Beispiel #1
0
# How to draw a picture on a primitive

import os
import harfang as hg
import math

# load Harfang plugins (renderer, image loader, etc...)
hg.LoadPlugins()

# create the renderer
renderer = hg.CreateRenderer()
renderer.Open()

# open a new window
win = hg.NewWindow(480, 240)

# create a new output surface for the newly opened window
surface = renderer.NewOutputSurface(win)
renderer.SetOutputSurface(surface)

# initialize the render system, which is used to draw through the renderer
render_system = hg.RenderSystem()
render_system.Initialize(renderer)

# create a gpu texture
pic = hg.Picture(512, 512, hg.PictureRGBA8)
tex = renderer.NewTexture("clock_tex")
if not renderer.CreateTexture(tex, pic):
	print("Could not create clock texture")

Beispiel #2
0
monitors=None
monitors_names=[]
modes=None
current_monitor=0
current_mode=0
ratio_filter=0
flag_windowed=False

screenModes=[hg.WV_FullscreenMonitor1,hg.WV_FullscreenMonitor2,hg.WV_FullscreenMonitor3]
smr_screenMode=hg.WV_FullscreenMonitor1
smr_resolution=hg.Vec2(1280,1024)

hg.InputInit()
hg.WindowSystemInit()

win = hg.NewWindow("Screen Mode Requester", res_w, res_h, 32)#, hg.WV_Fullscreen)
hg.RenderInit(win)
hg.RenderReset(res_w, res_h, hg.RF_MSAA8X | hg.RF_FlipAfterRender | hg.RF_FlushAfterRender | hg.RF_MaxAnisotropy | hg.RF_VSync)

hg.AddAssetsFolder("../assets_compiled")


# initialize ImGui
imgui_prg = hg.LoadProgramFromAssets('shaders/imgui')
imgui_img_prg = hg.LoadProgramFromAssets('shaders/imgui_image')

hg.ImGuiInit(10, imgui_prg, imgui_img_prg)

def gui_ScreenModeRequester():
	global flag_windowed
	global current_monitor,current_mode,monitors_names,modes
Beispiel #3
0
# Basic scene with pipeline

import harfang as hg

hg.InputInit()
hg.WindowSystemInit()

res_x, res_y = 1280, 720

win = hg.NewWindow(res_x, res_y)
hg.RenderInit(win)
hg.RenderReset(res_x, res_y, hg.ResetVSync | hg.ResetMSAA4X)

hg.AddAssetsFolder("../3d-fight_compiled/")

imgui_prg = hg.LoadProgramFromAssets('core/shader/imgui')
imgui_img_prg = hg.LoadProgramFromAssets('core/shader/imgui_image')
hg.ImGuiInit(10, imgui_prg, imgui_img_prg)

check = True
open = True
combo = 0
color = hg.Color(1, 0, 1)

# hg.SetRenderDebug(hg.RenderDebugProfiler | hg.RenderDebugStats | hg.RenderDebugText)

# Vertex model:
vs_decl = hg.VertexDecl()
vs_decl.Begin()
vs_decl.Add(hg.A_Position, 3, hg.AT_Float)
vs_decl.Add(hg.A_Normal, 3, hg.AT_Uint8, True, True)
Beispiel #4
0
# initialize  Harfang
hg.InputInit()
hg.AudioInit()
hg.WindowSystemInit()

keyboard = hg.Keyboard()
mouse = hg.Mouse()

sel,scr_mode,scr_res = request_screen_mode(16/9)

