本文整理汇总了Golang中github.com/banthar/gl.Disable函数的典型用法代码示例。如果您正苦于以下问题:Golang Disable函数的具体用法?Golang Disable怎么用?Golang Disable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Disable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Draw
func (s *Sprite) Draw(x, y, angle, scale float32, blend bool) {
gl.Enable(gl.TEXTURE_2D)
gl.Disable(gl.COLOR_MATERIAL)
if blend {
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.BLEND)
} else {
gl.Disable(gl.BLEND)
gl.BlendFunc(gl.ONE, gl.ZERO)
}
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Translatef(x, y, 0)
gl.Rotatef(angle*360/(2*math.Pi), 0, 0, 1)
gl.Scalef(scale, scale, 1)
s.tex.Bind(gl.TEXTURE_2D)
gl.Begin(gl.QUADS)
gl.Color3f(1, 1, 1)
gl.TexCoord2d(0, 0)
gl.Vertex3f(-0.5*s.width, -0.5*s.height, 0)
gl.TexCoord2d(1, 0)
gl.Vertex3f(0.5*s.width, -0.5*s.height, 0)
gl.TexCoord2d(1, 1)
gl.Vertex3f(0.5*s.width, 0.5*s.height, 0)
gl.TexCoord2d(0, 1)
gl.Vertex3f(-0.5*s.width, 0.5*s.height, 0)
gl.End()
gl.Disable(gl.TEXTURE_2D)
gl.Disable(gl.BLEND)
}
开发者ID:mfpi,项目名称:lecture-hall-games,代码行数:31,代码来源:utils.go
示例2: Draw
func (self *Picker) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
gl.Begin(gl.TRIANGLE_FAN)
gl.Color4ub(0, 0, 0, 128)
gl.Vertex2f(self.x, self.y)
for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
gl.Vertex2f(self.x-float32(math.Sin(angle))*self.radius, self.y+float32(math.Cos(angle))*self.radius)
}
gl.End()
self.DrawItemHighlight(t, ThePlayer.currentAction)
self.DrawPlayerItems(t, true)
gl.PopMatrix()
}
开发者ID:codygman,项目名称:amberfell,代码行数:26,代码来源:picker.go
示例3: Draw
func (self *Pause) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
gl.Color4ub(0, 0, 0, 240)
gl.Begin(gl.QUADS)
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
gl.End()
str := "paused"
h, w := pauseFont.Measure(str)
// x := (viewport.rplane - viewport.lplane - w) / 2
// y := (viewport.tplane - viewport.bplane - h) / 2
gl.Translated(-w/2, -h/2, 0)
pauseFont.Print(str)
gl.PopMatrix()
}
开发者ID:codygman,项目名称:amberfell,代码行数:30,代码来源:pause.go
示例4: Draw
func (self *Console) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
h := float32(consoleFont.height) * PIXEL_SCALE
margin := float32(3.0) * PIXEL_SCALE
consoleHeight := 3 * h
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Color4ub(0, 0, 0, 208)
gl.Begin(gl.QUADS)
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Left Of The Texture and Quad
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Right Of The Texture and Quad
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane)) // Top Right Of The Texture and Quad
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane)) // Top Left Of The Texture and Quad
gl.End()
gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-h, 0)
consoleFont.Print(fmt.Sprintf("FPS: %5.2f V: %d (%d) CH: %d M: %d", self.fps, self.vertices, self.culledVertices, len(TheWorld.chunks), len(TheWorld.mobs)))
gl.LoadIdentity()
gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-2*h, 0)
consoleFont.Print(fmt.Sprintf("X: %5.2f Y: %4.2f Z: %5.2f H: %5.2f (%s) D: %0.1f (%d)", ThePlayer.position[XAXIS], ThePlayer.position[YAXIS], ThePlayer.position[ZAXIS], ThePlayer.heading, HeadingToCompass(ThePlayer.heading), ThePlayer.distanceTravelled, ThePlayer.distanceFromStart))
gl.LoadIdentity()
gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-3*h, 0)
numgc := uint32(0)
avggc := float64(0)
var last3 [3]float64
if self.mem.NumGC > 3 {
numgc = self.mem.NumGC
avggc = float64(self.mem.PauseTotalNs) / float64(self.mem.NumGC) / 1e6
index := int(numgc) - 1
if index > 255 {
index = 255
}
last3[0] = float64(self.mem.PauseNs[index]) / 1e6
last3[1] = float64(self.mem.PauseNs[index-1]) / 1e6
last3[2] = float64(self.mem.PauseNs[index-2]) / 1e6
}
consoleFont.Print(fmt.Sprintf("Mem: %.1f/%.1f GC: %.1fms [%d: %.1f, %.1f, %.1f] ChGen: %.1fms | Sc: %.1f TOD: %.1f", float64(self.mem.Alloc)/(1024*1024), float64(self.mem.Sys)/(1024*1024), avggc, numgc, last3[0], last3[1], last3[2], float64(self.chunkGenerationTime)/1e6, viewport.scale, timeOfDay))
gl.PopMatrix()
}
开发者ID:caustin,项目名称:amberfell,代码行数:56,代码来源:console.go
示例5: RenderScaled
func (t *Skybox) RenderScaled(center, scale *Vec3) {
v := []*Vec3{
V3(-1, -1, 1),
V3(1, -1, 1),
V3(1, 1, 1),
V3(-1, 1, 1),
V3(-1, -1, -1),
V3(1, -1, -1),
V3(1, 1, -1),
V3(-1, 1, -1)}
for i := 0; i < 8; i++ {
v[i].Muli(scale).Addi(center)
}
if globals.UseShader {
program.Unuse()
}
//*//save attributes and change them
gl.PushAttrib(gl.ENABLE_BIT | gl.TEXTURE_BIT)
defer gl.PopAttrib() //reset to old attributes
gl.Enable(gl.TEXTURE_2D)
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.BLEND) //*/
oneSide := func(tex *texture.Texture, a, b, c, d int, n *Vec3) {
tex.BindForSkybox(color.White)
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.Begin(gl.TRIANGLES)
gl.Normal3dv(n.Slc())
gl.TexCoord2i(0, 0)
gl.Vertex3dv(v[a].Slc())
gl.TexCoord2i(1, 0)
gl.Vertex3dv(v[b].Slc())
gl.TexCoord2i(1, 1)
gl.Vertex3dv(v[c].Slc())
gl.TexCoord2i(0, 0)
gl.Vertex3dv(v[a].Slc())
gl.TexCoord2i(1, 1)
gl.Vertex3dv(v[c].Slc())
gl.TexCoord2i(0, 1)
gl.Vertex3dv(v[d].Slc())
gl.End()
}
oneSide(t.up, 2, 3, 7, 6, V3(0, -1, 0))
oneSide(t.dn, 5, 4, 0, 1, V3(0, 1, 0))
oneSide(t.lt, 5, 1, 2, 6, V3(1, 0, 0))
oneSide(t.rt, 0, 4, 7, 3, V3(-1, 0, 0))
oneSide(t.ft, 1, 0, 3, 2, V3(0, 0, -1))
oneSide(t.bk, 4, 5, 6, 7, V3(0, 0, 1))
}
开发者ID:swantescholz,项目名称:coding,代码行数:52,代码来源:skybox.go
示例6: draw
func (this *App) draw() {
gl.Disable(gl.CULL_FACE)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.DEPTH_TEST)
White.Gl()
var w, h = Double(this.win.Width()), Double(this.win.Height())
drawTexRect(this.texmandel, V2(0, 0), V2(w, h))
var col = color24.NewColor24(0, 0, 0)
this.frac.Gradient().Interpolate(col, this.cursor.Pos.X)
this.cursor.Draw(w, h, col)
this.win.FinishFrame()
}
开发者ID:swantescholz,项目名称:coding,代码行数:14,代码来源:app.go
示例7: main
func main() {
glfw.Init()
defer glfw.Terminate()
glfw.OpenWindow(640, 480, 8, 8, 8, 8, 0, 0, glfw.Windowed)
defer glfw.CloseWindow()
glfw.SetWindowTitle("Tile test")
glfw.Enable(glfw.StickyKeys)
glfw.SetSwapInterval(1)
glfw.SetKeyCallback(inputCallback)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, GridWidth, GridHeight, 0, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.TEXTURE_2D)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.ClearColor(0.0, 0.0, 0.0, 1.0)
initResources()
initWorld()
for Running {
if (time.Since(DT).Nanoseconds() / 1000000) > 15 { //don't loop faster than every 15ms
DT = time.Now()
gl.Clear(gl.COLOR_BUFFER_BIT)
player.update()
renderScene()
glfw.SwapBuffers()
}
}
}
开发者ID:remirisque,项目名称:miniworld,代码行数:35,代码来源:main.go
示例8: 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:navneet1v,项目名称:opengl-go-tutorials,代码行数:33,代码来源:lesson07.go
示例9: Reshape
func (v *Video) Reshape(width int, height int) {
x_offset := 0
y_offset := 0
r := ((float64)(height)) / ((float64)(width))
if r > 0.9375 { // Height taller than ratio
h := (int)(math.Floor((float64)(0.9375 * (float64)(width))))
y_offset = (height - h) / 2
height = h
} else if r < 0.9375 { // Width wider
var scrW, scrH float64
if ppu.OverscanEnabled {
scrW = 240.0
scrH = 224.0
} else {
scrW = 256.0
scrH = 240.0
}
w := (int)(math.Floor((float64)((scrH / scrW) * (float64)(height))))
x_offset = (width - w) / 2
width = w
}
gl.Viewport(x_offset, y_offset, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-1, 1, -1, 1, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
}
开发者ID:bombless,项目名称:Fergulator,代码行数:33,代码来源:video.go
示例10: onKey
func onKey(key, state int) {
switch key {
case glfw.KeyEsc:
running = false
case 76: // L
if state == 1 {
if light = !light; !light {
gl.Disable(gl.LIGHTING)
} else {
gl.Enable(gl.LIGHTING)
}
}
case 70: // F
if state == 1 {
if filter++; filter >= len(textures) {
filter = 0
}
}
case glfw.KeyPageup:
z -= 0.2
case glfw.KeyPagedown:
z += 0.2
case glfw.KeyUp:
speed[0] -= 0.1
case glfw.KeyDown:
speed[0] += 0.1
case glfw.KeyLeft:
speed[1] -= 0.1
case glfw.KeyRight:
speed[1] += 0.1
}
}
开发者ID:andrebq,项目名称:glfw,代码行数:32,代码来源:main.go
示例11: onKey
func onKey(key, state int) {
switch key {
case glfw.KeyEsc:
running = false
case 'L':
if state == 1 {
if light = !light; !light {
gl.Disable(gl.LIGHTING)
} else {
gl.Enable(gl.LIGHTING)
}
}
case 'F':
if state == 1 {
if filter++; filter >= len(textures) {
filter = 0
}
}
case 'B': // B
if state == 1 {
if blend = !blend; blend {
gl.Enable(gl.BLEND)
gl.Disable(gl.DEPTH_TEST)
} else {
gl.Disable(gl.BLEND)
gl.Enable(gl.DEPTH_TEST)
}
}
case glfw.KeyPageup:
z -= 0.2
case glfw.KeyPagedown:
z += 0.2
case glfw.KeyUp:
speed[0] -= 0.1
case glfw.KeyDown:
speed[0] += 0.1
case glfw.KeyLeft:
speed[1] -= 0.1
case glfw.KeyRight:
speed[1] += 0.1
}
}
开发者ID:sycoso,项目名称:glfw,代码行数:42,代码来源:main.go
示例12: uploadTexture
func uploadTexture(img *image.RGBA) gl.Texture {
gl.Enable(gl.TEXTURE_2D)
tex := gl.GenTexture()
tex.Bind(gl.TEXTURE_2D)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexImage2D(gl.TEXTURE_2D, 0, 4, img.Bounds().Max.X, img.Bounds().Max.Y,
0, gl.RGBA, gl.UNSIGNED_BYTE, img.Pix)
gl.Disable(gl.TEXTURE_2D)
return tex
}
开发者ID:mfpi,项目名称:lecture-hall-games,代码行数:11,代码来源:utils.go
示例13: main
func main() {
var err error
if err = glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %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, "[e] %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:sycoso,项目名称:glfw,代码行数:54,代码来源:main.go
示例14: initialize
func initialize(WIDTH, HEIGHT int) {
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(WIDTH), float64(HEIGHT), 0, 0, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.Disable(gl.DEPTH_TEST)
}
开发者ID:reiver,项目名称:lifepack,代码行数:12,代码来源:main.go
示例15: Draw
func (this *Cursor) Draw(w, h Double, col *color24.Color24) {
var p = this.Pos.Mul(V2(w, h))
var a = p.Add(V2(-10, -10))
var b = p.Add(V2(10, -10))
gl.Disable(gl.TEXTURE_2D)
col.Gl()
gl.Begin(gl.TRIANGLES)
p.Gl()
a.Gl()
b.Gl()
gl.End()
gl.Enable(gl.TEXTURE_2D)
}
开发者ID:swantescholz,项目名称:coding,代码行数:13,代码来源:app.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:tmc,项目名称:glut,代码行数:22,代码来源:asteroids.go
示例17: onResize
func onResize(w, h int) {
if h == 0 {
h = 1
}
gl.Viewport(0, 0, w, h)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-1, 1, -1, 1, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
}
开发者ID:samnardoni,项目名称:ca,代码行数:13,代码来源:ca.go
示例18: reshape
func reshape(width int, height int) {
x_offset := 0
y_offset := 0
r := ((float64)(height)) / ((float64)(width))
if r > 0.9375 { // Height taller than ratio
h := (int)(math.Floor((float64)(0.9375 * (float64)(width))))
y_offset = (height - h) / 2
height = h
} else if r < 0.9375 { // Width wider
w := (int)(math.Floor((float64)((256.0 / 240.0) * (float64)(height))))
x_offset = (width - w) / 2
width = w
}
gl.Viewport(x_offset, y_offset, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-1, 1, -1, 1, -1, 1)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
}
开发者ID:wmbest2,项目名称:Fergulator,代码行数:24,代码来源:video.go
示例19: Draw
func (self *Inventory) Draw(t int64) {
gl.MatrixMode(gl.MODELVIEW)
gl.PushMatrix()
gl.LoadIdentity()
gl.Disable(gl.DEPTH_TEST)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.LIGHT0)
gl.Disable(gl.LIGHT1)
gl.Color4ub(0, 0, 0, 240)
gl.Begin(gl.QUADS)
gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
gl.End()
picker.DrawItemHighlight(t, 3)
picker.DrawItemHighlight(t, 4)
picker.DrawItemHighlight(t, 5)
picker.DrawItemHighlight(t, 6)
picker.DrawItemHighlight(t, 7)
picker.DrawPlayerItems(t)
const blocksize = float64(0.3)
const COLSIZE = 12
diam := blocksize * 2.4
offset := diam + float64(4)*PIXEL_SCALE
for i := 0; i < len(self.inventoryRects); i++ {
x := float64(viewport.lplane) + float64(10)*PIXEL_SCALE + float64(i/COLSIZE)*offset
y := float64(viewport.tplane) - float64(10)*PIXEL_SCALE - float64(i%COLSIZE)*offset
self.inventoryRects[i] = Rect{x, y - diam, diam, diam}
self.DrawItemSlot(t, self.inventoryRects[i])
}
slot := 0
for i := 1; i < len(ThePlayer.inventory); i++ {
if ThePlayer.inventory[i] > 0 {
self.inventorySlots[slot] = uint16(i)
self.DrawItem(t, ThePlayer.inventory[i], uint16(i), self.inventoryRects[slot])
slot++
}
}
for i := 0; i < len(self.componentSlots); i++ {
x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + float64(i)*offset
y := float64(viewport.tplane) - (float64(10) * PIXEL_SCALE)
self.componentRects[i] = Rect{x, y - diam, diam, diam}
self.DrawItemSlot(t, self.componentRects[i])
}
for i := 0; i < len(self.componentSlots); i++ {
if self.componentSlots[i] != 0 {
self.DrawItem(t, ThePlayer.inventory[self.componentSlots[i]], self.componentSlots[i], self.componentRects[i])
}
}
for i := 0; i < len(self.productSlots); i++ {
x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + offset*float64(i%len(self.componentRects))
y := float64(viewport.tplane) - (float64(10) * PIXEL_SCALE) - offset*float64(2+float64(i/len(self.componentRects)))
self.productRects[i] = Rect{x, y - diam, diam, diam}
self.DrawItemSlot(t, self.productRects[i])
}
for i := 0; i < len(self.productSlots); i++ {
if self.productSlots[i] != nil {
self.DrawItem(t, self.productSlots[i].product.quantity, self.productSlots[i].product.item, self.productRects[i])
}
}
var mousex, mousey int
mousestate := sdl.GetMouseState(&mousex, &mousey)
self.HandleMouse(mousex, mousey, mousestate)
gl.PopMatrix()
}
开发者ID:Cyberdada,项目名称:amberfell,代码行数:83,代码来源:inventory.go
示例20: main
func main() {
runtime.LockOSThread()
if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
log.Fatal(sdl.GetError())
}
var screen = sdl.SetVideoMode(screenWidth, screenHeight, 32, sdl.OPENGL|sdl.HWSURFACE|sdl.GL_DOUBLEBUFFER|sdl.FULLSCREEN)
if screen == nil {
log.Fatal(sdl.GetError())
}
sdl.WM_SetCaption("Lecture Hall Games", "")
sdl.EnableUNICODE(1)
if gl.Init() != 0 {
log.Fatal("could not initialize OpenGL")
}
gl.Viewport(0, 0, int(screen.W), int(screen.H))
gl.ClearColor(1, 1, 1, 0)
gl.Clear(gl.COLOR_BUFFER_BIT)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)
gl.Disable(gl.LIGHTING)
gl.Disable(gl.DEPTH_TEST)
gl.TexEnvi(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
if mixer.OpenAudio(mixer.DEFAULT_FREQUENCY, mixer.DEFAULT_FORMAT,
mixer.DEFAULT_CHANNELS, 4096) != 0 {
log.Fatal(sdl.GetError())
}
if ttf.Init() != 0 {
log.Fatal(sdl.GetError())
}
if p, err := build.Default.Import(basePkg, "", build.FindOnly); err == nil {
os.Chdir(p.Dir)
}
var err error
rand.Seed(time.Now().UnixNano())
levelDir := fmt.Sprintf("data/levels/demolevel%d", 3+rand.Intn(numberLevels))
//carsDir := fmt.Sprintf(" data/cars/car%d/", 1+rand.Intn(numberCars))
if game, err = NewRacer(levelDir); err != nil {
log.Fatal(err)
}
go func() {
listen, err := net.Listen("tcp", ":8001")
if err != nil {
log.Fatal(err)
}
for {
conn, err := listen.Accept()
if err != nil {
log.Println(err)
continue
}
go handleConnection(conn)
}
}()
running := true
last := time.Now()
for running {
select {
case event := <-sdl.Events:
switch e := event.(type) {
case sdl.QuitEvent:
running = false
case sdl.ResizeEvent:
screen = sdl.SetVideoMode(int(e.W), int(e.H), 32, sdl.RESIZABLE)
case sdl.KeyboardEvent:
if e.Type == sdl.KEYDOWN {
if e.Keysym.Sym == sdl.K_ESCAPE {
running = false
} else {
game.KeyPressed(e.Keysym)
}
}
}
default:
}
current := time.Now()
t := current.Sub(last)
last = current
mu.Lock()
game.Update(t)
game.Render(screen)
mu.Unlock()
sdl.GL_SwapBuffers()
}
sdl.Quit()
}
开发者ID:mfpi,项目名称:lecture-hall-games,代码行数:98,代码来源:main.go
注:本文中的github.com/banthar/gl.Disable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论