本文整理匯總了Golang中github.com/banthar/gl.Vertex3f函數的典型用法代碼示例。如果您正苦於以下問題:Golang Vertex3f函數的具體用法?Golang Vertex3f怎麽用?Golang Vertex3f使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Vertex3f函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
}
示例2: Draw
// Render stuff
func Draw() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(-1, -1, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(1, -1, 0)
gl.End()
glfw.SwapBuffers()
}
示例3: render
func (s sprite) render() {
gl.Translatef(float32(s.X), float32(s.Y), float32(s.Z))
gl.Rotatef(90.0, 1.0, 0.0, 0.0)
s.tex.Bind(gl.TEXTURE_2D)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-s.width/2.0, -s.height/2.0, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(s.width/2.0, -s.height/2.0, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(s.width/2.0, s.height/2.0, 0.0)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-s.width/2.0, s.height/2.0, 0.0)
gl.End()
s.tex.Unbind(gl.TEXTURE_2D)
}
示例4: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(-1.5, 0, -6)
gl.Rotatef(trisAngle, 0, 1, 0)
gl.Begin(gl.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(0, 1, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(-1, -1, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(1, -1, 0)
gl.End()
gl.LoadIdentity()
gl.Translatef(1.5, 0, -6)
gl.Rotatef(quadAngle, 1, 0, 0)
gl.Color3f(0.5, 0.5, 1.0)
gl.Begin(gl.QUADS)
gl.Vertex3f(-1, 1, 0)
gl.Vertex3f(1, 1, 0)
gl.Vertex3f(1, -1, 0)
gl.Vertex3f(-1, -1, 0)
gl.End()
trisAngle += 0.2
quadAngle -= 0.15
glfw.SwapBuffers()
}
示例5: Render
func (v *Video) Render() {
for running {
select {
case dimensions := <-v.resize:
v.ResizeEvent(dimensions[0], dimensions[1])
case val := <-v.tick:
slice := make([]uint8, len(val)*3)
for i := 0; i < len(val); i = i + 1 {
slice[i*3+0] = (uint8)((val[i] >> 16) & 0xff)
slice[i*3+1] = (uint8)((val[i] >> 8) & 0xff)
slice[i*3+2] = (uint8)((val[i]) & 0xff)
}
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
v.tex.Bind(gl.TEXTURE_2D)
if ppu.OverscanEnabled {
gl.TexImage2D(gl.TEXTURE_2D, 0, 3, 240, 224, 0, gl.RGB, gl.UNSIGNED_BYTE, slice)
} else {
gl.TexImage2D(gl.TEXTURE_2D, 0, 3, 256, 240, 0, gl.RGB, gl.UNSIGNED_BYTE, slice)
}
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, 1.0, 0.0)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, 1.0, 0.0)
gl.End()
if v.screen != nil {
sdl.GL_SwapBuffers()
v.fpsmanager.FramerateDelay()
}
}
}
}
示例6: draw
func draw() {
for y := 0; y < Size; y++ {
for x := 0; x < Size; x++ {
var color uint8
if grid.Front()[y][x] {
color = 0x00
} else {
color = 0xFF
}
pixels[(y*Size+x)*3+0] = color
pixels[(y*Size+x)*3+1] = color
pixels[(y*Size+x)*3+2] = color
}
}
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.TexImage2D(gl.TEXTURE_2D, 0, 3, Size, Size, 0, gl.RGB, gl.UNSIGNED_BYTE, pixels)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, 1.0, 0.0)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, 1.0, 0.0)
gl.End()
glfw.SwapBuffers()
}
示例7: GLDraw
// Function GLDraw draws the model into the current GL scene. It assumes that the context is already
// set up, including any translation and rotation.
func (model *Model) GLDraw() {
var a, b, c float32
var v *Vertex
// Start drawing triangles
gl.Begin(gl.TRIANGLES)
for _, triangle := range model.triangles {
triangleNormals := triangle.TriangleNormals()
textureCoordinates := triangle.TextureCoordinates()
// Set the normal. Assume it's a flat triangle (the normals at all 3 vertices are equal)
a, b, c = triangleNormals.Vertex1Normal()
gl.Normal3f(a, b, c)
// Vertex 1
a, b = textureCoordinates.Vertex1Coord()
gl.TexCoord2f(a, b)
v = triangle.Vertex1()
gl.Vertex3f(v.X(), v.Y(), v.Z())
// Vertex 2
a, b = textureCoordinates.Vertex2Coord()
gl.TexCoord2f(a, b)
v = triangle.Vertex2()
gl.Vertex3f(v.X(), v.Y(), v.Z())
// Vertex 3
a, b = textureCoordinates.Vertex3Coord()
gl.TexCoord2f(a, b)
v = triangle.Vertex3()
gl.Vertex3f(v.X(), v.Y(), v.Z())
}
// Finish
gl.End()
}
示例8: Render
func (v *Video) Render() {
runtime.LockOSThread()
for running {
select {
case val := <-v.tick:
slice := make([]uint8, len(val)*3)
for i := 0; i < len(val); i = i + 1 {
slice[i*3+0] = (uint8)((val[i] >> 16) & 0xff)
slice[i*3+1] = (uint8)((val[i] >> 8) & 0xff)
slice[i*3+2] = (uint8)((val[i]) & 0xff)
}
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
v.tex.Bind(gl.TEXTURE_2D)
gl.TexImage2D(gl.TEXTURE_2D, 0, 3, 256, 240, 0, gl.RGB, gl.UNSIGNED_BYTE, slice)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
gl.Begin(gl.QUADS)
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, -1.0, 0.0)
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, 1.0, 0.0)
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, 1.0, 0.0)
gl.End()
glfw.SwapBuffers()
v.fpsmanager.FramerateDelay()
}
}
}
示例9: Render
// Render the mesh
// The V array must be a multiple of 3 since it uses triangles to render the mesh.
// If two or more triangles share the same edge the user can pass the same pointer twice
func (m *Mesh) Render() {
count := 0
gl.Begin(gl.TRIANGLES)
for _, v := range m.V {
if count%3 == 0 && count > 0 {
gl.End()
gl.Begin(gl.TRIANGLES)
count = 0
}
gl.Color3f(1, 0, 0)
gl.Vertex3f(v.X, v.Y, v.Z)
count++
}
if count > 0 {
gl.End()
}
}
示例10: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.LoadIdentity()
gl.Translatef(0, 0, -20+globalState.MousePos.Z*globalState.speed)
gl.Rotatef(globalState.Rot.X, 1, 0, 0)
gl.Rotatef(globalState.Rot.Y, 0, 1, 0)
gl.Rotatef(globalState.Rot.Z, 0, 0, 1)
if globalState.speed != 1 {
gl.Scalef(globalState.speed, globalState.speed, globalState.speed)
}
gl.RenderMode(gl.RENDER)
gl.Begin(gl.QUADS)
for i, _ := range mesh.Faces {
if colors, ok := faceColor[i]; ok {
gl.Color3f(colors[0], colors[1], colors[2])
} else {
faceColor[i] = make([]float32, 3)
faceColor[i][0] = rand.Float32()
faceColor[i][1] = rand.Float32()
faceColor[i][2] = rand.Float32()
gl.Color3f(faceColor[i][0], faceColor[i][1], faceColor[i][2])
}
face := &mesh.Faces[i]
for j, _ := range face.Vertices {
var v *wfobj.Vertex
if len(face.Normals) > 0 {
v = &face.Normals[j]
gl.Normal3f(v.X, v.Y, v.Z)
}
v = &face.Vertices[j]
gl.Vertex3f(v.X, v.Y, v.Z)
}
}
gl.End()
gl.Finish()
gl.Flush()
sdl.GL_SwapBuffers()
}
示例11: drawGLScene
// Here goes our drawing code
func drawGLScene() {
// Clear the screen and depth buffer
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Move left 1.5 units and into the screen 6.0 units.
gl.LoadIdentity()
gl.Translatef(-1.5, 0.0, -6.0)
gl.Rotatef(float32(rtri), 0.0, 1.0, 0.0) // Rotate the triangle on the Y axis
gl.Begin(gl.TRIANGLES) // Draw triangles
gl.Color3f(1.0, 0.0, 0.0) // Set The Color To Red
gl.Vertex3f(0.0, 1.0, 0.0) // top
gl.Color3f(0.0, 1.0, 0.0) // Set The Color To Red
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.Color3f(0.0, 0.0, 1.0) // Set The Color To Red
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.End() // finish drawing the triangle
// Move right 3 units
gl.LoadIdentity()
gl.Translatef(1.5, 0.0, -6.0)
gl.Color3f(0.5, 0.5, 1.0) // Set The Color To Blue One Time Only
gl.Rotatef(float32(rquad), 1.0, 0.0, 0.0) // rotate the quad on the X axis
gl.Begin(gl.QUADS) // draw quads
gl.Vertex3f(-1.0, 1.0, 0.0) // top left
gl.Vertex3f(1.0, 1.0, 0.0) // top right
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.End() // done drawing the quad
// Draw to the screen
sdl.GL_SwapBuffers()
rtri += 0.2 // Increase The Rotation Variable For The Triangle
rquad -= 0.15 // Decrease The Rotation Variable For The Quad
// Gather our frames per second
frames++
t := sdl.GetTicks()
if t-t0 >= 5000 {
seconds := (t - t0) / 1000.0
fps := frames / seconds
fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
t0 = t
frames = 0
}
}
示例12: drawGLScene
// Here goes our drawing code
func drawGLScene(sector Sector) {
xtrans := gl.GLfloat(-xpos)
ztrans := gl.GLfloat(-zpos)
ytrans := gl.GLfloat(-walkbias - 0.25)
scenroty := gl.GLfloat(360.0 - yrot)
// Clear the screen and depth buffer
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// reset the view
gl.LoadIdentity()
// Rotate up and down to look up and down
gl.Rotatef(float32(lookupdown), 1.0, 0.0, 0.0)
// Rotate depending on direction player is facing
gl.Rotatef(float32(scenroty), 0.0, 1.0, 0.0)
// translate the scene based on player position
gl.Translatef(float32(xtrans), float32(ytrans), float32(ztrans))
gl.BindTexture(gl.TEXTURE_2D, uint(textures[filter]))
for _, vertices := range sector {
gl.Begin(gl.TRIANGLES)
for _, triangle := range *vertices {
gl.Normal3f(0.0, 0.0, 1.0)
gl.TexCoord2f(float32(triangle.u), float32(triangle.v))
gl.Vertex3f(float32(triangle.x), float32(triangle.y), float32(triangle.z))
}
gl.End()
}
// Draw to the screen
sdl.GL_SwapBuffers()
// Gather our frames per second
frames++
t := sdl.GetTicks()
if t-t0 >= 5000 {
seconds := (t - t0) / 1000.0
fps := frames / seconds
fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
t0 = t
frames = 0
}
}
示例13: drawScene
func drawScene() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Food
for coord, _ := range food {
gl.LoadIdentity()
gl.Scalef(0.05, 0.05, 1)
gl.Translatef(float32(coord.x)-5, float32(coord.y)-5, -1)
gl.Begin(gl.QUADS)
gl.Color3f(0.5, float32(coord.x)/10, float32(coord.y)/10)
gl.Vertex3f(0.25, 0.75, 0)
gl.Vertex3f(0.75, 0.75, 0)
gl.Color3f(0.3, float32(coord.x)/10-0.2, float32(coord.y)/10-0.2)
gl.Vertex3f(0.75, 0.25, 0)
gl.Vertex3f(0.25, 0.25, 0)
gl.End()
}
//Snake
for _, coord := range snake.coords {
gl.LoadIdentity()
gl.Scalef(0.05, 0.05, 1)
gl.Translatef(float32(coord.x)-5, float32(coord.y)-5, -1)
gl.Begin(gl.QUADS)
gl.Color3f(float32(coord.y)/10, float32(coord.x)/10, 0.5)
gl.Vertex3f(0, 1, 0)
gl.Vertex3f(1, 1, 0)
gl.Color3f(float32(coord.y)/10-0.2, float32(coord.x)/10-0.2, 0.3)
gl.Vertex3f(1, 0, 0)
gl.Vertex3f(0, 0, 0)
gl.End()
}
glfw.SwapBuffers()
}
示例14: drawGLScene
// Here goes our drawing code
func drawGLScene() {
// Clear the screen and depth buffer
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Move left 1.5 units and into the screen 6.0 units.
gl.LoadIdentity()
gl.Translatef(-1.5, 0.0, -6.0)
gl.Begin(gl.TRIANGLES) // Draw triangles
gl.Vertex3f(0.0, 1.0, 0.0) // top
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.End() // finish drawing the triangle
// Move right 3 units
gl.Translatef(3.0, 0.0, 0.0)
gl.Begin(gl.QUADS) // draw quads
gl.Vertex3f(-1.0, 1.0, 0.0) // top left
gl.Vertex3f(1.0, 1.0, 0.0) // top right
gl.Vertex3f(1.0, -1.0, 0.0) // bottom right
gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
gl.End() // done drawing the quad
// Draw to the screen
sdl.GL_SwapBuffers()
// Gather our frames per second
frames++
t := sdl.GetTicks()
if t-t0 >= 5000 {
seconds := (t - t0) / 1000.0
fps := frames / seconds
fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
t0 = t
frames = 0
}
}
示例15: drawGLScene
// Here goes our drawing code
func drawGLScene() {
// Clear the screen and depth buffer
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
// Move left 1.5 units and into the screen 6.0 units.
gl.LoadIdentity()
gl.Translatef(0.0, 0.0, float32(z)) // translate by z
gl.Rotatef(float32(xrot), 1.0, 0.0, 0.0) /* Rotate On The X Axis */
gl.Rotatef(float32(yrot), 0.0, 1.0, 0.0) /* Rotate On The Y Axis */
/* Select Our Texture */
gl.BindTexture(gl.TEXTURE_2D, uint(textures[filter])) // based on filter
gl.Begin(gl.QUADS)
// Front face
gl.Normal3f(0.0, 0.0, 1.0) // Normal Pointing Towards Viewer
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom left
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, -1.0, 1.0) // Bottom right
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, 1.0, 1.0) // Top right
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, 1.0, 1.0) // Top left
// Back Face
gl.Normal3f(0.0, 0.0, -1.0) // Normal Pointing Away From Viewer
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom right
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, 1.0, -1.0) // Top right
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, 1.0, -1.0) // Top left
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, -1.0, -1.0) // Bottom left
// Top Face
gl.Normal3f(0.0, 1.0, 0.0) // Normal Pointing Up
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(-1.0, 1.0, -1.0) // Top left
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(-1.0, 1.0, 1.0) // Bottom left
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(1.0, 1.0, 1.0) // Bottom right
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(1.0, 1.0, -1.0) // Top right
// Bottom Face
gl.Normal3f(0.0, -1.0, 0.0) // Normal Pointing Down
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, -1.0, -1.0) // Top right
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, -1.0, -1.0) // Top left
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, -1.0, 1.0) // Bottom left
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom right
// Right face
gl.Normal3f(1.0, 0.0, 0.0) // Normal Pointing Right
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(1.0, -1.0, -1.0) // Bottom right
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(1.0, 1.0, -1.0) // Top right
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(1.0, 1.0, 1.0) // Top left
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(1.0, -1.0, 1.0) // Bottom left
// Left Face
gl.Normal3f(-1.0, 0.0, 0.0) // Normal Pointing Left
gl.TexCoord2f(1.0, 0.0)
gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom left
gl.TexCoord2f(0.0, 0.0)
gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom right
gl.TexCoord2f(0.0, 1.0)
gl.Vertex3f(-1.0, 1.0, 1.0) // Top right
gl.TexCoord2f(1.0, 1.0)
gl.Vertex3f(-1.0, 1.0, -1.0) // Top left
gl.End()
sdl.GL_SwapBuffers()
xrot += xspeed
yrot += yspeed
// Gather our frames per second
frames++
t := sdl.GetTicks()
if t-t0 >= 5000 {
seconds := (t - t0) / 1000.0
fps := frames / seconds
fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
t0 = t
frames = 0
}
//.........這裏部分代碼省略.........