Exemplo n.º 1
0
func NewLine(x1, y1, x2, y2 float64, a ...interface{}) Line {
	color := hge.Dword(0xFFFFFFFF)
	z := 0.5

	for i := 0; i < len(a); i++ {
		if i == 0 {
			if c, ok := a[i].(uint); ok {
				color = hge.Dword(c)
			}
			if c, ok := a[i].(hge.Dword); ok {
				color = c
			}
		}
		if i == 1 {
			if z1, ok := a[i].(float32); ok {
				z = float64(z1)
			}
			if z1, ok := a[i].(float64); ok {
				z = z1
			}
		}
	}

	return Line{x1, y1, x2, y2, z, color}
}
Exemplo n.º 2
0
//DWORD col=0xFFFFFFFF, float z=0.5f);
func (dm *DistortionMesh) Clear(a ...interface{}) {
	col := hge.Dword(0xFFFFFFFF)
	z := 0.5

	for i := 0; i < len(a); i++ {
		switch a[i].(type) {
		case float64:
			z = a[i].(float64)
		case float32:
			z = float64(a[i].(float32))
		case hge.Dword:
			col = a[i].(hge.Dword)
		case uint:
			col = hge.Dword(a[i].(uint))
		}
	}

	cols := float64(dm.cols)

	for j := 0.0; j < float64(dm.rows); j++ {
		for i := 0.0; i < cols; i++ {
			dm.dispArray[int(j*cols+i)].X = float32(i * dm.cellw)
			dm.dispArray[int(j*cols+i)].Y = float32(j * dm.cellh)
			dm.dispArray[int(j*cols+i)].Color = col
			dm.dispArray[int(j*cols+i)].Z = float32(z)
		}

	}
}
Exemplo n.º 3
0
func RenderSimulation() {
	// Render sky
	sky.SetColor(colSkyTop.HWColor(), 0)
	sky.SetColor(colSkyTop.HWColor(), 1)
	sky.SetColor(colSkyBtm.HWColor(), 2)
	sky.SetColor(colSkyBtm.HWColor(), 3)
	sky.Render(0, 0)

	// Render stars
	if seq_id >= 6 || seq_id < 2 {
		for i := 0; i < NUM_STARS; i++ {
			star.SetColor((hge.Dword(starA[i]*255.0) << 24) | 0xFFFFFF)
			star.RenderEx(starX[i], starY[i], 0.0, starS[i])
		}
	}

	// Render sun
	glow.SetColor(colSunGlow.HWColor())
	glow.RenderEx(sunX, sunY, 0.0, sunGlowS)
	sun.SetColor(colSun.HWColor())
	sun.RenderEx(sunX, sunY, 0.0, sunS)

	// Render moon
	glow.SetColor(colMoonGlow.HWColor())
	glow.RenderEx(moonX, moonY, 0.0, moonGlowS)
	moon.SetColor(colMoon.HWColor())
	moon.RenderEx(moonX, moonY, 0.0, moonS)

	// Render sea
	sea.Render(0, SKY_HEIGHT)
	seaglow.SetColor(colSeaGlow.HWColor())
	seaglow.RenderEx(seaGlowX, SKY_HEIGHT, 0.0, seaGlowSX, seaGlowSY)
}
Exemplo n.º 4
0
func LoadTexture(filename string, a ...interface{}) *Texture {
	fname := C.CString(filename)
	defer C.free(unsafe.Pointer(fname))

	size := hge.Dword(0)
	mipmap := false

	for i := 0; i < len(a); i++ {
		if i == 0 {
			if s, ok := a[i].(hge.Dword); ok {
				size = s
			}
		}
		if i == 1 {
			if m, ok := a[i].(bool); ok {
				mipmap = m
			}
		}
	}

	t := new(Texture)
	t.texture = C.HGE_Texture_Load(gfxHGE.HGE, fname, C.DWORD(size), boolToCInt(mipmap))
	if t.texture == 0 {
		return nil
	}

	runtime.SetFinalizer(t, func(texture *Texture) {
		texture.Free()
	})

	return t
}
Exemplo n.º 5
0
// Loads a resource into memory from disk.
func NewResource(filename string) (*Resource, hge.Dword) {
	var s C.DWORD
	fname := C.CString(filename)
	defer C.free(unsafe.Pointer(fname))

	r := new(Resource)

	r.Pointer = Pointer(C.HGE_Resource_Load(resourceHGE.HGE, fname, &s))

	runtime.SetFinalizer(r, func(runtime *Resource) {
		r.Free()
	})

	return r, hge.Dword(s)
}
Exemplo n.º 6
0
func RenderFunc() int {
	// Render graphics to the texture
	BeginScene(target)
	Clear(0)
	par.Render()
	spr.Render(x, y)
	EndScene()

	// Now put several instances of the rendered texture to the screen
	BeginScene()
	Clear(0)
	for i := 0.0; i < 6.0; i++ {
		tar.SetColor(hge.Dword(0xFFFFFF | ((int)((5-i)*40+55) << 24)))
		tar.RenderEx(i*100.0, i*50.0, i*hge.Pi/8, 1.0-i*0.1)
	}
	fnt.Printf(5, 5, font.TEXT_LEFT, "dt:%.3f\nFPS:%d (constant)", Delta(), GetFPS())
	EndScene()

	return 0
}
Exemplo n.º 7
0
func NewEffect(filename string, a ...interface{}) *Effect {
	fname := C.CString(filename)
	defer C.free(unsafe.Pointer(fname))

	size := hge.Dword(0)

	if len(a) == 1 {
		if s, ok := a[0].(hge.Dword); ok {
			size = s
		}
	}

	e := new(Effect)
	e.soundHGE = hge.New()
	e.effect = C.HGE_Effect_Load(e.soundHGE.HGE, fname, C.DWORD(size))

	runtime.SetFinalizer(e, func(effect *Effect) {
		effect.Free()
	})

	return e
}