本文整理汇总了Golang中gl.Enable函数的典型用法代码示例。如果您正苦于以下问题:Golang Enable函数的具体用法?Golang Enable怎么用?Golang Enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Enable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: drawFrame
func drawFrame() {
gl.LoadIdentity()
gl.LineWidth(5.0)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.Color4f(gl.GLfloat(FrameColor[0]), gl.GLfloat(FrameColor[1]), gl.GLfloat(FrameColor[2]), 0.1)
m := PlayArea
t := 1.0 * m
b := -1.0 * m
r := 1.0 * m
l := -1.0 * m
gl.Begin(gl.LINE_STRIP)
zo := -5.0
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
gl.End()
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:29,代码来源:chain-reaction.go
示例2: lineTo
func (pen *Pen) lineTo(p Point) {
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.Color4f(0.0, 0.0, 0.0, 0.1)
gl.Begin(gl.LINES)
for _, s := range pen.points {
if s.x == 0 && s.y == 0 {
continue
}
if p.distanceTo(s) < 20.0 {
gl.Vertex2i(int(p.x), int(p.y))
gl.Vertex2i(int(s.x), int(s.y))
}
}
gl.End()
pen.n = (pen.n + 1) % len(pen.points)
pen.points[pen.n] = p
pen.moveTo(p)
}
开发者ID:losinggeneration,项目名称:opengl,代码行数:34,代码来源:draw.go
示例3: initGL
// general OpenGL initialization
func initGL() {
LoadGLTexture("data/star.bmp")
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
gl.ClearDepth(1.0)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:12,代码来源:lesson09.go
示例4: init_
func init_() {
//pos := []float64{5.0, 5.0, 10.0, 0.0}
colors := map[string][]float32{
"0": {0.7, 0.7, 0.7, 1.0},
"1": {1.0, 0.0, 0.0, 1.0},
"2": {1.0, 0.6, 0.0, 1.0},
"3": {1.0, 1.0, 0.0, 1.0},
"4": {0.0, 1.0, 0.0, 1.0},
"5": {0.0, 0.0, 1.0, 1.0},
"6": {0.0, 0.6, 1.0, 1.0},
"7": {1.0, 0.0, 1.0, 1.0},
"8": {1.0, 1.0, 1.0, 1.0},
"9": {0.3, 0.3, 0.3, 1.0},
}
fetchChunks(2, 2)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.2, 0.2, 0.6, 0.0)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Enable(gl.COLOR_MATERIAL)
gl.Enable(gl.CULL_FACE)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.Hint(gl.LINE_SMOOTH_HINT, gl.NICEST)
gl.Lightfv(gl.LIGHT0, gl.AMBIENT, lightAmbient)
gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, lightDiffuse)
gl.Lightfv(gl.LIGHT0, gl.POSITION, lightPosition)
gl.Enable(gl.LIGHT0)
gl.Enable(gl.LIGHTING)
for name, color := range colors {
/* make a cube */
cubes[name] = gl.GenLists(1)
gl.NewList(cubes[name], gl.COMPILE)
cube(color)
gl.EndList()
}
if *printInfo {
print("GL_RENDERER = ", gl.GetString(gl.RENDERER), "\n")
print("GL_VERSION = ", gl.GetString(gl.VERSION), "\n")
print("GL_VENDOR = ", gl.GetString(gl.VENDOR), "\n")
print("GL_EXTENSIONS = ", gl.GetString(gl.EXTENSIONS), "\n")
}
}
开发者ID:yohcop,项目名称:cubopolis.go,代码行数:51,代码来源:main.go
示例5: setupTextRendering
func (f *Font) setupTextRendering(color [3]byte, txt string) (gl.GLuint, *sdl.Surface, *sdl.Surface, *sdl.Surface, int, int) {
//
var texture gl.GLuint
/* Use SDL_TTF to render our text */
var col sdl.Color
col.R = color[0]
col.G = color[1]
col.B = color[2]
// get surface with text
initial := ttf.RenderText_Blended(f.font, txt, col)
/* Convert the rendered text to a known format */
w := next_p2(int(initial.W))
h := next_p2(int(initial.H))
intermediarya := sdl.CreateRGBSurface(0, w, h, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000)
var rr *sdl.Rect = nil
intermediarya.Blit(rr, initial, rr)
intermediary := intermediarya.DisplayFormatAlpha()
/* Tell GL about our new texture */
gl.GenTextures(1, &texture)
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.TexImage2D(gl.TEXTURE_2D, 0, 4, gl.GLsizei(w), gl.GLsizei(h), 0, gl.BGRA,
gl.UNSIGNED_BYTE, unsafe.Pointer(intermediary.Pixels))
gl.TexEnvi(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
/* GL_NEAREST looks horrible, if scaled... */
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
/* prepare to render our texture */
gl.Enable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, texture)
gl.Color4f(1.0, 1.0, 1.0, 1.0)
gl.Enable(gl.BLEND)
// gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_COLOR) // TODO : MAke real alpha work!
return texture, initial, intermediarya, intermediary, w, h
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:50,代码来源:draw_font.go
示例6: handleKeyPress
// handle key press events
func handleKeyPress(keysym sdl.Keysym) {
switch keysym.Sym {
case sdl.K_f: // f key pages through filters
filter = (filter + 1) % 3
p("new filter:", filter)
case sdl.K_l: // l key toggles light
light = !light
if light {
p("light on")
gl.Enable(gl.LIGHTING)
} else {
p("light off")
gl.Disable(gl.LIGHTING)
}
case sdl.K_PAGEUP: // page up zooms into the scene
z -= 0.02
case sdl.K_PAGEDOWN: // zoom out of the scene
z += 0.02
case sdl.K_UP: // up arrow affects x rotation
xspeed -= 0.01
case sdl.K_DOWN: // down arrow affects x rotation
xspeed += 0.01
case sdl.K_RIGHT: // affect y rotation
yspeed += 0.01
case sdl.K_LEFT: // affect y rotation
yspeed -= 0.01
case sdl.K_ESCAPE:
Quit(0)
case sdl.K_F1:
sdl.WM_ToggleFullScreen(surface)
}
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:33,代码来源:lesson07.go
示例7: DrawText2D
func (f *Font) DrawText2D(x int, y int, color [3]byte, scale float, txt string) (endw int, endh int) {
gl.LoadIdentity()
// gl.Translatef(0.0, 0.0, -2.0);
glEnable2D()
gl.Disable(gl.DEPTH_TEST)
texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt)
locX := gl.GLfloat(x)
locY := gl.GLfloat(y)
wi := gl.GLfloat(w) * gl.GLfloat(scale)
he := gl.GLfloat(h) * gl.GLfloat(scale)
/* Draw a quad at location */
gl.Begin(gl.QUADS)
/* Recall that the origin is in the lower-left corner
That is why the TexCoords specify different corners
than the Vertex coors seem to. */
gl.TexCoord2f(0.0, 1.0)
gl.Vertex2f(locX, locY)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex2f(locX+wi, locY)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex2f(locX+wi, locY+he)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex2f(locX, locY+he)
gl.End()
endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary)
gl.Enable(gl.DEPTH_TEST)
glDisable2D()
return
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:35,代码来源:draw_font.go
示例8: main
func main() {
// We need to lock the goroutine to one thread due time.Ticker
runtime.LockOSThread()
var err os.Error
err = glfw.Init()
if err != nil {
fmt.Printf("GLFW: %s\n", err)
return
}
defer glfw.Terminate()
// You could probably change the required versions down
glfw.OpenWindowHint(glfw.OpenGLVersionMajor, 3)
glfw.OpenWindowHint(glfw.OpenGLVersionMinor, 3)
glfw.OpenWindowHint(glfw.OpenGLProfile, 1)
// Open Window with 8 bit Alpha
err = glfw.OpenWindow(ScreenWidth, ScreenHeight, 0, 0, 0, 8, 0, 0, glfw.Windowed)
if err != nil {
fmt.Printf("GLFW: %s\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetWindowTitle(WindowTitle)
major, minor, rev := glfw.GLVersion()
if major < 3 {
fmt.Printf("Error your graphic card does not support OpenGL 3.3\n Your GL-Version is: %d, %d, %d\n", major, minor, rev)
fmt.Println("You can try to lower the settings in glfw.OpenWindowHint(glfw.OpenGLVersionMajor/Minor.")
}
initStatus := gl.Init() // Init glew
if initStatus != 0 {
fmt.Printf("Error-code: %d Init-Status: %d\n", gl.GetError(), initStatus)
}
// Enable transparency in OpenGL
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
initResources()
// We are limiting the calls to display() (frames per second) to 60. This prevents the 100% cpu usage.
ticker := time.NewTicker(int64(second) / 60) // max 60 fps
for {
<-ticker.C
move := float32(math.Sin(glfw.Time()))
angle := float32(glfw.Time())
matrix = math3d.MakeTranslationMatrix(move, 0.0, 0.0)
matrix = matrix.Multiply(math3d.MakeZRotationMatrix(angle)).Transposed()
display()
}
// Free resources
free()
runtime.UnlockOSThread()
}
开发者ID:pdelbarba,项目名称:gl3-examples,代码行数:59,代码来源:main.go
示例9: initGL
func initGL() {
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0, 0, 0, 0)
gl.ClearDepth(1)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
开发者ID:nightkidfifa,项目名称:poly2tri.golang,代码行数:8,代码来源:main.go
示例10: initGL
// general OpenGL initialization
func initGL() {
gl.Enable(gl.TEXTURE_2D)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
// Setup the light
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:]) // ambient lighting
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:]) // make it diffuse
gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:]) // and place it
gl.Enable(gl.LIGHT1) // and finally turn it on.
gl.Color4f(1.0, 1.0, 1.0, 0.5) // Full Brightness, 50% Alpha ( NEW )
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE) // Blending Function For Translucency Based On Source Alpha Value ( NEW )
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:19,代码来源:lesson08.go
示例11: initGL
// general OpenGL initialization
func initGL() {
LoadGLTextures("data/mud.bmp")
gl.Enable(gl.TEXTURE_2D)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.0)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:])
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:])
gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:])
gl.Enable(gl.LIGHT1)
gl.Color4f(1.0, 1.0, 1.0, 0.5)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:20,代码来源:lesson10.go
示例12: initGL
// general OpenGL initialization
func initGL() {
gl.Enable(gl.TEXTURE_2D)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
gl.ClearDepth(1.0)
gl.Enable(gl.DEPTH_TEST)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
// Setup the light
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient1[:]) // ambient lighting
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse1[:]) // make it diffuse
gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition1[:]) // and place it
gl.Enable(gl.LIGHT1) // and finally turn it on.
gl.Lightfv(gl.LIGHT2, gl.AMBIENT, lightAmbient2[:]) // ambient lighting
gl.Lightfv(gl.LIGHT2, gl.DIFFUSE, lightDiffuse2[:]) // make it diffuse
gl.Lightfv(gl.LIGHT2, gl.POSITION, lightPosition2[:]) // and place it
gl.Enable(gl.LIGHT2) // and finally turn it on.
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:21,代码来源:lesson07.go
示例13: main
func main() {
var err os.Error
if err = glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return
}
defer glfw.Terminate()
// Open window with FSAA samples (if possible).
glfw.OpenWindowHint(glfw.FsaaSamples, 4)
if err = glfw.OpenWindow(400, 400, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetWindowTitle("Aliasing Detector")
glfw.SetSwapInterval(1)
if samples := glfw.WindowParam(glfw.FsaaSamples); samples != 0 {
fmt.Fprintf(os.Stdout, "Context reports FSAA is supported with %d samples\n", samples)
} else {
fmt.Fprintf(os.Stdout, "Context reports FSAA is unsupported\n")
}
gl.MatrixMode(gl.PROJECTION)
glu.Perspective(0, 1, 0, 1)
for glfw.WindowParam(glfw.Opened) == 1 {
time := float32(glfw.Time())
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0.5, 0, 0)
gl.Rotatef(time, 0, 0, 1)
gl.Enable(GL_MULTISAMPLE_ARB)
gl.Color3f(1, 1, 1)
gl.Rectf(-0.25, -0.25, 0.25, 0.25)
gl.LoadIdentity()
gl.Translatef(-0.5, 0, 0)
gl.Rotatef(time, 0, 0, 1)
gl.Disable(GL_MULTISAMPLE_ARB)
gl.Color3f(1, 1, 1)
gl.Rectf(-0.25, -0.25, 0.25, 0.25)
glfw.SwapBuffers()
}
}
开发者ID:skelterjohn,项目名称:glfw,代码行数:54,代码来源:main.go
示例14: init_
func init_() {
pos := []float32{5.0, 5.0, 10.0, 0.0}
red := []float32{0.8, 0.1, 0.0, 1.0}
green := []float32{0.0, 0.8, 0.2, 1.0}
blue := []float32{0.2, 0.2, 1.0, 1.0}
gl.Lightfv(gl.LIGHT0, gl.POSITION, pos)
gl.Enable(gl.CULL_FACE)
gl.Enable(gl.LIGHTING)
gl.Enable(gl.LIGHT0)
gl.Enable(gl.DEPTH_TEST)
/* make the gears */
gear1 = gl.GenLists(1)
gl.NewList(gear1, gl.COMPILE)
gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, red)
gear(1.0, 4.0, 1.0, 20, 0.7)
gl.EndList()
gear2 = gl.GenLists(1)
gl.NewList(gear2, gl.COMPILE)
gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, green)
gear(0.5, 2.0, 2.0, 10, 0.7)
gl.EndList()
gear3 = gl.GenLists(1)
gl.NewList(gear3, gl.COMPILE)
gl.Materialfv(gl.FRONT, gl.AMBIENT_AND_DIFFUSE, blue)
gear(1.3, 2.0, 0.5, 10, 0.7)
gl.EndList()
gl.Enable(gl.NORMALIZE)
if *printInfo {
print("GL_RENDERER = ", gl.GetString(gl.RENDERER), "\n")
print("GL_VERSION = ", gl.GetString(gl.VERSION), "\n")
print("GL_VENDOR = ", gl.GetString(gl.VENDOR), "\n")
print("GL_EXTENSIONS = ", gl.GetString(gl.EXTENSIONS), "\n")
}
}
开发者ID:DeedleFake,项目名称:Go-OpenGL,代码行数:41,代码来源:gogears.go
示例15: initGL
// general OpenGL initialization
func initGL() {
// Enable Texture Mapping
gl.Enable(gl.TEXTURE_2D)
// enable smooth shading
gl.ShadeModel(gl.SMOOTH)
// Set the background to black
gl.ClearColor(0.0, 0.0, 0.0, 0.5)
// Depth buffer setup
gl.ClearDepth(1.0)
// Enable depth testing
gl.Enable(gl.DEPTH_TEST)
// The type of test
gl.DepthFunc(gl.LEQUAL)
// Nicest perspective correction
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:23,代码来源:lesson06.go
示例16: special
func special(key, x, y int) {
switch key {
case glut.KEY_F1:
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.BLEND)
gl.Enable(gl.LINE_SMOOTH)
gl.Enable(gl.POINT_SMOOTH)
case glut.KEY_F2:
gl.Disable(gl.BLEND)
gl.Disable(gl.LINE_SMOOTH)
gl.Disable(gl.POINT_SMOOTH)
case glut.KEY_UP:
thrust = true
thrustTime = glut.Get(glut.ELAPSED_TIME)
case glut.KEY_LEFT:
left = true
leftTime = glut.Get(glut.ELAPSED_TIME)
case glut.KEY_RIGHT:
right = true
rightTime = glut.Get(glut.ELAPSED_TIME)
}
}
开发者ID:brownman,项目名称:Go-GLUT,代码行数:22,代码来源:asteroids.go
示例17: SetupVideo
func SetupVideo() {
if sdl.Init(sdl.INIT_VIDEO) < 0 {
panic("Couldn't initialize sdl")
}
w := WinW
h := WinH
var screen = sdl.SetVideoMode(w, h, 32, SDL_FLAGS)
// var screen = sdl.SetVideoMode(w, h, 32, sdl.OPENGLBLIT | sdl.DOUBLEBUF | sdl.HWSURFACE)
// var screen = sdl.SetVideoMode(w, h, 32, sdl.OPENGL)
if screen == nil {
panic("sdl error")
}
if ttf.Init() != 0 {
panic("ttf init error")
}
if gl.Init() != 0 {
panic("Couldn't init gl")
}
ResizeWindow(screen.W, screen.H)
gl.ClearColor(0, 0, 0, 0)
// gl.ClearColor(1, 1, 1, 0)
gl.ClearDepth(1.0)
gl.DepthFunc(gl.LEQUAL)
gl.Enable(gl.DEPTH_TEST)
gl.ShadeModel(gl.SMOOTH)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
/*
if gl.Init() != 0 {
panic("glew error")
}
*/
// gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT )
// gl.Clear(gl.COLOR_BUFFER_BIT)
// initGL
// gl.Ortho(0, gl.GLdouble(screen.W), gl.GLdouble(screen.H), 0, -1.0, 1.0)
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:50,代码来源:video.go
示例18: reshape
func reshape(w, h int) {
/* Because Gil specified "screen coordinates" (presumably with an
upper-left origin), this short bit of code sets up the coordinate
system to correspond to actual window coodrinates. This code
wouldn't be required if you chose a (more typical in 3D) abstract
coordinate system. */
gl.ClearColor(1, 1, 1, 1)
//fmt.Println(gl.GetString(gl.EXTENSIONS))
gl.Viewport(0, 0, w, h) /* Establish viewing area to cover entire window. */
gl.MatrixMode(gl.PROJECTION) /* Start modifying the projection matrix. */
gl.LoadIdentity() /* Reset project matrix. */
gl.Ortho(0, float64(w), 0, float64(h), -1, 1) /* Map abstract coords directly to window coords. */
gl.Scalef(1, -1, 1) /* Invert Y axis so increasing Y goes down. */
gl.Translatef(0, float32(-h), 0) /* Shift origin up to upper-left corner. */
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Disable(gl.DEPTH_TEST)
width, height = w, h
}
开发者ID:xushiwei,项目名称:draw2d,代码行数:19,代码来源:draw2dgl.go
示例19: drawWin
func drawWin(d float) {
gl.LoadIdentity()
// gl.LineWidth(5.0)
// gl.Enable(gl.POINT_SMOOTH)
// gl.Enable(gl.LINE_SMOOTH)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
if d > 1.0 {
d = 1.0
}
c := WinColor
gl.Color4f(gl.GLfloat(c[0]), gl.GLfloat(c[1]), gl.GLfloat(c[2]), gl.GLfloat(d))
m := PlayArea * 4
t := 1.0 * m
b := -1.0 * m
r := 1.0 * m
l := -1.0 * m
gl.Begin(gl.POLYGON)
zo := -10.0
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
gl.End()
gl.Disable(gl.BLEND)
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:38,代码来源:chain-reaction.go
示例20: DrawText3D
func (f *Font) DrawText3D(pos Vector3, color [3]byte, scale float, txt string) (endw int, endh int) {
gl.LoadIdentity()
// gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(-4.99));
gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(-4.99))
gl.Scalef(gl.GLfloat(1.0/64.0*scale), gl.GLfloat(1.0/64.0*scale), gl.GLfloat(1.0))
gl.Disable(gl.DEPTH_TEST)
texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt)
wi := gl.GLfloat(w)
he := gl.GLfloat(h)
locX := gl.GLfloat(0) - wi*0.5
locY := gl.GLfloat(0) - he*0.5
/* Draw a quad at location */
gl.Begin(gl.QUADS)
/* Recall that the origin is in the lower-left corner
That is why the TexCoords specify different corners
than the Vertex coors seem to. */
gl.Color4f(1.0, 1.0, 0.0, 1.0)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(locX, locY, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(locX+wi, locY, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(locX+wi, locY+he, 0.0)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(locX, locY+he, 0.0)
gl.End()
endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary)
gl.Enable(gl.DEPTH_TEST)
return
}
开发者ID:jcd,项目名称:go-gamelib,代码行数:38,代码来源:draw_font.go
注:本文中的gl.Enable函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论