本文整理汇总了C++中SDL_GL_MakeCurrent函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GL_MakeCurrent函数的具体用法?C++ SDL_GL_MakeCurrent怎么用?C++ SDL_GL_MakeCurrent使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_GL_MakeCurrent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
// Set's up what our program will be using
void setup(Matrix &projectionMatrix, Matrix &viewMatrix, Matrix &modelMatrix){
SDL_Init(SDL_INIT_VIDEO);
displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 360, SDL_WINDOW_OPENGL);
SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
SDL_GL_MakeCurrent(displayWindow, context);
#ifdef _WINDOWS
glewInit();
#endif
}
示例2: GL_UpdateContext
/*
=================
GL_UpdateContext
=================
*/
qboolean GL_UpdateContext( void )
{
if(!( SDL_GL_MakeCurrent( host.hWnd, glw_state.context ) ) )
{
MsgDev(D_ERROR, "GL_UpdateContext: %s", SDL_GetError());
return GL_DeleteContext();
}
return true;
}
示例3: _PlatformCreateOpenGLContextCore
static void _PlatformCreateOpenGLContextCore(FPlatformOpenGLContext* OutContext)
{
check(OutContext);
SDL_HWindow PrevWindow = SDL_GL_GetCurrentWindow();
SDL_HGLContext PrevContext = SDL_GL_GetCurrentContext();
OutContext->hGLContext = SDL_GL_CreateContext(OutContext->hWnd);
SDL_GL_MakeCurrent(PrevWindow, PrevContext);
}
示例4: android_egl_context_backup
void
android_egl_context_backup()
{
/* Keep a copy of the EGL Context so we can try to restore it when we resume */
SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata;
data->egl_context = SDL_GL_GetCurrentContext();
/* We need to do this so the EGLSurface can be freed */
SDL_GL_MakeCurrent(Android_Window, NULL);
}
示例5: SDL_GL_MakeCurrent
void CGfxLibrary::PlatformEndDriver_OGL(void)
{
// shut the driver down
SDL_GL_MakeCurrent(NULL, NULL);
if (go_hglRC) {
SDL_GL_DeleteContext(go_hglRC);
go_hglRC = NULL;
}
}
示例6: SetupSDLWindow
internal b32 SetupSDLWindow(GameState * CurrentGameState)
{
if(CurrentGameState->ScreenWidth == 0)
{
CurrentGameState->ScreenWidth = DEFAULT_SCREEN_WIDTH;
}
if(CurrentGameState->ScreenHeight == 0)
{
CurrentGameState->ScreenHeight = DEFAULT_SCREEN_HEIGHT;
}
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 0 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
CurrentGameState->MainSDLWindow = SDL_CreateWindow("TA_SDL: SOMETHING HERE!!!", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,CurrentGameState->ScreenWidth, CurrentGameState->ScreenHeight, SDL_WINDOW_SHOWN|SDL_WINDOW_OPENGL);
if (!CurrentGameState->MainSDLWindow)
{
LogError("SDL_CreateWindow Error: %s", SDL_GetError());
return 0;
}
CurrentGameState->PerformanceCounterFrequency = SDL_GetPerformanceFrequency();
Assert(CurrentGameState->PerformanceCounterFrequency);
GLint GLMajorVer, GLMinorVer;
CurrentGameState->glContext = SDL_GL_CreateContext( CurrentGameState->MainSDLWindow);
SDL_GL_MakeCurrent (CurrentGameState->MainSDLWindow,CurrentGameState->glContext);
if( SDL_GL_SetSwapInterval( 1 ) < 0 )
{
LogWarning("Warning: Unable to set VSync! SDL Error: %s",SDL_GetError());
}
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVer);
glGetIntegerv(GL_MINOR_VERSION, &GLMinorVer);
GLenum ErrorValue = glGetError();
if(ErrorValue!=GL_NO_ERROR)
{
LogError("failed before glewInit : %s",gluErrorString(ErrorValue));
}
//as we need to use glewExperimental - known issue (it segfaults otherwise!) - we encounter
//another known issue, which is that while glewInit suceeds, it leaves opengl in an error state
ErrorValue = glGetError();
return 1;
}
示例7: SDL_Init
void ClassDemoApp::Setup() {
SDL_Init(SDL_INIT_VIDEO);
displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 360, SDL_WINDOW_OPENGL);
SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
SDL_GL_MakeCurrent(displayWindow, context);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifdef _WINDOWS
glewInit();
#endif
done = false;
srand((unsigned int)time(NULL));
program = new ShaderProgram(RESOURCE_FOLDER"vertex_textured.glsl", RESOURCE_FOLDER"fragment_textured.glsl");
// program = new ShaderProgram(RESOURCE_FOLDER"vertex.glsl", RESOURCE_FOLDER"fragment.glsl");
tileTexture = LoadTexture("sheet_4.png");
projectionMatrix.setOrthoProjection(-3.55f, 3.55f, -2.0f, 2.0f, -1.0f, 1.0f);
//SheetSprite sheet = SheetSprite(tileTexture, 14, 8);
for (int i = 0; i < LEVEL_HEIGHT; i++) {
for (int j = 0; j < LEVEL_WIDTH; j++) {
if (i == 0 || j == 0 || j == LEVEL_WIDTH - 1)
levelData[i][j] = 13;
else
levelData[i][j] = 254;
}
}
for (int k = 2; k < LEVEL_WIDTH - 5; ) {
for (int r = rand() % 3; r < 3; r++) {
int j = rand() % (LEVEL_HEIGHT - 4) + 3;
for (int i = rand() % 4; i < 6; i++) {
levelData[j][k + i] = 13;
if (i == 4 && (k + i) > LEVEL_WIDTH - 11) {
levelData[j - 1][k + i] = 64;
r = 3;
}
}
}
k += 7 + rand() % 3;
}
SheetSprite playerSprite = SheetSprite(LoadTexture("p2_spritesheet.png"), 1, 1);
player = new Entity(playerSprite);
entities.push_back(player);
player->width = 0.225f;
player->height = 0.3f;
player->x = TILE_SIZE * 6 + player->width / 2;
player->y = -TILE_SIZE * 2;
player->isStatic = false;
baseTouchX = 6;
}
示例8: SDL_GL_MakeCurrent
GHOST_TSuccess
GHOST_WindowSDL::activateDrawingContext()
{
if (m_sdl_glcontext != NULL) {
int status = SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext);
(void)status;
return GHOST_kSuccess;
}
return GHOST_kFailure;
}
示例9: sdl2_gl_make_context_current
int sdl2_gl_make_context_current(DisplayChangeListener *dcl,
QEMUGLContext ctx)
{
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
SDL_GLContext sdlctx = (SDL_GLContext)ctx;
assert(scon->opengl);
return SDL_GL_MakeCurrent(scon->real_window, sdlctx);
}
示例10: SDL_GL_MakeCurrent
bool Window::glMakeCurrent() noexcept
{
if ( m_wimpl->glcontext == nullptr )
{
lx::setError( "The current window is not an OpenGL window" );
return false;
}
return SDL_GL_MakeCurrent( m_wimpl->window, m_wimpl->glcontext ) == 0;
}
示例11: android_egl_context_restore
void
android_egl_context_restore()
{
SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata;
// Clockwork: make sure there is a valid stored context to restore
if (data->egl_context && SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context) < 0) {
// Clockwork: if the old context could not be restored, leave it to the Graphics subsystem to create a new one
data->egl_context = NULL;
}
}
示例12: SDL_Init
void PlatKillas::Init() {
SDL_Init(SDL_INIT_VIDEO);
displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL);
SDL_GLContext context = SDL_GL_CreateContext(displayWindow);
SDL_GL_MakeCurrent(displayWindow, context);
glViewport(0, 0, 800, 600);
glMatrixMode(GL_PROJECTION);
glOrtho(-1.33, 1.33, -1.0, 1.0, -1.0, 1.0);
}
示例13: SDL_GL_MakeCurrent
bool GraphicsWindowSDL2::releaseContextImplementation()
{
if(!mRealized)
{
OSG_WARN<< "Warning: GraphicsWindow not realized, cannot do releaseContext." <<std::endl;
return false;
}
return SDL_GL_MakeCurrent(NULL, NULL)==0;
}
示例14: SDL_GL_MakeCurrent
void SDLGraphicsOperations::makeOpenGLContextCurrent(os::OpenGLContext* ctx)
{
if (ctx == nullptr)
{
SDL_GL_MakeCurrent(os_get_window(), nullptr);
} else
{
reinterpret_cast<SDLOpenGLContext*>(ctx)->makeCurrent();
}
}
示例15: gl_set_video_mode
bool gl_set_video_mode(struct graphics_data *graphics, int width, int height,
int depth, bool fullscreen, bool resize)
{
struct sdl_render_data *render_data = graphics->render_data;
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_GLContext context;
render_data->window = SDL_CreateWindow("MegaZeux",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height,
GL_STRIP_FLAGS(sdl_flags(depth, fullscreen, resize)));
if(!render_data->window)
{
warn("Failed to create window: %s\n", SDL_GetError());
return false;
}
render_data->renderer =
SDL_CreateRenderer(render_data->window, -1, SDL_RENDERER_ACCELERATED);
if(!render_data->renderer)
{
warn("Failed to create renderer: %s\n", SDL_GetError());
return false;
}
context = SDL_GL_CreateContext(render_data->window);
if(!context)
{
warn("Failed to create context: %s\n", SDL_GetError());
return false;
}
if(SDL_GL_MakeCurrent(render_data->window, context))
{
warn("Failed to make context current: %s\n", SDL_GetError());
return false;
}
sdl_window_id = SDL_GetWindowID(render_data->window);
#else // !SDL_VERSION_ATLEAST(2,0,0)
if(!SDL_SetVideoMode(width, height, depth,
GL_STRIP_FLAGS(sdl_flags(depth, fullscreen, resize))))
return false;
#endif // !SDL_VERSION_ATLEAST(2,0,0)
render_data->screen = NULL;
render_data->shadow = NULL;
return true;
}