예제 #1
0
파일: window.go 프로젝트: swantescholz/go
func (this *Window) initGL() {
	gl.ShadeModel(gl.SMOOTH) //SMOOTH or FLAT
	gl.CullFace(gl.BACK)
	gl.FrontFace(gl.CCW)
	gl.Enable(gl.CULL_FACE)
	gl.Enable(gl.DEPTH_TEST)
	gl.Enable(gl.LIGHTING)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	/*gl.Enable(gl.FOG)
	gl.Fogi(gl.FOG_MODE, gl.EXP)
	gl.Fogfv(gl.FOG_COLOR, []float32{0.5,0.5,0.5,1.0})
	gl.Fogf(gl.FOG_DENSITY, 0.0035)
	gl.Hint(gl.FOG_HINT, gl.DONT_CARE)
	gl.Fogf(gl.FOG_START, 1.0)
	gl.Fogf(gl.FOG_END  , 5000.0)//*/
	gl.Enable(gl.TEXTURE_2D)
	gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE) //before: decal, std: modulate
	//gl.TexParameteri(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, true) //mipmaps (dont use it!, its bad!)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)               //GL_LINEAR or GL_NEAREST, no mipmap here
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR) //*/
	gl.ClearColor(.1, .1, .1, 1)
	//gl.Enable(gl.PRIMITIVE_RESTART)
	//gl.PrimitiveRestartIndex()
	this.setGLViewport()
}
예제 #2
0
func (this *Window) initGL() {

	runtime.LockOSThread()

	if gl.Init() != 0 {
		panic("gl init error")
	}

	gl.ShadeModel(gl.SMOOTH)
	gl.CullFace(gl.BACK)
	gl.FrontFace(gl.CCW)
	gl.Enable(gl.CULL_FACE)
	gl.Enable(gl.DEPTH_TEST)
	gl.Enable(gl.LIGHTING)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Enable(gl.TEXTURE_2D)
	gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
	var magFilter, minFilter = gl.LINEAR, gl.LINEAR
	if globals.CreateMipmaps {
		minFilter = gl.LINEAR_MIPMAP_LINEAR
	}
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter)
	gl.Enable(gl.NORMALIZE)
	gl.ClearColor(.1, .1, .1, 1)
	this.setGLViewport()
}
예제 #3
0
파일: sdldoc.go 프로젝트: glenn-brown/aima
func setup_opengl(width, height int) {
	ratio := float64(width) / float64(height)
	gl.ShadeModel(gl.SMOOTH)
	gl.CullFace(gl.BACK)
	gl.FrontFace(gl.CCW)
	gl.Enable(gl.CULL_FACE)
	gl.ClearColor(0, 0, 0, 0)
	gl.Viewport(0, 0, width, height)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()

	gluPerspective := func(fovy, aspect, zNear, zFar float64) {
		top := math.Tan(fovy*0.5) * zNear
		bottom := -top
		left := aspect * bottom
		right := -left
		gl.Frustum(left, right, bottom, top, zNear, zFar)
	}
	gluPerspective(60.0, ratio, 1.0, 1024.0)
}