コード例 #1
0
//	Toggles scissor-testing.
func (me RenderStates) ToggleScissorTest() {
	if Cache.renderStates.ScissorTest = !Cache.renderStates.ScissorTest; Cache.renderStates.ScissorTest {
		gl.Enable(gl.SCISSOR_TEST)
	} else {
		gl.Disable(gl.SCISSOR_TEST)
	}
}
コード例 #2
0
//	Toggles blending.
func (me RenderStates) ToggleBlending() {
	if Cache.renderStates.Blending = !Cache.renderStates.Blending; Cache.renderStates.Blending {
		gl.Enable(gl.BLEND)
	} else {
		gl.Disable(gl.BLEND)
	}
}
コード例 #3
0
//	Toggles depth-testing.
func (me RenderStates) ToggleDepthTest() {
	if Cache.renderStates.DepthTest = !Cache.renderStates.DepthTest; Cache.renderStates.DepthTest {
		gl.Enable(gl.DEPTH_TEST)
	} else {
		gl.Disable(gl.DEPTH_TEST)
	}
}
コード例 #4
0
//	Toggles stencil-testing.
func (me RenderStates) ToggleStencilTest() {
	if Cache.renderStates.StencilTest = !Cache.renderStates.StencilTest; Cache.renderStates.StencilTest {
		gl.Enable(gl.STENCIL_TEST)
	} else {
		gl.Disable(gl.STENCIL_TEST)
	}
}
コード例 #5
0
//	Toggles face-culling.
func (me RenderStates) ToggleFaceCulling() {
	if Cache.renderStates.FaceCulling = !Cache.renderStates.FaceCulling; Cache.renderStates.FaceCulling {
		gl.Enable(gl.CULL_FACE)
	} else {
		gl.Disable(gl.CULL_FACE)
	}
}
コード例 #6
0
//	Toggles SRGB-framebuffer.
func (me RenderStates) ToggleFramebufferSrgb() {
	if Cache.renderStates.FramebufferSrgb = !Cache.renderStates.FramebufferSrgb; Cache.renderStates.FramebufferSrgb {
		gl.Enable(gl.FRAMEBUFFER_SRGB)
	} else {
		gl.Disable(gl.FRAMEBUFFER_SRGB)
	}
}
コード例 #7
0
//	Activates or deactivates face-culling.
func (me RenderStates) SetFaceCulling(newFaceCulling bool) {
	if Cache.renderStates.FaceCulling != newFaceCulling {
		if Cache.renderStates.FaceCulling = newFaceCulling; Cache.renderStates.FaceCulling {
			gl.Enable(gl.CULL_FACE)
		} else {
			gl.Disable(gl.CULL_FACE)
		}
	}
}
コード例 #8
0
//	Activates or deactivates depth-testing.
func (me RenderStates) SetDepthTest(newDepthTest bool) {
	if Cache.renderStates.DepthTest != newDepthTest {
		if Cache.renderStates.DepthTest = newDepthTest; Cache.renderStates.DepthTest {
			gl.Enable(gl.DEPTH_TEST)
		} else {
			gl.Disable(gl.DEPTH_TEST)
		}
	}
}
コード例 #9
0
//	Activates or deactivates blending.
func (me RenderStates) SetBlending(newBlending bool) {
	if Cache.renderStates.Blending != newBlending {
		if Cache.renderStates.Blending = newBlending; Cache.renderStates.Blending {
			gl.Enable(gl.BLEND)
		} else {
			gl.Disable(gl.BLEND)
		}
	}
}
コード例 #10
0
//	Activates or deactivates SRGB-framebuffer.
func (me RenderStates) SetFramebufferSrgb(newFramebufferSrgb bool) {
	if Cache.renderStates.FramebufferSrgb != newFramebufferSrgb {
		if Cache.renderStates.FramebufferSrgb = newFramebufferSrgb; Cache.renderStates.FramebufferSrgb {
			gl.Enable(gl.FRAMEBUFFER_SRGB)
		} else {
			gl.Disable(gl.FRAMEBUFFER_SRGB)
		}
	}
}
コード例 #11
0
//	Activates or deactivates stencil-testing.
func (me RenderStates) SetStencilTest(newStencilTest bool) {
	if Cache.renderStates.StencilTest != newStencilTest {
		if Cache.renderStates.StencilTest = newStencilTest; Cache.renderStates.StencilTest {
			gl.Enable(gl.STENCIL_TEST)
		} else {
			gl.Disable(gl.STENCIL_TEST)
		}
	}
}
コード例 #12
0
//	Activates or deactivates scissor-testing.
func (me RenderStates) SetScissorTest(newScissorTest bool) {
	if Cache.renderStates.ScissorTest != newScissorTest {
		if Cache.renderStates.ScissorTest = newScissorTest; Cache.renderStates.ScissorTest {
			gl.Enable(gl.SCISSOR_TEST)
		} else {
			gl.Disable(gl.SCISSOR_TEST)
		}
	}
}
コード例 #13
0
//	Disables scissor-testing only if it is currently enabled.
func (me RenderStates) DisableScissorTest() {
	if Cache.renderStates.ScissorTest {
		Cache.renderStates.ScissorTest = false
		gl.Disable(gl.SCISSOR_TEST)
	}
}
コード例 #14
0
//	Deactivates blending.
func (_ RenderStates) ForceDisableBlending() {
	Cache.renderStates.Blending = false
	gl.Disable(gl.BLEND)
}
コード例 #15
0
//	Disables blending only if it is currently enabled.
func (me RenderStates) DisableBlending() {
	if Cache.renderStates.Blending {
		Cache.renderStates.Blending = false
		gl.Disable(gl.BLEND)
	}
}
コード例 #16
0
//	Deactivates depth-testing.
func (_ RenderStates) ForceDisableDepthTest() {
	Cache.renderStates.DepthTest = false
	gl.Disable(gl.DEPTH_TEST)
}
コード例 #17
0
//	Deactivates stencil-testing.
func (_ RenderStates) ForceDisableStencilTest() {
	Cache.renderStates.StencilTest = false
	gl.Disable(gl.STENCIL_TEST)
}
コード例 #18
0
//	Disables stencil-testing only if it is currently enabled.
func (me RenderStates) DisableStencilTest() {
	if Cache.renderStates.StencilTest {
		Cache.renderStates.StencilTest = false
		gl.Disable(gl.STENCIL_TEST)
	}
}
コード例 #19
0
//	Disables face-culling only if it is currently enabled.
func (me RenderStates) DisableFaceCulling() {
	if Cache.renderStates.FaceCulling {
		Cache.renderStates.FaceCulling = false
		gl.Disable(gl.CULL_FACE)
	}
}
コード例 #20
0
//	Deactivates scissor-testing.
func (_ RenderStates) ForceDisableScissorTest() {
	Cache.renderStates.ScissorTest = false
	gl.Disable(gl.SCISSOR_TEST)
}
コード例 #21
0
//	Disables depth-testing only if it is currently enabled.
func (me RenderStates) DisableDepthTest() {
	if Cache.renderStates.DepthTest {
		Cache.renderStates.DepthTest = false
		gl.Disable(gl.DEPTH_TEST)
	}
}
コード例 #22
0
//	Deactivates face-culling.
func (_ RenderStates) ForceDisableFaceCulling() {
	Cache.renderStates.FaceCulling = false
	gl.Disable(gl.CULL_FACE)
}
コード例 #23
0
//	Deactivates SRGB-framebuffer.
func (_ RenderStates) ForceDisableFramebufferSrgb() {
	Cache.renderStates.FramebufferSrgb = false
	gl.Disable(gl.FRAMEBUFFER_SRGB)
}
コード例 #24
0
//	Disables SRGB-framebuffer only if it is currently enabled.
func (me RenderStates) DisableFramebufferSrgb() {
	if Cache.renderStates.FramebufferSrgb {
		Cache.renderStates.FramebufferSrgb = false
		gl.Disable(gl.FRAMEBUFFER_SRGB)
	}
}
コード例 #25
0
ファイル: main.go プロジェクト: LonelyPale/go-opengl
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")
}
コード例 #26
0
ファイル: main.go プロジェクト: LonelyPale/go-opengl
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")
}