SDL_GL_SetAttribute

Name

SDL_GL_SetAttribute -- Set a special SDL/OpenGL attribute

Synopsis

uses
SDL;

function SDL_GL_SetAttribute( attr : TSDL_GLattr; value : Integer) : Integer;

Description

Sets the OpenGL attribute attr to value. The attributes you set don't take effect until after a call to SDL_SetVideoMode. You should use SDL_GL_GetAttribute to check the values after a SDL_SetVideoMode call.

Return Value

Returns 0 on success, or -1 on error.

Example

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 );
screen := SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL );
if ( screen = nil ) then
begin
MessageBox( 0, PChar( Format( 'Couldn''t set GL Mode : %s', [SDL_GetError] ) ), 'Error', MB_OK or MB_ICONHAND );
SDL_Quit;
exit;
end;

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.

See Also

SDL_GL_GetAttribute , GL Attributes