Wiki Page Content

Revision 3 as of 2010-08-04 01:34:02

Clear message

DRAFT

SDL_GL_SetAttribute

Use this function to set an OpenGL window attribute before window creation.

Syntax

int SDL_GL_SetAttribute(SDL_GLattr attr,
                        int        value)

Function Parameters

attr

the SDL_GLattr to be set

value

the desired value for the attribute

Return Value

Returns 0 on success or a negative error code * -1 * on failure; call SDL_GetError() for more information.

Code Examples

*

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if ( (screen=SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL )) == NULL ) {
    fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    SDL_Quit();
    return;
}


*

green

Remarks

*
This function sets the OpenGL attribute attr to value. The requested attributes will take effect after a call to SDL_SetVideoMode initializing the video driver. You should use SDL_GL_GetAttribute() to check the values after a call to SDL_SetVideoMode initializing the video driver, since the values obtained can differ from the requested ones.

Note: The SDL_DOUBLEBUF flag is not required to enable double buffering when setting an OpenGL video mode. Double buffering is enabled or disabled using the SDL_GL_DOUBLEBUFFER attribute.
*

green


CategoryAPI, CategoryVideo

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit