本文整理匯總了Golang中github.com/MobRulesGames/opengl/gl.Enable函數的典型用法代碼示例。如果您正苦於以下問題:Golang Enable函數的具體用法?Golang Enable怎麽用?Golang Enable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Enable函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: preDraw
func (w *TextLine) preDraw(region Region) {
if !w.initted {
w.initted = true
w.texture = gl.GenTexture()
w.text = w.next_text
w.figureDims()
}
if w.text != w.next_text {
w.text = w.next_text
w.figureDims()
}
gl.PushMatrix()
gl.Color3d(0, 0, 0)
gl.Begin(gl.QUADS)
gl.Vertex2i(region.X, region.Y)
gl.Vertex2i(region.X, region.Y+region.Dy)
gl.Vertex2i(region.X+region.Dx, region.Y+region.Dy)
gl.Vertex2i(region.X+region.Dx, region.Y)
gl.End()
gl.PushAttrib(gl.TEXTURE_BIT)
gl.Enable(gl.TEXTURE_2D)
w.texture.Bind(gl.TEXTURE_2D)
gl.PushAttrib(gl.COLOR_BUFFER_BIT)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
}
示例2: Draw
func (w *ImageBox) Draw(region Region) {
w.Render_region = region
// We check texture == 0 and not active because active only indicates if we
// have a texture that we need to free later. It's possible for us to have
// a texture that someone else owns.
if w.texture == 0 {
return
}
gl.Enable(gl.TEXTURE_2D)
w.texture.Bind(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.Color4d(w.r, w.g, w.b, w.a)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0, 0)
gl.Vertex2i(region.X, region.Y)
gl.TexCoord2f(0, -1)
gl.Vertex2i(region.X, region.Y+region.Dy)
gl.TexCoord2f(1, -1)
gl.Vertex2i(region.X+region.Dx, region.Y+region.Dy)
gl.TexCoord2f(1, 0)
gl.Vertex2i(region.X+region.Dx, region.Y)
gl.End()
gl.Disable(gl.TEXTURE_2D)
}
示例3: PushClipPlanes
func (r Region) PushClipPlanes() {
if len(clippers) == 0 {
gl.Enable(gl.CLIP_PLANE0)
gl.Enable(gl.CLIP_PLANE1)
gl.Enable(gl.CLIP_PLANE2)
gl.Enable(gl.CLIP_PLANE3)
r.setClipPlanes()
clippers = append(clippers, r)
} else {
cur := clippers[len(clippers)-1]
clippers = append(clippers, r.Isect(cur))
clippers[len(clippers)-1].setClipPlanes()
}
}
示例4: LoadSprite
func (m *Manager) LoadSprite(path string) (*Sprite, error) {
// We can't run this during an init() function because it will get queued to
// run before the opengl context is created, so we just check here and run
// it if we haven't run it before.
gen_tex_once.Do(func() {
render.Queue(func() {
gl.Enable(gl.TEXTURE_2D)
error_texture = gl.GenTexture()
error_texture.Bind(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
pink := []byte{255, 0, 255, 255}
glu.Build2DMipmaps(gl.TEXTURE_2D, 4, 1, 1, gl.RGBA, pink)
})
})
path = filepath.Clean(path)
err := m.loadSharedSprite(path)
if err != nil {
return nil, err
}
var s Sprite
m.mutex.Lock()
s.shared = m.shared[path]
m.mutex.Unlock()
s.anim_node = s.shared.anim_start
s.state_node = s.shared.state_start
return &s, nil
}
示例5: RenderAdvanced
func RenderAdvanced(x, y, dx, dy, rot float64, flip bool) {
if textureList != 0 {
var run, op mathgl.Mat4
run.Identity()
op.Translation(float32(x), float32(y), 0)
run.Multiply(&op)
op.Translation(float32(dx/2), float32(dy/2), 0)
run.Multiply(&op)
op.RotationZ(float32(rot))
run.Multiply(&op)
if flip {
op.Translation(float32(-dx/2), float32(-dy/2), 0)
run.Multiply(&op)
op.Scaling(float32(dx), float32(dy), 1)
run.Multiply(&op)
} else {
op.Translation(float32(dx/2), float32(-dy/2), 0)
run.Multiply(&op)
op.Scaling(float32(-dx), float32(dy), 1)
run.Multiply(&op)
}
gl.PushMatrix()
gl.MultMatrixf(&run[0])
gl.Enable(gl.TEXTURE_2D)
gl.CallList(textureList)
gl.PopMatrix()
}
}
示例6: MakeLosTexture
// Creates a LosTexture with the specified size, which must be a power of two.
func MakeLosTexture() *LosTexture {
var lt LosTexture
lt.pix = make([]byte, LosTextureSizeSquared)
lt.p2d = make([][]byte, LosTextureSize)
lt.rec = make(chan gl.Texture, 1)
for i := 0; i < LosTextureSize; i++ {
lt.p2d[i] = lt.pix[i*LosTextureSize : (i+1)*LosTextureSize]
}
render.Queue(func() {
gl.Enable(gl.TEXTURE_2D)
tex := gl.GenTexture()
tex.Bind(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, len(lt.p2d), len(lt.p2d), 0, gl.ALPHA, gl.BYTE, lt.pix)
lt.rec <- tex
runtime.SetFinalizer(<, losTextureFinalize)
})
return <
}
示例7: drawPrep
func drawPrep() {
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.TEXTURE_2D)
gl.PolygonMode(gl.FRONT_AND_BACK, gl.FILL)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.ClearStencil(0)
gl.Clear(gl.STENCIL_BUFFER_BIT)
}
示例8: Remap
// Updates OpenGl with any changes that have been made to the texture.
// OpenGl calls in this method are run on the render thread
func (lt *LosTexture) Remap() {
if !lt.ready() {
return
}
render.Queue(func() {
gl.Enable(gl.TEXTURE_2D)
lt.tex.Bind(gl.TEXTURE_2D)
gl.TexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, len(lt.p2d), len(lt.p2d), gl.ALPHA, lt.pix)
})
}
示例9: makeErrorTexture
func makeErrorTexture() {
gl.Enable(gl.TEXTURE_2D)
error_texture = gl.GenTexture()
error_texture.Bind(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
transparent := []byte{0, 0, 0, 0}
glu.Build2DMipmaps(gl.TEXTURE_2D, 4, 1, 1, gl.RGBA, transparent)
}
示例10: makeTexture
func (s *sheet) makeTexture(pixer <-chan []byte) {
gl.Enable(gl.TEXTURE_2D)
s.texture = gl.GenTexture()
s.texture.Bind(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
data := <-pixer
glu.Build2DMipmaps(gl.TEXTURE_2D, 4, s.dx, s.dy, gl.RGBA, data)
memory.FreeBlock(data)
}
示例11: Render
func Render(x, y, dx, dy float64) {
var run, op mathgl.Mat4
run.Identity()
op.Translation(float32(x), float32(y), 0)
run.Multiply(&op)
op.Scaling(float32(dx), float32(dy), 1)
run.Multiply(&op)
gl.PushMatrix()
gl.Enable(gl.TEXTURE_2D)
gl.MultMatrixf(&run[0])
gl.CallList(textureList)
gl.PopMatrix()
}
示例12: Draw
func (mdb *MediumDialogBox) Draw(region gui.Region) {
mdb.region = region
if mdb.done {
return
}
gl.Enable(gl.TEXTURE_2D)
gl.Color4ub(255, 255, 255, 255)
mdb.layout.Background.Data().RenderNatural(region.X, region.Y)
for _, button := range mdb.buttons {
button.RenderAt(region.X, region.Y)
}
for i := range mdb.format.Sections {
section := mdb.format.Sections[i]
data := mdb.data.Pages[mdb.data.cur_page].Sections[i]
p := section.Paragraph
d := base.GetDictionary(p.Size)
var just gui.Justification
switch p.Halign {
case "left":
just = gui.Left
case "right":
just = gui.Right
case "center":
just = gui.Center
default:
base.Error().Printf("Unknown justification '%s'", p.Halign)
p.Halign = "left"
}
var valign gui.Justification
switch p.Valign {
case "top":
valign = gui.Top
case "bottom":
valign = gui.Bottom
case "center":
valign = gui.Center
default:
base.Error().Printf("Unknown justification '%s'", p.Valign)
p.Valign = "top"
}
gl.Color4ub(255, 255, 255, 255)
d.RenderParagraph(data.Text, float64(p.X+region.X), float64(p.Y+region.Y)-d.MaxHeight()/2, 0, float64(p.Dx), d.MaxHeight(), just, valign)
gl.Color4ub(255, 255, 255, byte(data.shading*255))
tex := data.Image.Data()
tex.RenderNatural(region.X+section.X-tex.Dx()/2, region.Y+section.Y-tex.Dy()/2)
}
}
示例13: SetImage
func (w *ImageBox) SetImage(path string) {
w.UnsetImage()
data, err := os.Open(path)
if err != nil {
// TODO: Log error
return
}
var img image.Image
img, _, err = image.Decode(data)
if err != nil {
// TODO: Log error
return
}
w.Request_dims.Dx = img.Bounds().Dx()
w.Request_dims.Dy = img.Bounds().Dy()
canvas := image.NewRGBA(image.Rect(0, 0, img.Bounds().Dx(), img.Bounds().Dy()))
for y := 0; y < canvas.Bounds().Dy(); y++ {
for x := 0; x < canvas.Bounds().Dx(); x++ {
r, g, b, a := img.At(x, y).RGBA()
base := 4*x + canvas.Stride*y
canvas.Pix[base] = uint8(r)
canvas.Pix[base+1] = uint8(g)
canvas.Pix[base+2] = uint8(b)
canvas.Pix[base+3] = uint8(a)
}
}
w.texture = gl.GenTexture()
gl.Enable(gl.TEXTURE_2D)
w.texture.Bind(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
glu.Build2DMipmaps(gl.TEXTURE_2D, 4, img.Bounds().Dx(), img.Bounds().Dy(), gl.RGBA, canvas.Pix)
w.active = true
}
示例14: figureDims
func (w *TextLine) figureDims() {
// Always draw the text as white on a transparent background so that we can change
// the color easily through opengl
w.rdims.Dx, w.rdims.Dy = drawText(w.font, w.context, color.RGBA{255, 255, 255, 255}, image.NewRGBA(image.Rect(0, 0, 1, 1)), w.text)
texture_dims := Dims{
Dx: int(nextPowerOf2(uint32(w.rdims.Dx))),
Dy: int(nextPowerOf2(uint32(w.rdims.Dy))),
}
w.rgba = image.NewRGBA(image.Rect(0, 0, texture_dims.Dx, texture_dims.Dy))
drawText(w.font, w.context, color.RGBA{255, 255, 255, 255}, w.rgba, w.text)
gl.Enable(gl.TEXTURE_2D)
w.texture.Bind(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
glu.Build2DMipmaps(gl.TEXTURE_2D, 4, w.rgba.Bounds().Dx(), w.rgba.Bounds().Dy(), gl.RGBA, w.rgba.Pix)
gl.Disable(gl.TEXTURE_2D)
}
示例15: Draw
func (w *VerticalTable) Draw(region Region) {
gl.Enable(gl.BLEND)
gl.Disable(gl.TEXTURE_2D)
dx := region.Dx
if dx > w.Request_dims.Dx && !w.Ex {
dx = w.Request_dims.Dx
}
dy := region.Dy
if dy > w.Request_dims.Dy && !w.Ex {
dy = w.Request_dims.Dy
}
gl.Color4d(
w.params.Background.R,
w.params.Background.G,
w.params.Background.B,
w.params.Background.A)
gl.Begin(gl.QUADS)
gl.Vertex2i(region.X, region.Y+region.Dy-dy)
gl.Vertex2i(region.X, region.Y+region.Dy)
gl.Vertex2i(region.X+dx, region.Y+region.Dy)
gl.Vertex2i(region.X+dx, region.Y+region.Dy-dy)
gl.End()
gl.Color4d(
w.params.Border.R,
w.params.Border.G,
w.params.Border.B,
w.params.Border.A)
gl.Begin(gl.LINES)
gl.Vertex2i(region.X, region.Y+region.Dy-dy)
gl.Vertex2i(region.X, region.Y+region.Dy)
gl.Vertex2i(region.X, region.Y+region.Dy)
gl.Vertex2i(region.X+dx, region.Y+region.Dy)
gl.Vertex2i(region.X+dx, region.Y+region.Dy)
gl.Vertex2i(region.X+dx, region.Y+region.Dy-dy)
gl.Vertex2i(region.X+dx, region.Y+region.Dy-dy)
gl.Vertex2i(region.X, region.Y+region.Dy-dy)
gl.End()
fill_available := region.Dy - w.Request_dims.Dy
if fill_available < 0 {
fill_available = 0
}
fill_request := 0
for _, child := range w.Children {
if _, ey := child.Expandable(); ey {
fill_request += child.Requested().Dy
}
}
var child_region Region
child_region.Y = region.Y + region.Dy
for _, child := range w.Children {
child_region.Dims = child.Requested()
if _, ey := child.Expandable(); ey && fill_request > 0 {
child_region.Dy += (child_region.Dy * fill_available) / fill_request
}
if region.Dy < w.Request_dims.Dy {
child_region.Dims.Dy *= region.Dy
child_region.Dims.Dy /= w.Request_dims.Dy
}
if child_region.Dx > region.Dx {
child_region.Dx = region.Dx
}
if ex, _ := child.Expandable(); child_region.Dx < region.Dx && ex {
child_region.Dx = region.Dx
}
child_region.X = region.X
child_region.Y -= child_region.Dy
child_region.Y -= w.params.Spacing
child.Draw(child_region)
}
w.Render_region = region
}