示例#1
0
文件: gldebug.go 项目: Miaque/mojo
func Enable(cap Enum) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.Enable(%v) %v", cap, errstr)
	}()
	C.glEnable(cap.c())
}
示例#2
0
func InitGL(width, height, msaa int, fullscreen bool) {
	C.SDL_Init(C.SDL_INIT_VIDEO)
	C.SDL_VideoInit( /*nil*/ C.SDL_GetVideoDriver(0))
	C.SDL_GL_SetAttribute(C.SDL_GL_CONTEXT_MAJOR_VERSION, 3)
	C.SDL_GL_SetAttribute(C.SDL_GL_CONTEXT_MINOR_VERSION, 2)

	if msaa != 0 {
		C.SDL_GL_SetAttribute(C.SDL_GL_MULTISAMPLEBUFFERS, 1)
		C.SDL_GL_SetAttribute(C.SDL_GL_MULTISAMPLESAMPLES, C.int(msaa))
	}

	C.SDL_GL_SetAttribute(C.SDL_GL_DEPTH_SIZE, 16)
	//win = C.SDL_CreateWindow(nil, C.SDL_WINDOWPOS_CENTERED, C.SDL_WINDOWPOS_CENTERED,C.int(width), C.int(height), C.SDL_WINDOW_OPENGL)
	if fullscreen {
		win = C.SDL_CreateWindow(nil, C.SDL_WINDOWPOS_CENTERED, C.SDL_WINDOWPOS_CENTERED, C.int(width), C.int(height), C.SDL_WINDOW_OPENGL|C.SDL_WINDOW_FULLSCREEN_DESKTOP)
	} else {
		win = C.SDL_CreateWindow(nil, C.SDL_WINDOWPOS_CENTERED, C.SDL_WINDOWPOS_CENTERED, C.int(width), C.int(height), C.SDL_WINDOW_OPENGL)
	}

	C.SDL_ShowWindow(win)
	wat := C.SDL_GL_CreateContext(win)
	fmt.Println(C.GoString(C.SDL_GetVideoDriver(0)))

	C.SDL_GL_MakeCurrent(win, wat)
	//C.SDL_GL_SetSwapInterval(1)

	C.glEnable(C.GL_DEPTH_TEST)
	C.glDepthFunc(C.GL_LEQUAL)

	C.glClearColor(0.3, 0.5, 1, 0)
	C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT)
	printerr("failed to initialize openGL")

}
示例#3
0
文件: imp.go 项目: CaptainSoOmA/Uni
func init() {
	//
	right[0], front[1], top[2] = 1.0, 1.0, 1.0
	matrix[3][3] = 1.
	for l := 0; l < MaxL; l++ {
		lightSource[l] = vect.New()
	}
	w := 2.0 * math.Pi / float64(nLamp)
	sin[0], cos[0] = C.GLdouble(0.0), C.GLdouble(1.0)
	sin[nLamp], cos[nLamp] = sin[0], cos[0]
	for g := 1; g < nLamp; g++ {
		sin[g] = C.GLdouble(math.Sin(float64(g) * w))
		cos[g] = C.GLdouble(math.Cos(float64(g) * w))
	}
	sin[nLamp+1], sin[1] = cos[nLamp+1], cos[1]
	//  C.glDepthFunc (C.GL_LESS) // default
	C.glEnable(C.GL_DEPTH_TEST)
	C.glShadeModel(C.GL_SMOOTH)
	for i := 0; i < 3; i++ {
		lmAmb[i] = C.GLfloat(0.2)
	} // default: 0.2
	lmAmb[3] = C.GLfloat(1.0) // default: 1.0
	C.glLightModelfv(C.GL_LIGHT_MODEL_AMBIENT, &lmAmb[0])
	for i := 0; i < 3; i++ {
		mAmbi[i] = C.GLfloat(0.2)
	} // default: 0.2
	mAmbi[3] = C.GLfloat(1.0) // default: 1.0
	//  C.glLightModelfv (C.GL_LIGHT_MODEL_TWO_SIDE, 1)
	C.glMaterialfv(C.GL_FRONT_AND_BACK, C.GL_AMBIENT_AND_DIFFUSE, &mAmbi[0])
	for i := 0; i < 3; i++ {
		mDiff[i] = C.GLfloat(0.8)
	} // default: 0.8
	mDiff[3] = C.GLfloat(1.0) // default: 1.0
	w = 1.
	C.glClearDepth(C.GLclampd(w))
	//  C.glMaterialfv (C.GL_FRONT_AND_BACK, C.GL_DIFFUSE, mDiff)
	//  C.glColorMaterial (C.GL_FRONT_AND_BACK, C.GL_DIFFUSE)
	//  C.glColorMaterial (C.GL_FRONT, C.GL_AMBIENT)
	C.glColorMaterial(C.GL_FRONT_AND_BACK, C.GL_AMBIENT_AND_DIFFUSE)
	C.glEnable(C.GL_COLOR_MATERIAL)
	C.glEnable(C.GL_LIGHTING)
	initialize()
}
示例#4
0
func (game *game) initGL() {
	log.Printf("GL_VERSION: %v GL_RENDERER: %v GL_VENDOR %v\n",
		GetString(C.GL_VERSION), GetString(C.GL_RENDERER), GetString(C.GL_VENDOR))
	log.Printf("GL_EXTENSIONS: %v\n", GetString(C.GL_EXTENSIONS))
	C.glClearColor(0.0, 0.0, 0.0, 1.0)
	C.glEnable(C.GL_CULL_FACE)
	C.glEnable(C.GL_DEPTH_TEST)

	game.prog = createProgram(vertShaderSrcDef, fragShaderSrcDef)
	posAttrib := attribLocation(game.prog, "vPosition")
	game.offsetUni = uniformLocation(game.prog, "offset")
	game.colorUni = uniformLocation(game.prog, "color")
	C.glUseProgram(game.prog)
	C.glEnableVertexAttribArray(C.GLuint(posAttrib))

	vertVBO := GenBuffer()
	checkGLError()
	C.glBindBuffer(C.GL_ARRAY_BUFFER, vertVBO)
	verts := []float32{.0, 0.5, -0.5, -0.5, 0.5, -0.5}
	C.glBufferData(C.GL_ARRAY_BUFFER, C.GLsizeiptr(len(verts)*int(unsafe.Sizeof(verts[0]))), unsafe.Pointer(&verts[0]), C.GL_STATIC_DRAW)
	C.glVertexAttribPointer(C.GLuint(posAttrib), 2, C.GL_FLOAT, C.GL_FALSE, 0, unsafe.Pointer(uintptr(0)))
}
示例#5
0
文件: imp.go 项目: CaptainSoOmA/Uni
func ActualizeLight(n uint) { // n < MaxL
	//
	var L [4]float64
	L[0], L[1], L[2] = lightSource[n].Coord3()
	var l [4]C.GLfloat
	for i := 0; i < 3; i++ {
		l[i] = C.GLfloat(L[i])
	}
	l[3] = C.GLfloat(1.0)
	C.glLightfv(C.GL_LIGHT0+C.GLenum(n), C.GL_POSITION, &l[0])
	C.glLightfv(C.GL_LIGHT0+C.GLenum(n), C.GL_AMBIENT, &aa[n][0])
	C.glLightfv(C.GL_LIGHT0+C.GLenum(n), C.GL_DIFFUSE, &dd[n][0])
	C.glEnable(C.GL_LIGHT0 + C.GLenum(n))
}
示例#6
0
func Enable(cap Enum) {
	C.glEnable(cap.c())
}
示例#7
0
文件: gles2.go 项目: remogatto/egles
func Enable(
	cap Enum) {
	C.glEnable(C.GLenum(cap))

}
示例#8
0
文件: gl.go 项目: extrame/gl
// Enable calls glEnable
func Enable(mask int) {
	C.glEnable(C.GLenum(mask))
}
示例#9
0
文件: gl.go 项目: jackscan/go-gles2
func Enable(c Capability) {
	C.glEnable(C.GLenum(c))
}
示例#10
0
文件: es2.go 项目: nick-fedesna/egles
func Enable(cap int) { C.glEnable(C.GLenum(cap)) }