Loading scenes/gldemo/gldemo.go +50 −36 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ const ( sceneName = "GL-Demo" windowWidth = 1650 windowHeight = 1080 invAspectDeg = float32(windowHeight) * 45.0 / float32(windowWidth) ) var ( Loading @@ -32,6 +33,7 @@ var ( modelUniform int32 texture uint32 vao uint32 vbo uint32 ) // Hooks returns our hooks. Loading @@ -57,6 +59,9 @@ func initialize() { gl.UseProgram(program) projection = mgl32.Perspective(mgl32.DegToRad(45.0), float32(windowWidth)/windowHeight, 0.1, 10.0) //w2 := float32(windowWidth / 2) //h2 := float32(windowHeight / 2) //projection = mgl32.Frustum(-w2, w2, -h2, h2, 0.1, 10.0) projectionUniform := gl.GetUniformLocation(program, gl.Str("projection\x00")) gl.UniformMatrix4fv(projectionUniform, 1, false, &projection[0]) Loading @@ -83,7 +88,6 @@ func initialize() { gl.GenVertexArrays(1, &vao) gl.BindVertexArray(vao) var vbo uint32 gl.GenBuffers(1, &vbo) gl.BindBuffer(gl.ARRAY_BUFFER, vbo) gl.BufferData(gl.ARRAY_BUFFER, len(cubeVertices)*4, gl.Ptr(cubeVertices), gl.STATIC_DRAW) Loading @@ -108,7 +112,16 @@ func initialize() { // Resize changes the view. func resize(width, height int) { fmt.Fprintf(os.Stderr, "[%s] Resize(%d, %d)\n", sceneName, width, height) //fmt.Fprintf(os.Stderr, "[%s] Resize(%d, %d)\n", sceneName, width, height) aspect := float32(width) / float32(height) //degree := aspect * invAspectDeg //projection = mgl32.Perspective(mgl32.DegToRad(degree), aspect, 0.1, 10.0) projection = mgl32.Perspective(mgl32.DegToRad(45.0), aspect, 0.1, 10.0) //w2 := float32(width / 2) //h2 := float32(height / 2) //projection = mgl32.Frustum(-w2, w2, -h2, h2, 0.1, 10.0) projectionUniform := gl.GetUniformLocation(program, gl.Str("projection\x00")) gl.UniformMatrix4fv(projectionUniform, 1, false, &projection[0]) } // Render something. Loading Loading @@ -254,6 +267,7 @@ out vec2 fragTexCoord; void main() { fragTexCoord = vertTexCoord; gl_Position = projection * camera * model * vec4(vert, 1); //gl_Position = camera * model * projection * vec4(vert, 1); } ` + "\x00" Loading @@ -275,49 +289,49 @@ var cubeVertices = []float32{ // X, Y, Z, U, V // Bottom -1.0, -1.0, -1.0, 0.0, 0.0, 1.0, -1.0, -1.0, 1.0, 0.0, -1.0, -1.0, 1.0, 0.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, -1.0, -1.0, +1.0, 0.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, +1.0, -1.0, +1.0, 1.0, 1.0, -1.0, -1.0, +1.0, 0.0, 1.0, // Top -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, +1.0, -1.0, 0.0, 0.0, -1.0, +1.0, +1.0, 0.0, 1.0, +1.0, +1.0, -1.0, 1.0, 0.0, +1.0, +1.0, -1.0, 1.0, 0.0, -1.0, +1.0, +1.0, 0.0, 1.0, +1.0, +1.0, +1.0, 1.0, 1.0, // Front -1.0, -1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, +1.0, 1.0, 0.0, +1.0, -1.0, +1.0, 0.0, 0.0, -1.0, +1.0, +1.0, 1.0, 1.0, +1.0, -1.0, +1.0, 0.0, 0.0, +1.0, +1.0, +1.0, 0.0, 1.0, -1.0, +1.0, +1.0, 1.0, 1.0, // Back -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 1.0, -1.0, 0.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, -1.0, 1.0, 0.0, -1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, +1.0, -1.0, 0.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, +1.0, -1.0, -1.0, 1.0, 0.0, -1.0, +1.0, -1.0, 0.0, 1.0, +1.0, +1.0, -1.0, 1.0, 1.0, // Left -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, -1.0, 1.0, 0.0, -1.0, -1.0, +1.0, 0.0, 1.0, -1.0, +1.0, -1.0, 1.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 0.0, -1.0, -1.0, +1.0, 0.0, 1.0, -1.0, +1.0, +1.0, 1.0, 1.0, -1.0, +1.0, -1.0, 1.0, 0.0, // Right 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, +1.0, -1.0, +1.0, 1.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, +1.0, +1.0, -1.0, 0.0, 0.0, +1.0, -1.0, +1.0, 1.0, 1.0, +1.0, +1.0, -1.0, 0.0, 0.0, +1.0, +1.0, +1.0, 0.0, 1.0, } Loading
scenes/gldemo/gldemo.go +50 −36 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ const ( sceneName = "GL-Demo" windowWidth = 1650 windowHeight = 1080 invAspectDeg = float32(windowHeight) * 45.0 / float32(windowWidth) ) var ( Loading @@ -32,6 +33,7 @@ var ( modelUniform int32 texture uint32 vao uint32 vbo uint32 ) // Hooks returns our hooks. Loading @@ -57,6 +59,9 @@ func initialize() { gl.UseProgram(program) projection = mgl32.Perspective(mgl32.DegToRad(45.0), float32(windowWidth)/windowHeight, 0.1, 10.0) //w2 := float32(windowWidth / 2) //h2 := float32(windowHeight / 2) //projection = mgl32.Frustum(-w2, w2, -h2, h2, 0.1, 10.0) projectionUniform := gl.GetUniformLocation(program, gl.Str("projection\x00")) gl.UniformMatrix4fv(projectionUniform, 1, false, &projection[0]) Loading @@ -83,7 +88,6 @@ func initialize() { gl.GenVertexArrays(1, &vao) gl.BindVertexArray(vao) var vbo uint32 gl.GenBuffers(1, &vbo) gl.BindBuffer(gl.ARRAY_BUFFER, vbo) gl.BufferData(gl.ARRAY_BUFFER, len(cubeVertices)*4, gl.Ptr(cubeVertices), gl.STATIC_DRAW) Loading @@ -108,7 +112,16 @@ func initialize() { // Resize changes the view. func resize(width, height int) { fmt.Fprintf(os.Stderr, "[%s] Resize(%d, %d)\n", sceneName, width, height) //fmt.Fprintf(os.Stderr, "[%s] Resize(%d, %d)\n", sceneName, width, height) aspect := float32(width) / float32(height) //degree := aspect * invAspectDeg //projection = mgl32.Perspective(mgl32.DegToRad(degree), aspect, 0.1, 10.0) projection = mgl32.Perspective(mgl32.DegToRad(45.0), aspect, 0.1, 10.0) //w2 := float32(width / 2) //h2 := float32(height / 2) //projection = mgl32.Frustum(-w2, w2, -h2, h2, 0.1, 10.0) projectionUniform := gl.GetUniformLocation(program, gl.Str("projection\x00")) gl.UniformMatrix4fv(projectionUniform, 1, false, &projection[0]) } // Render something. Loading Loading @@ -254,6 +267,7 @@ out vec2 fragTexCoord; void main() { fragTexCoord = vertTexCoord; gl_Position = projection * camera * model * vec4(vert, 1); //gl_Position = camera * model * projection * vec4(vert, 1); } ` + "\x00" Loading @@ -275,49 +289,49 @@ var cubeVertices = []float32{ // X, Y, Z, U, V // Bottom -1.0, -1.0, -1.0, 0.0, 0.0, 1.0, -1.0, -1.0, 1.0, 0.0, -1.0, -1.0, 1.0, 0.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, -1.0, -1.0, +1.0, 0.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, +1.0, -1.0, +1.0, 1.0, 1.0, -1.0, -1.0, +1.0, 0.0, 1.0, // Top -1.0, 1.0, -1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, +1.0, -1.0, 0.0, 0.0, -1.0, +1.0, +1.0, 0.0, 1.0, +1.0, +1.0, -1.0, 1.0, 0.0, +1.0, +1.0, -1.0, 1.0, 0.0, -1.0, +1.0, +1.0, 0.0, 1.0, +1.0, +1.0, +1.0, 1.0, 1.0, // Front -1.0, -1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, +1.0, 1.0, 0.0, +1.0, -1.0, +1.0, 0.0, 0.0, -1.0, +1.0, +1.0, 1.0, 1.0, +1.0, -1.0, +1.0, 0.0, 0.0, +1.0, +1.0, +1.0, 0.0, 1.0, -1.0, +1.0, +1.0, 1.0, 1.0, // Back -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, 1.0, -1.0, 0.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, -1.0, 1.0, 0.0, -1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, +1.0, -1.0, 0.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, +1.0, -1.0, -1.0, 1.0, 0.0, -1.0, +1.0, -1.0, 0.0, 1.0, +1.0, +1.0, -1.0, 1.0, 1.0, // Left -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, -1.0, 1.0, 0.0, -1.0, -1.0, +1.0, 0.0, 1.0, -1.0, +1.0, -1.0, 1.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, -1.0, -1.0, 1.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 0.0, -1.0, -1.0, +1.0, 0.0, 1.0, -1.0, +1.0, +1.0, 1.0, 1.0, -1.0, +1.0, -1.0, 1.0, 0.0, // Right 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 0.0, 1.0, 1.0, -1.0, 0.0, 0.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, +1.0, -1.0, +1.0, 1.0, 1.0, +1.0, -1.0, -1.0, 1.0, 0.0, +1.0, +1.0, -1.0, 0.0, 0.0, +1.0, -1.0, +1.0, 1.0, 1.0, +1.0, +1.0, -1.0, 0.0, 0.0, +1.0, +1.0, +1.0, 0.0, 1.0, }