func resize(w, h int) { // TODO: Fix the near and far limits persMat := gls.Perspective(45, float32(w)/float32(h), 1, 1000) //persMat := gls.Identity() gl.UseProgram(theProgram) gls.UniformMatrix4fv(ctcm_unif, 1, false, persMat) //log.Println("Resizing ", persMat) gl.Viewport(0, 0, gl.Sizei(w), gl.Sizei(h)) }
func renderToScreen() { gl.BindFramebuffer(gl.FRAMEBUFFER, 0) gl.Viewport(0, 0, winWidth, winHeight) gl.UseProgram(shaderTextureDisplay.glProg) gl.BindTexture(gl.TEXTURE_2D, rttFrameTex) gl.Uniform1i(shaderTextureDisplay.unifTex, 0) gl.BindBuffer(gl.ARRAY_BUFFER, dispVertBuf) gl.EnableVertexAttribArray(shaderTextureDisplay.attrPos) gl.VertexAttribPointer(shaderTextureDisplay.attrPos, 3, gl.FLOAT, gl.FALSE, 0, gl.Pointer(nil)) gl.DrawArrays(gl.TRIANGLE_FAN, 0, 4) gl.DisableVertexAttribArray(shaderTextureDisplay.attrPos) gl.BindBuffer(gl.ARRAY_BUFFER, 0) }
func renderToTexture() { gl.BindFramebuffer(gl.FRAMEBUFFER, rttFrameBuf) gl.Viewport(0, 0, texSize, texSize) gl.ClearColor(0.9, 0.6, 0.3, 1) gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) gl.UseProgram(shaderTextureCreator.glProg) gl.BindBuffer(gl.ARRAY_BUFFER, rttVertBuf) gl.EnableVertexAttribArray(shaderTextureCreator.attrPos) gl.VertexAttribPointer(shaderTextureCreator.attrPos, 2, gl.FLOAT, gl.FALSE, 0, gl.Pointer(nil)) gl.DrawArrays(gl.TRIANGLE_FAN, 0, 4) gl.DisableVertexAttribArray(shaderTextureCreator.attrPos) gl.BindBuffer(gl.ARRAY_BUFFER, 0) }
func renderToTexture() { gl.BindFramebuffer(gl.FRAMEBUFFER, rttFrameBuf) gl.Viewport(0, 0, texWidth, texHeight) gl.ClearColor(0.1, 0.2, 0.3, 1) gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) gl.UseProgram(shaderTextureCreator.glProg) gl.BindTexture(gl.TEXTURE_3D, volTex) gl.Uniform1i(shaderTextureCreator.unifTex, 0) gl.BindBuffer(gl.ARRAY_BUFFER, rttVertBuf) gl.EnableVertexAttribArray(shaderTextureCreator.attrPos) gl.VertexAttribPointer(shaderTextureCreator.attrPos, 2, gl.FLOAT, gl.FALSE, 0, gl.Pointer(nil)) gl.DrawArrays(gl.TRIANGLE_FAN, 0, 4) gl.DisableVertexAttribArray(shaderTextureCreator.attrPos) gl.BindBuffer(gl.ARRAY_BUFFER, 0) }
func handleResize(w, h int) { gl.Viewport(0, 0, gl.Sizei(w), gl.Sizei(h)) }