Example #1
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 #2
0
func VideoInit(driver string, flags InitFlags) error {
	c_str := C.CString(driver)
	defer C.free(unsafe.Pointer(c_str))
	c_flags := C.Uint32(flags)
	ret := C.SDL_VideoInit(c_str, c_flags)
	if ret == 0 {
		return nil
	}
	return GetError()
}
Example #3
0
func VideoInit(driver string) error {
	cdriver := C.CString(driver)
	defer C.free(unsafe.Pointer(cdriver))

	if C.SDL_VideoInit(cdriver) != 0 {
		return getError()
	}

	return nil
}
Example #4
0
func VideoInit(driverName string) int {
	_driverName := C.CString(driverName)
	defer C.free(unsafe.Pointer(_driverName))
	return (int)(C.SDL_VideoInit(_driverName))
}
Example #5
0
// VideoInit (https://wiki.libsdl.org/SDL_VideoInit)
func VideoInit(driverName string) error {
	if C.SDL_VideoInit(C.CString(driverName)) != 0 {
		return GetError()
	}
	return nil
}
Example #6
0
func VideoInit(driverName string) int {
	return (int)(C.SDL_VideoInit(C.CString(driverName)))
}
Example #7
0
// Function prototypes
// These functions are used internally, and should not be used unless you
// have a specific need to specify the video driver you want to use.
// You should normally use SDL_Init() or SDL_InitSubSystem().
//
// SDL_VideoInit() initializes the video subsystem -- sets up a connection
// to the window manager, etc, and determines the current video mode and
// pixel format, but does not initialize a window or graphics mode.
// Note that event handling is activated by this routine.
//
// If you use both sound and video in your application, you need to call
// SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
// you won't be able to set full-screen display modes.
func VideoInit(driver string, flags uint32) int {
	cdrv := cstr(driver)
	return int(C.SDL_VideoInit(cdrv, C.Uint32(flags)))
}