Пример #1
0
func (me *RenderView) render() {
	if me.Enabled {
		thrRend.curView, thrRend.curTech, thrRend.curEffect = me, me.Technique, nil
		Core.Render.states.Apply(&me.RenderStates)
		if me.Port.shouldScissor {
			Core.Render.states.ForceEnableScissorTest()
			gl.Scissor(me.Port.glVpX, me.Port.glVpY, me.Port.glVpW, me.Port.glVpH)
		}
		gl.Viewport(me.Port.glVpX, me.Port.glVpY, me.Port.glVpW, me.Port.glVpH)
		gl.Clear(me.RenderStates.Other.ClearBits)
		me.Technique.render()
		if me.Port.shouldScissor {
			Core.Render.states.ForceDisableScissorTest()
		}
	}
}
Пример #2
0
func main() {
	var err error
	var looping = true
	defer fmt.Println("EXIT")
	if err = glfw.Init(); err != nil {
		panic(err)
	}
	defer glfw.Terminate()
	glfw.OpenWindowHint(glfw.FsaaSamples, 0)
	if useStrictCoreProfile {
		glfw.OpenWindowHint(glfw.OpenGLVersionMajor, 3)
		glfw.OpenWindowHint(glfw.OpenGLVersionMinor, 2)
		glfw.OpenWindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
	}

	if err = glfw.OpenWindow(1280, 720, 8, 8, 8, 0, 24, 8, glfw.Windowed); err != nil {
		panic(err)
	}
	defer glfw.CloseWindow()
	glfw.Enable(glfw.StickyKeys)
	if !gl.Util.Init() {
		panic("Failed to initialize at least OpenGL 3.2 or higher.")
	}
	defer logLastGlError("(post loop)")
	gl.ClearColor(0.3, 0.1, 0.0, 1.0)
	gl.Enable(gl.DEPTH_TEST)
	gl.FrontFace(gl.CCW)
	gl.CullFace(gl.BACK)
	gl.Disable(gl.CULL_FACE)
	if err = compileShaders(); err != nil {
		panic(err)
	}
	setupGeometry()
	defer deleteGeometry()
	logLastGlError("(pre loop)")

	for looping {
		gl.UseProgram(shaderProg)
		if isFirstLoop {
			logLastGlError("gl.UseProgram")
		}

		gl.Viewport(0, 0, 1280, 720)
		if isFirstLoop {
			logLastGlError("gl.ViewPort")
		}

		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		if isFirstLoop {
			logLastGlError("gl.Clear")
		}

		renderGeometry(faceTri)
		if isFirstLoop {
			logLastGlError("renderGeometry(faceTri)")
		}

		renderGeometry(faceQuad)
		if isFirstLoop {
			logLastGlError("renderGeometry(faceQuad)")
		}

		if (glfw.WindowParam(glfw.Opened) != 1) || (glfw.Key(glfw.KeyEsc) == glfw.KeyPress) {
			looping = false
		} else {
			glfw.SwapBuffers()
		}
		isFirstLoop = false
	}
	logLastGlError("post-loop")
}
Пример #3
0
func main() {
	runtime.LockOSThread()
	var looping = true
	defer fmt.Println("EXIT")
	// if err = glfw.Init(); err != nil {
	// 	panic(err)
	// }
	if !glfw.Init() {
		panic("glfw.Init() failed!")
	}
	defer glfw.Terminate()
	// glfw.OpenWindowHint(glfw.FsaaSamples, 0)
	glfw.WindowHint(glfw.Samples, 0)
	if useStrictCoreProfile {
		// glfw.OpenWindowHint(glfw.OpenGLVersionMajor, 3)
		// glfw.OpenWindowHint(glfw.OpenGLVersionMinor, 2)
		// glfw.OpenWindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
		glfw.WindowHint(glfw.ContextVersionMajor, 3)
		glfw.WindowHint(glfw.ContextVersionMinor, 2)
		glfw.WindowHint(glfw.OpenglProfile, glfw.OpenglCoreProfile)
	}
	// if err = glfw.OpenWindow(1280, 720, 8, 8, 8, 0, 24, 8, glfw.Windowed); err != nil {
	// 	panic(err)
	// }
	// defer glfw.CloseWindow()
	glfw.WindowHint(glfw.RedBits, 8)
	glfw.WindowHint(glfw.BlueBits, 8)
	glfw.WindowHint(glfw.GreenBits, 8)
	glfw.WindowHint(glfw.AlphaBits, 0)
	glfw.WindowHint(glfw.DepthBits, 24)
	glfw.WindowHint(glfw.StencilBits, 8)
	win, err := glfw.CreateWindow(1280, 720, "Test", nil, nil)
	if err != nil {
		panic(err)
	}
	defer win.Destroy()
	win.MakeContextCurrent()

	// glfw.Enable(glfw.StickyKeys)
	win.SetInputMode(glfw.StickyKeys, glfw.True)
	if !gl.Util.Init() {
		panic("Failed to initialize at least OpenGL 3.2 or higher.")
	}
	defer logLastGlError("(post loop)")
	gl.ClearColor(0.3, 0.1, 0.0, 1.0)
	gl.Enable(gl.DEPTH_TEST)
	gl.FrontFace(gl.CCW)
	gl.CullFace(gl.BACK)
	gl.Disable(gl.CULL_FACE)
	if err = compileShaders(); err != nil {
		panic(err)
	}
	setupGeometry()
	defer deleteGeometry()
	logLastGlError("(pre loop)")

	for looping {
		gl.UseProgram(shaderProg)
		if isFirstLoop {
			logLastGlError("gl.UseProgram")
		}

		gl.Viewport(0, 0, 1280, 720)
		if isFirstLoop {
			logLastGlError("gl.ViewPort")
		}

		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		if isFirstLoop {
			logLastGlError("gl.Clear")
		}

		renderGeometry(faceTri)
		if isFirstLoop {
			logLastGlError("renderGeometry(faceTri)")
		}

		renderGeometry(faceQuad)
		if isFirstLoop {
			logLastGlError("renderGeometry(faceQuad)")
		}

		// if (glfw.WindowParam(glfw.Opened) != 1) || (glfw.Key(glfw.KeyEsc) == glfw.KeyPress) {
		if win.ShouldClose() || win.GetKey(glfw.KeyEscape) == glfw.Press {
			looping = false
		} else {
			// glfw.SwapBuffers()
			win.SwapBuffers()
			glfw.PollEvents()
		}
		isFirstLoop = false
	}
	logLastGlError("post-loop")
}