PDA

View Full Version : MultiSampling in SDL



Pswin
01-22-2008, 10:01 AM
hi
how can i use multisampling in the SDL?


i'm trying to use SDL_GL_SetAttribute but i can do it :( please help me with an example source code( for SDL)

-NiCo-
01-22-2008, 11:01 AM
hi
i'm trying to use SDL_GL_SetAttribute but i can do it :(

What's the problem if you can do it? ;)



if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);

SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

if ( SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL ) {
fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}



N.

Groovounet
01-22-2008, 04:33 PM
Don't forget to use glEnable(GL_MULTISAMPLE) ^_^

Pswin
01-23-2008, 09:17 AM
can i change video mode at runtime or enable/disable multisampling at runtime

V-man
01-23-2008, 09:25 AM
With certain drivers, even when you call glDisable(GL_MULTISAMPLE) it doesn't disabled it. Actually, I haven't tried this in a long time.

-NiCo-
01-23-2008, 10:36 AM
With certain drivers, even when you call glDisable(GL_MULTISAMPLE) it doesn't disabled it. Actually, I haven't tried this in a long time.

Indeed, on my GF 7600 GO disabling multisampling only works when using 4 samples or less. I 'solved' this issue by using framebuffer objects. I write to either a multisampled or singlesampled window and use framebuffer blitting to transfer the result to the singlesampled main window.

N.