示例#1
0
func (f *Furniture) Render(pos mathgl.Vec2, width float32) {
	var rgba [4]float64
	gl.GetDoublev(gl.CURRENT_COLOR, &rgba[0])
	gl.PushAttrib(gl.CURRENT_BIT)
	if !f.Blocks_los || !f.alpha_enabled {
		f.alpha = 1
	}
	gl.Color4ub(byte(255*rgba[0]), byte(255*rgba[1]), byte(255*rgba[2]), byte(255*rgba[3]*f.alpha))
	orientation := f.Orientations[f.Rotation]
	dy := width * float32(orientation.Texture.Data().Dy()) / float32(orientation.Texture.Data().Dx())
	// orientation.Texture.Data().Render(float64(pos.X), float64(pos.Y), float64(width), float64(dy))
	orientation.Texture.Data().RenderAdvanced(float64(pos.X), float64(pos.Y), float64(width), float64(dy), 0, !f.Flip)
	gl.PopAttrib()
}
示例#2
0
文件: spawn.go 项目: RickDakan/haunts
func (sp *SpawnPoint) RenderOnFloor() {
	re := topSpawnRegexp()
	if re == nil || !re.MatchString(sp.Name) {
		return
	}

	var rgba [4]float64
	gl.GetDoublev(gl.CURRENT_COLOR, &rgba[0])
	gl.PushAttrib(gl.CURRENT_BIT)
	gl.Disable(gl.TEXTURE_2D)

	// This just creates a color that is consistent among all spawn points whose
	// names match SpawnName-.*
	prefix := sp.Name
	for i := range prefix {
		if prefix[i] == '-' {
			prefix = prefix[0:i]
			break
		}
	}
	h := fnv.New32()
	h.Write([]byte(prefix))
	hs := h.Sum32()
	gl.Color4ub(byte(hs%256), byte((hs/256)%256), byte((hs/(256*256))%256), byte(255*rgba[3]))

	base.EnableShader("box")
	base.SetUniformF("box", "dx", float32(sp.Dx))
	base.SetUniformF("box", "dy", float32(sp.Dy))
	if !sp.temporary {
		base.SetUniformI("box", "temp_invalid", 0)
	} else if !sp.invalid {
		base.SetUniformI("box", "temp_invalid", 1)
	} else {
		base.SetUniformI("box", "temp_invalid", 2)
	}
	(&texture.Object{}).Data().Render(float64(sp.X), float64(sp.Y), float64(sp.Dx), float64(sp.Dy))
	base.EnableShader("")
	gl.PopAttrib()
}
示例#3
0
func (e *Entity) Render(pos mathgl.Vec2, width float32) {
	var rgba [4]float64
	gl.GetDoublev(gl.CURRENT_COLOR, &rgba[0])
	e.last_render_width = width
	gl.Enable(gl.TEXTURE_2D)
	e.drawReticle(pos, rgba)
	if e.sprite.sp != nil {
		dxi, dyi := e.sprite.sp.Dims()
		dx := float32(dxi)
		dy := float32(dyi)
		tx, ty, tx2, ty2 := e.sprite.sp.Bind()
		gl.Begin(gl.QUADS)
		gl.TexCoord2d(tx, -ty)
		gl.Vertex2f(pos.X, pos.Y)
		gl.TexCoord2d(tx, -ty2)
		gl.Vertex2f(pos.X, pos.Y+dy*width/dx)
		gl.TexCoord2d(tx2, -ty2)
		gl.Vertex2f(pos.X+width, pos.Y+dy*width/dx)
		gl.TexCoord2d(tx2, -ty)
		gl.Vertex2f(pos.X+width, pos.Y)
		gl.End()
	}
}