当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_GL_MakeCurrent函数代码示例

本文整理汇总了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
}
开发者ID:LeviMollison,项目名称:GameProgramming,代码行数:10,代码来源:main.cpp

示例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;
}
开发者ID:THE-Swank,项目名称:xash3d,代码行数:14,代码来源:gl_sdl_static.c

示例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);
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:9,代码来源:OpenGLShaderCompiler.cpp

示例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);
}
开发者ID:dragonCASTjosh,项目名称:Clockwork,代码行数:9,代码来源:SDL_androidevents.c

示例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;
  }
}
开发者ID:DrItanium,项目名称:Serious-Engine,代码行数:9,代码来源:SDLOpenGL.cpp

示例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;
}
开发者ID:Christof-Sigel,项目名称:TA_SDL,代码行数:56,代码来源:sdl.cpp

示例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;
}
开发者ID:kt1235,项目名称:kt1235_Game_Programming,代码行数:56,代码来源:ClassDemoApp.cpp

示例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;
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:10,代码来源:GHOST_WindowSDL.cpp

示例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);
}
开发者ID:dota1923,项目名称:qemu,代码行数:10,代码来源:sdl2-gl.c

示例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;
}
开发者ID:Gumichan01,项目名称:lunatix-engine,代码行数:10,代码来源:Window.cpp

示例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;
    }
}
开发者ID:dragonCASTjosh,项目名称:Clockwork,代码行数:10,代码来源:SDL_androidevents.c

示例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);
}
开发者ID:minhtritran,项目名称:cs3113-hw,代码行数:10,代码来源:PlatKillas.cpp

示例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;
}
开发者ID:ChairGraveyard,项目名称:TES3MP,代码行数:10,代码来源:sdlgraphicswindow.cpp

示例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();
	}
}
开发者ID:Kobrar,项目名称:fs2open.github.com,代码行数:10,代码来源:SDLGraphicsOperations.cpp

示例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;
}
开发者ID:nooodl,项目名称:megazeux,代码行数:55,代码来源:render_sdl.c


注:本文中的SDL_GL_MakeCurrent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。