if sel == "ok":
	Main.resolution.x,Main.resolution.y=scr_res.x,scr_res.y
	Main.game_scale=Main.resolution.y / Main.original_resolution.y
	Main.screenMode=scr_mode

	win = hg.NewWindow("WinterZ", int(Main.resolution.x), int(Main.resolution.y), 32)#, hg.WV_Fullscreen)
	hg.RenderInit(win)
	hg.RenderReset(int(Main.resolution.x), int(Main.resolution.y), hg.RF_MSAA8X | hg.RF_FlipAfterRender | hg.RF_FlushAfterRender | hg.RF_MaxAnisotropy | hg.RF_VSync)

	hg.AddAssetsFolder("../assets_compiled")

	render_state_quad = hg.ComputeRenderState(hg.BM_Alpha, hg.DT_Less, hg.FC_Disabled)
	shader_texture = hg.LoadProgramFromAssets("shaders/texture")
	shader_white = hg.LoadProgramFromAssets("shaders/white")

	init_game()
	start_ambient_sound()

	Main.score = 0
	Main.score_max = 0
	reset_intro_phase()
Beispiel #5
0
box_width = 5.5
box_height = 5.6
light_width = box_width * 0.25

# load Harfang plugins (renderer, image loader, etc...)
hg.LoadPlugins()

# mount the runtime package required for the rendering
hg.MountFileDriver(hg.StdFileDriver("_data"))

# create the renderer
renderer = hg.CreateRenderer()
renderer.Open()

# open a new window
win = hg.NewWindow(800, 600)

# create a new output surface for the newly opened window
surface = renderer.NewOutputSurface(win)
renderer.SetOutputSurface(surface)

# initialize the render system, which is used to draw through the renderer
render_system = hg.RenderSystem()
render_system.Initialize(renderer)

# create scene
scene = hg.Scene()
hg.SceneSetupCoreSystemsAndComponents(scene, render_system)

env = hg.Environment()
env.SetBackgroundColor(hg.Color.Black)
# Demonstrate the effect of hinting and grid snapping on text rendering with raster font

import harfang as hg

hg.LoadPlugins()

# create the renderer
renderer = hg.CreateRenderer()
renderer.Open()

# open a new window
win = hg.NewWindow(1000, 1000)

# create a new output surface for the newly opened window
surface = renderer.NewOutputSurface(win)
renderer.SetOutputSurface(surface)

# initialize the render system, which is used to draw through the renderer
render_system = hg.RenderSystem()
render_system.Initialize(renderer)

# create the font objects
no_hint_fonts = []
for size in range(4, 44):
    no_hint_fonts.append(hg.RasterFont("@core/fonts/default.ttf", size, 512))

hint_fonts = []
for size in range(4, 44):
    hint_fonts.append(
        hg.RasterFont("@core/fonts/default.ttf", size, 512, 2, True))
Beispiel #7
0
import harfang as hg

# load Harfang plugins (renderer, image loader, etc...)
hg.LoadPlugins()

# create the renderer
renderer = hg.CreateRenderer()
renderer.Open()

# open a new window
win = hg.NewWindow(640, 480)

# create a new output surface for the newly opened window
surface = renderer.NewOutputSurface(win)
renderer.SetOutputSurface(surface)

# get keyboard device
keyboard = hg.GetInputSystem().GetDevice("keyboard")

check = True
open = True
combo = 0
color = hg.Color(1, 0, 1)

hg.ImGuiSetOutputSurface(surface)

while hg.IsWindowOpen(win) and not keyboard.WasPressed(hg.KeyEscape):
    if hg.ImGuiBegin("GUI"):
        _, check = hg.ImGuiCheckbox("Check", check)

        _, open = hg.ImGuiCollapsingHeader("Header", open)
Beispiel #8
0
# How to draw text using TTF fonts with the render system

import harfang as hg

# load Harfang plugins (renderer, image loader, etc...)
hg.LoadPlugins()

# create the renderer
renderer = hg.CreateRenderer()
renderer.Open()

# open a new window
win = hg.NewWindow(860, 200)

# create a new output surface for the newly opened window
surface = renderer.NewOutputSurface(win)
renderer.SetOutputSurface(surface)

# initialize the render system, which is used to draw through the renderer
render_system = hg.RenderSystem()
render_system.Initialize(renderer)

# create the font object
font = hg.RasterFont("@core/fonts/default.ttf", 48, 512)

# set default render states
renderer.Set2DMatrices()
renderer.EnableBlending(True)
renderer.EnableDepthTest(False)

# get keyboard device