本文整理汇总了Golang中github.com/go-gl/gl/v2/1/gl.Enable函数的典型用法代码示例。如果您正苦于以下问题:Golang Enable函数的具体用法?Golang Enable怎么用?Golang Enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Enable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: PrintSegment
// Shouldn't have tabs nor newlines
func (o *OpenGlStream) PrintSegment(s string) {
if s == "" {
return
}
if o.BackgroundColor != nil && o.BorderColor == nil {
gl.PushAttrib(gl.CURRENT_BIT)
gl.Color3dv((*float64)(&o.BackgroundColor[0]))
gl.PushMatrix()
gl.Translated(float64(o.pos[0]), float64(o.pos[1]), 0)
for range s {
gl.CallList(oFontBackground)
}
gl.PopMatrix()
gl.PopAttrib()
}
gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_LOD_BIAS, float32(lodBias*0.01))
gl.Enable(gl.BLEND)
defer gl.Disable(gl.BLEND)
gl.Enable(gl.TEXTURE_2D)
defer gl.Disable(gl.TEXTURE_2D)
gl.PushMatrix()
gl.Translated(float64(o.pos[0]), float64(o.pos[1]), 0)
gl.ListBase(oFontBase + uint32(o.FontOptions)*96)
gl.CallLists(int32(len(s)), gl.UNSIGNED_BYTE, gl.Ptr(&[]byte(s)[0]))
gl.PopMatrix()
//CheckGLError()
}
开发者ID:rexposadas,项目名称:Conception-go,代码行数:33,代码来源:text.go
示例2: draw
// OpenGL draw function
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.LoadIdentity()
gl.Begin(gl.LINES)
gl.Color3f(.2, .2, .2)
for i := range staticLines {
x := staticLines[i].GetAsSegment().A.X
y := staticLines[i].GetAsSegment().A.Y
gl.Vertex3f(float32(x), float32(y), 0)
x = staticLines[i].GetAsSegment().B.X
y = staticLines[i].GetAsSegment().B.Y
gl.Vertex3f(float32(x), float32(y), 0)
}
gl.End()
gl.Color4f(.3, .3, 1, .8)
// draw balls
for _, ball := range balls {
gl.PushMatrix()
pos := ball.Body.Position()
rot := ball.Body.Angle() * chipmunk.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(ballRadius), 60)
gl.PopMatrix()
}
}
开发者ID:TheZeroSlave,项目名称:chipmunk,代码行数:33,代码来源:bouncing_balls.go
示例3: draw
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.LoadIdentity()
//Transform screen to keep player in middle. Added intentation to make obvious the push matrix is like a block
gl.PushMatrix()
// gl.Translatef((1280/2)-float32(player.x), 0, 0.0)
// gl.Begin(gl.LINES)
// gl.Color3f(.2, .5, .2)
// for i := range staticLines {
// x := staticLines[i].GetAsSegment().A.X
// y := staticLines[i].GetAsSegment().A.Y
// gl.Vertex3f(float32(x), float32(y), 0)
// x = staticLines[i].GetAsSegment().B.X
// y = staticLines[i].GetAsSegment().B.Y
// gl.Vertex3f(float32(x), float32(y), 0)
// }
// gl.End()
gl.Color4f(player.color_r, player.color_g, player.color_b, player.color_a)
//Draw Player
gl.PushMatrix()
rot := player.rot
pos_x := player.x
pos_y := player.y
gl.Translatef(pos_x, pos_y, 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(BALL_RADIUS), 20)
gl.PopMatrix()
//Draw the grapple
gl.PushMatrix()
gl.Translatef(player.hook.x_end, player.hook.y_end, 0.0)
drawCircle(float64(5), 5)
gl.PopMatrix()
//Grapple Line
gl.LineWidth(2.5)
gl.Color3f(1.0, 0.0, 0.0)
gl.Begin(gl.LINES)
gl.Vertex3f(player.x, player.y, 0.0)
gl.Vertex3f(player.hook.x_end, player.hook.y_end, 0)
gl.End()
//Second Pop
gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:54,代码来源:glfwtest.go
示例4: main
func main() {
runtime.LockOSThread()
if err := glfw.Init(); err != nil {
panic(err)
}
defer glfw.Terminate()
window, err := glfw.CreateWindow(800, 600, "fontstash example", nil, nil)
if err != nil {
panic(err)
}
window.MakeContextCurrent()
glfw.SwapInterval(1)
gl.Init()
data, err := ioutil.ReadFile(filepath.Join("..", "ClearSans-Regular.ttf"))
if err != nil {
panic(err)
}
gl.Enable(gl.TEXTURE_2D)
tmpBitmap := make([]byte, 512*512)
cdata, err, _, tmpBitmap := truetype.BakeFontBitmap(data, 0, 32, tmpBitmap, 512, 512, 32, 96)
var ftex uint32
gl.GenTextures(1, &ftex)
gl.BindTexture(gl.TEXTURE_2D, ftex)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, 512, 512, 0,
gl.ALPHA, gl.UNSIGNED_BYTE, unsafe.Pointer(&tmpBitmap[0]))
gl.ClearColor(0.3, 0.3, 0.32, 1.)
for !window.ShouldClose() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, 800, 600, 0, 0, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Color4ub(255, 255, 255, 255)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
my_print(100, 100, "The quick brown fox jumps over the fence", ftex, cdata)
window.SwapBuffers()
glfw.PollEvents()
}
}
开发者ID:shibukawa,项目名称:fontstash.go,代码行数:54,代码来源:truetype.go
示例5: setModelViewOptions
func setModelViewOptions() {
gl.Enable(gl.TEXTURE_2D)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.DITHER)
gl.Enable(gl.CULL_FACE)
gl.CullFace(gl.FRONT)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.BLEND)
gl.Enable(gl.ALPHA_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Disable(gl.DEPTH_TEST)
}
开发者ID:fmd,项目名称:gogol,代码行数:12,代码来源:window.go
示例6: draw
// OpenGL draw function
func draw() {
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.LoadIdentity()
player := game.Player
//Transform screen.
gl.PushMatrix()
gl.Translatef((1280/2)-float32((player.Body.Position().X)), 0, 0.0)
gl.Begin(gl.LINES)
gl.Color3f(.2, .5, .2)
for _, segment := range game.Level.GetChipmunkSegments() {
x := segment.GetAsSegment().A.X
y := segment.GetAsSegment().A.Y
gl.Vertex3f(float32(x), float32(y), 0)
x = segment.GetAsSegment().B.X
y = segment.GetAsSegment().B.Y
gl.Vertex3f(float32(x), float32(y), 0)
}
gl.End()
gl.Color4f(.9, .1, 1, .9)
// draw balls
for _, enemy := range game.Enemies {
gl.PushMatrix()
pos := enemy.Body.Position()
rot := enemy.Body.Angle() * game.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(enemy.Radius), 60)
gl.PopMatrix()
}
gl.Color4f(.3, .3, 1, .8)
//Draw Player
gl.PushMatrix()
pos := player.Body.Position()
rot := player.Body.Angle() * game.DegreeConst
gl.Translatef(float32(pos.X), float32(pos.Y), 0.0)
gl.Rotatef(float32(rot), 0, 0, 1)
drawCircle(float64(player.Radius), 60)
gl.PopMatrix()
gl.PopMatrix()
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:50,代码来源:main.go
示例7: Draw
func (atlas *FontAtlas) Draw(text string, b Bounds) {
atlas.LoadGlyphs(text)
gl.Enable(gl.BLEND)
defer gl.Disable(gl.BLEND)
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.TEXTURE_2D)
defer gl.Disable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, atlas.Texture)
x := b.Min.X + atlas.drawPadding
y := (b.Max.Y+b.Min.Y)/2 + (ceilPxf(atlas.maxBounds.Min.Y)+ceilPxf(atlas.maxBounds.Max.Y))/2
p := rune(0)
for _, r := range text {
glyph := atlas.Rendered[r]
dx := float32(glyph.Loc.Dx())
dy := float32(glyph.Loc.Dy())
px := x + ceilPxf(glyph.Bounds.Min.X) - glyphPadding
py := y + ceilPxf(glyph.Bounds.Min.Y) - glyphPadding
// this is not the ideal way of positioning the letters
// will create positioning artifacts
// but it the result is more
px = float32(math.Trunc(float64(px)))
py = float32(math.Trunc(float64(py)))
gl.Begin(gl.QUADS)
{
gl.TexCoord2f(glyph.RelLoc.Min.X, glyph.RelLoc.Min.Y)
gl.Vertex2f(px, py)
gl.TexCoord2f(glyph.RelLoc.Max.X, glyph.RelLoc.Min.Y)
gl.Vertex2f(px+dx, py)
gl.TexCoord2f(glyph.RelLoc.Max.X, glyph.RelLoc.Max.Y)
gl.Vertex2f(px+dx, py+dy)
gl.TexCoord2f(glyph.RelLoc.Min.X, glyph.RelLoc.Max.Y)
gl.Vertex2f(px, py+dy)
}
gl.End()
k := atlas.Face.Kern(p, r)
p = r
x += ceilPxf(glyph.Advance + k)
}
}
开发者ID:egonelbre,项目名称:spector,代码行数:48,代码来源:fontatlas.go
示例8: DrawColoredAtXY
func (img *glImage) DrawColoredAtXY(x, y int, color [4]float32) {
// TODO have the state knwon globally somewhere so this does not need to be
// called all the time
gl.Enable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, img.id)
gl.Begin(gl.QUADS)
gl.Color4f(color[0], color[1], color[2], color[3])
gl.TexCoord2f(img.left, img.top)
gl.Vertex2i(int32(x), int32(y))
gl.Color4f(color[0], color[1], color[2], color[3])
gl.TexCoord2f(img.right, img.top)
gl.Vertex2i(int32(x+img.Width), int32(y))
gl.Color4f(color[0], color[1], color[2], color[3])
gl.TexCoord2f(img.right, img.bottom)
gl.Vertex2i(int32(x+img.Width), int32(y+img.Height))
gl.Color4f(color[0], color[1], color[2], color[3])
gl.TexCoord2f(img.left, img.bottom)
gl.Vertex2i(int32(x), int32(y+img.Height))
gl.End()
}
开发者ID:gonutz,项目名称:settlers,代码行数:26,代码来源:gl_image.go
示例9: LataaKuvat
func LataaKuvat() {
file, err := os.Open("tiles.png")
if err != nil {
panic("En saa avattua kuvatiedostoa: " + err.Error())
}
kuva, _, err := image.Decode(file)
if err != nil {
panic("Kuva on rikki: " + err.Error())
}
var texture uint32
gl.GenTextures(1, &texture)
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.TexImage2D(gl.TEXTURE_2D, 0, 4,
int32(kuva.Bounds().Dx()), int32(kuva.Bounds().Dy()), 0,
gl.RGBA, gl.UNSIGNED_BYTE,
unsafe.Pointer(&kuva.(*image.RGBA).Pix[0]),
)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.Enable(gl.TEXTURE_2D)
}
开发者ID:joonazan,项目名称:go-opas,代码行数:26,代码来源:piirto.go
示例10: newChipset
func newChipset(file string, tilesize int) chipset {
imgFile, err := os.Open(file)
if err != nil {
log.Fatalf("texture %q not found on disk: %v\n", file, err)
}
img, _, err := image.Decode(imgFile)
if err != nil {
panic(err)
}
rgba := image.NewRGBA(img.Bounds())
draw.Draw(rgba, rgba.Bounds(), img, image.ZP, draw.Src)
var texture uint32
gl.Enable(gl.TEXTURE_2D)
gl.GenTextures(1, &texture)
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.TexImage2D(
gl.TEXTURE_2D,
0, gl.RGBA,
int32(rgba.Rect.Size().X),
int32(rgba.Rect.Size().Y),
0,
gl.RGBA,
gl.UNSIGNED_BYTE,
gl.Ptr(rgba.Pix))
return chipset{width: rgba.Bounds().Dx(), height: rgba.Bounds().Dy(), handle: texture, tilesize: tilesize}
}
开发者ID:manyminds,项目名称:tmx,代码行数:33,代码来源:opengl.go
示例11: drawHud
func (ctx *DrawContext) drawHud(o *orrery.Orrery, frametime time.Duration) {
txt, size, err := ctx.createHudTexture(o, frametime)
if err != nil {
log.Fatalf(`can't create texture from text surface: %s`, err)
}
defer gl.DeleteTextures(1, &txt)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
gl.Ortho(0.0, float64(ctx.width), float64(ctx.height), 0.0, -1.0, 1.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Clear(gl.DEPTH_BUFFER_BIT)
gl.BindTexture(gl.TEXTURE_2D, txt)
gl.Enable(gl.TEXTURE_2D)
defer gl.Disable(gl.TEXTURE_2D)
gl.Color3f(1, 1, 1)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0, 0)
gl.Vertex2f(0.0, 0.0)
gl.TexCoord2f(1, 0)
gl.Vertex2f(float32(size[0]), 0.0)
gl.TexCoord2f(1, 1)
gl.Vertex2f(float32(size[0]), float32(size[1]))
gl.TexCoord2f(0, 1)
gl.Vertex2f(0.0, float32(size[1]))
gl.End()
gl.PopMatrix()
}
开发者ID:farhaven,项目名称:universe,代码行数:33,代码来源:drawing.go
示例12: init
func (c *Context) init() {
if err := gl.Init(); err != nil {
panic(err)
}
// Textures' pixel formats are alpha premultiplied.
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
}
开发者ID:DrJosh9000,项目名称:ebiten,代码行数:8,代码来源:context.go
示例13: main
func main() {
err := glfw.Init()
if err != nil {
panic(err)
}
defer glfw.Terminate()
fp, err := os.Open("example.tmx")
if err != nil {
panic(err)
}
m, err := tmx.NewMap(fp)
if err != nil {
panic(err)
}
var monitor *glfw.Monitor
window, err := glfw.CreateWindow(screenWidth, screenHeight, "Map Renderer", monitor, nil)
if err != nil {
panic(err)
}
window.MakeContextCurrent()
if err := gl.Init(); err != nil {
panic(err)
}
width, height := window.GetFramebufferSize()
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.ClearColor(1.0, 1.0, 1.0, 1.0)
gl.Viewport(0, 0, int32(width), int32(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(width), float64(height), 0, -1, 1)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
canvas := newOpenGLCanvas(width, height, float32(width)/float32(screenWidth), float32(height)/float32(screenHeight))
renderer := tmx.NewRenderer(*m, canvas)
fps := 0
startTime := time.Now().UnixNano()
timer := tmx.CreateTimer()
timer.Start()
for !window.ShouldClose() {
elapsed := float64(timer.GetElapsedTime()) / (1000 * 1000)
renderer.Render(int64(math.Ceil(elapsed)))
fps++
if time.Now().UnixNano()-startTime > 1000*1000*1000 {
log.Println(fps)
startTime = time.Now().UnixNano()
fps = 0
}
window.SwapBuffers()
glfw.PollEvents()
timer.UpdateTime()
}
}
开发者ID:manyminds,项目名称:tmx,代码行数:58,代码来源:opengl.go
示例14: initGL
func (v *Video) initGL() {
if err := gl.Init(); err != nil {
panic(err)
}
gl.Enable(gl.CULL_FACE)
gl.Enable(gl.DEPTH_TEST)
gl.ClearColor(0.0, 0.0, 0.0, 1.0)
v.prog = createProgram(vertShaderSrcDef, fragShaderSrcDef)
posAttrib := uint32(gl.GetAttribLocation(v.prog, gl.Str("vPosition"+"\x00")))
texCoordAttr := uint32(gl.GetAttribLocation(v.prog, gl.Str("vTexCoord"+"\x00")))
v.textureUni = gl.GetAttribLocation(v.prog, gl.Str("texture"+"\x00"))
var texture uint32
gl.GenTextures(1, &texture)
gl.ActiveTexture(gl.TEXTURE0)
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.UseProgram(v.prog)
gl.EnableVertexAttribArray(posAttrib)
gl.EnableVertexAttribArray(texCoordAttr)
//posAttrib.EnableArray()
//texCoordAttr.EnableArray()
var vbo uint32
gl.GenBuffers(1, &vbo)
gl.BindBuffer(gl.ARRAY_BUFFER, vbo)
verts := []float32{-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0}
gl.BufferData(gl.ARRAY_BUFFER, len(verts)*int(unsafe.Sizeof(verts[0])), gl.Ptr(verts), gl.STATIC_DRAW)
var textCoorBuf uint32
gl.GenBuffers(1, &textCoorBuf)
gl.BindBuffer(gl.ARRAY_BUFFER, textCoorBuf)
texVerts := []float32{0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0}
gl.BufferData(gl.ARRAY_BUFFER, len(texVerts)*int(unsafe.Sizeof(texVerts[0])), gl.Ptr(texVerts), gl.STATIC_DRAW)
gl.VertexAttribPointer(posAttrib, 2, gl.FLOAT, false, 0, gl.PtrOffset(0))
gl.VertexAttribPointer(texCoordAttr, 2, gl.FLOAT, false, 0, gl.PtrOffset(0))
//posAttrib.AttribPointer(2, gl.FLOAT, false, 0, uintptr(0))
//texCoordAttr.AttribPointer(2, gl.FLOAT, false, 0, uintptr(0))
}
开发者ID:badfortrains,项目名称:Fergulator,代码行数:45,代码来源:video.go
示例15: draw
func (atlas *FontAtlas) draw(rendered *image.RGBA, b Bounds) {
var texture uint32
gl.Enable(gl.TEXTURE_2D)
gl.GenTextures(1, &texture)
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.TexImage2D(
gl.TEXTURE_2D,
0,
gl.RGBA,
int32(rendered.Bounds().Dx()),
int32(rendered.Bounds().Dy()),
0,
gl.RGBA,
gl.UNSIGNED_BYTE,
gl.Ptr(rendered.Pix))
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
gl.Begin(gl.QUADS)
{
gl.TexCoord2f(0, 0)
gl.Vertex2f(b.Min.X, b.Min.Y)
gl.TexCoord2f(1, 0)
gl.Vertex2f(b.Max.X, b.Min.Y)
gl.TexCoord2f(1, 1)
gl.Vertex2f(b.Max.X, b.Max.Y)
gl.TexCoord2f(0, 1)
gl.Vertex2f(b.Min.X, b.Max.Y)
}
gl.End()
gl.Disable(gl.BLEND)
gl.DeleteTextures(1, &texture)
gl.Disable(gl.TEXTURE_2D)
}
开发者ID:egonelbre,项目名称:spector,代码行数:43,代码来源:fontatlas_slow.go
示例16: init_
// lets get things rolling
func init_() {
// all for lighting effects
//pos := []float32{0.0, 0.0, 100.0, 0.0}
var pos float32 = 1.0
gl.Lightfv(gl.LIGHT0, gl.POSITION, &pos)
gl.Enable(gl.LIGHTING)
gl.Enable(gl.LIGHT0)
// below is necessary
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.NORMALIZE)
if DEBUG {
tests()
init_walls()
return
} else {
make_maze()
init_walls()
}
}
开发者ID:pietdaniel,项目名称:gl_maze,代码行数:21,代码来源:main.go
示例17: FlushDraw
func (stash *Stash) FlushDraw() {
i := 0
texture := stash.ttTextures[i]
tt := true
for {
if texture.nverts > 0 {
gl.Enable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, texture.id)
for k := 0; k < texture.nverts; k++ {
gl.Begin(gl.QUADS)
gl.Color4fv(&texture.color[0])
gl.TexCoord2f(texture.verts[k*4+2], texture.verts[k*4+3])
gl.Vertex2f(texture.verts[k*4+0], texture.verts[k*4+1])
k++
gl.Color4fv(&texture.color[0])
gl.TexCoord2f(texture.verts[k*4+2], texture.verts[k*4+3])
gl.Vertex2f(texture.verts[k*4+0], texture.verts[k*4+1])
k++
gl.Color4fv(&texture.color[0])
gl.TexCoord2f(texture.verts[k*4+2], texture.verts[k*4+3])
gl.Vertex2f(texture.verts[k*4+0], texture.verts[k*4+1])
k++
gl.Color4fv(&texture.color[0])
gl.TexCoord2f(texture.verts[k*4+2], texture.verts[k*4+3])
gl.Vertex2f(texture.verts[k*4+0], texture.verts[k*4+1])
gl.End()
}
gl.Disable(gl.TEXTURE_2D)
texture.nverts = 0
}
if tt {
if i < len(stash.ttTextures)-1 {
i++
texture = stash.ttTextures[i]
} else {
i = 0
if len(stash.bmTextures) > 0 {
texture = stash.bmTextures[i]
tt = false
} else {
break
}
}
} else {
if i < len(stash.bmTextures)-1 {
i++
texture = stash.bmTextures[i]
} else {
break
}
}
}
}
开发者ID:shibukawa,项目名称:fontstash.go,代码行数:53,代码来源:fontstash.go
示例18: setupScene
func setupScene() {
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.LIGHTING)
gl.ClearColor(0.5, 0.5, 0.5, 0.0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
ambient := []float32{0.5, 0.5, 0.5, 1}
diffuse := []float32{1, 1, 1, 1}
lightPosition := []float32{-5, 5, 10, 0}
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, &ambient[0])
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, &diffuse[0])
gl.Lightfv(gl.LIGHT0, gl.POSITION, &lightPosition[0])
gl.Enable(gl.LIGHT0)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Frustum(-1, 1, -1, 1, 1.0, 10.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
开发者ID:donomii,项目名称:throfflib,代码行数:22,代码来源:throffgraphics.go
示例19: Reset
func (state *State) Reset(window *glfw.Window) {
gl.ClearColor(1, 1, 1, 1)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH)
gl.Enable(gl.FRAMEBUFFER_SRGB)
width, height := window.GetSize()
gl.Viewport(0, 0, int32(width), int32(height))
gl.Ortho(0, float64(width), float64(height), 0, 30, -30)
}
开发者ID:egonelbre,项目名称:spector,代码行数:13,代码来源:ui.go
示例20: List
func List(width, height int, list *draw.List) {
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.SCISSOR_TEST)
defer gl.Disable(gl.SCISSOR_TEST)
gl.EnableClientState(gl.VERTEX_ARRAY)
defer gl.DisableClientState(gl.VERTEX_ARRAY)
gl.EnableClientState(gl.COLOR_ARRAY)
defer gl.DisableClientState(gl.COLOR_ARRAY)
gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
defer gl.DisableClientState(gl.TEXTURE_COORD_ARRAY)
gl.VertexPointer(2, gl.FLOAT, vertexStride, unsafe.Pointer(&(list.Vertices[0].P)))
gl.TexCoordPointer(2, gl.FLOAT, vertexStride, unsafe.Pointer(&(list.Vertices[0].UV)))
gl.ColorPointer(4, gl.UNSIGNED_BYTE, vertexStride, unsafe.Pointer(&(list.Vertices[0].Color)))
offset := 0
for _, cmd := range list.Commands {
if cmd.Count == 0 {
continue
}
if cmd.Texture == 0 {
gl.Disable(gl.TEXTURE_2D)
} else {
gl.Enable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, uint32(cmd.Texture))
}
x, y, w, h := cmd.Clip.AsInt32()
gl.Scissor(x, int32(height)-y-h, w, h)
gl.DrawElements(gl.TRIANGLES, int32(cmd.Count), indexType, gl.Ptr(list.Indicies[offset:]))
offset += int(cmd.Count)
}
}
开发者ID:egonelbre,项目名称:spector,代码行数:38,代码来源:render.go
注:本文中的github.com/go-gl/gl/v2/1/gl.Enable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论