Example #1
0
func Clear(mask Enum) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.Clear(%v) %v", mask, errstr)
	}()
	C.glClear(C.GLbitfield(mask))
}
Example #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")

}
Example #3
0
func Write0() {
	//
	if !initialized {
		initialize()
	}
	if !scr.UnderX() {
		ker.Stop(pack, 1)
	}
	C.glMatrixMode(C.GL_MODELVIEW)
	C.glLoadIdentity()
	for i := 0; i < 3; i++ {
		matrix[i][0] = C.GLdouble(right[i])
		matrix[i][1] = C.GLdouble(top[i])
		matrix[i][2] = C.GLdouble(-front[i])
	}
	C.glMultMatrixd(&matrix[0][0])
	C.glTranslated(C.GLdouble(-eye[0]), C.GLdouble(-eye[1]), C.GLdouble(-eye[2]))
	C.glClear(C.GL_COLOR_BUFFER_BIT + C.GL_DEPTH_BUFFER_BIT)
	for n := uint(0); n < MaxL; n++ {
		if lightInitialized[n] {
			ActualizeLight(n)
		}
	}
	C.glBegin(POINTS)
	nn = 0
}
Example #4
0
func BeginFrame(width, height int, devicePixelRatio float32) {
	w := C.GLsizei(float32(width) * devicePixelRatio)
	h := C.GLsizei(float32(height) * devicePixelRatio)
	C.glViewport(0, 0, w, h)
	C.glClearColor(0, 0, 0, 1)
	C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT | C.GL_STENCIL_BUFFER_BIT)
	C.nvgBeginFrame(vg, C.int(width), C.int(height), C.float(devicePixelRatio))
}
Example #5
0
func (game *game) drawFrame() {
	time += .05
	color := (C.GLclampf(math.Sin(time)) + 1) * .5

	C.glUniform2f(C.GLint(game.offsetUni), C.GLfloat(game.offsetX), C.GLfloat(game.offsetY))
	C.glUniform3f(C.GLint(game.colorUni), 1.0, C.GLfloat(color), 0)
	C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT)

	C.glUseProgram(game.prog)
	C.glDrawArrays(C.GL_TRIANGLES, 0, 3)
}
Example #6
0
func Clear(mask Enum) {
	C.glClear(C.GLbitfield(mask))
}
Example #7
0
func Clear(
	mask Bitfield) {
	C.glClear(
		C.GLbitfield(mask))

}
Example #8
0
File: gl.go Project: extrame/gl
// Clear calls glClear
func Clear(mask int) {
	C.glClear(C.GLbitfield(mask))
}
Example #9
0
func Test(win window.Window) {
	C.glClearColor(1.0, 0.0, 0.0, 0.0)
	C.glClear(C.GL_COLOR_BUFFER_BIT | C.GL_DEPTH_BUFFER_BIT | C.GL_STENCIL_BUFFER_BIT)
	win.SwapBuffers()
}
Example #10
0
func Clear(mask bitField) {
	C.glClear((C.GLbitfield)(mask))
}
Example #11
0
File: gl.go Project: eaburns/gl
// Clear clears buffers to preset values.
func Clear(bits ClearFlags) {
	C.glClear(C.GLbitfield(bits))
}