FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL + OPENGL + Antialiasing

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
scooterman



Joined: 06 Feb 2007
Posts: 10

PostPosted: Sat Sep 22, 2007 12:03 pm    Post subject: SDL + OPENGL + Antialiasing Reply with quote

Hi again, I'm trying to add antialiasing support to my app, and by the SDL doc I should do this before initialize my screen:

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16);

But, when I try to run it, I'm receiving this error:
{}, You must create an OpenGL context before attempting to load OpenGL extension

So, how I'm supposed to load my extensions if the context will be initialized only with SDL_SetVideoMode?

Thanks,
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sat Sep 22, 2007 3:20 pm    Post subject: Reply with quote

That exception is thrown from DerelictGL.loadExtensions(). That tells me that you are calling it before you call SDL_SetVideoMode. Don't Smile
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
scooterman



Joined: 06 Feb 2007
Posts: 10

PostPosted: Sun Sep 23, 2007 9:25 am    Post subject: Reply with quote

Here is my init code:


DerelictSDL.load();
SDL_Init(SDL_INIT_VIDEO);

DerelictGL.load();

SDL_EnableUNICODE(1);

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16);

if (GameSystem.Fullscreen)
m_screen = SDL_SetVideoMode(GameSystem.ScreenWidth, GameSystem.ScreenHeight, 32, SDL_OPENGL | SDL_FULLSCREEN);
else
m_screen = SDL_SetVideoMode(GameSystem.ScreenWidth, GameSystem.ScreenHeight, 32, SDL_OPENGL);

DerelictGL.loadExtensions();

int Buffers;
int Samples;
glGetIntegerv( GL_SAMPLE_BUFFERS_ARB, & Buffers ) ;
glGetIntegerv( GL_SAMPLES_ARB, & Samples );

Stdout.formatln("{} {}",Samples, Buffers);




And I've just confirmed that it works on my windows box, but gives that error on my linux box, on the SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16) line.

Strange.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Sep 23, 2007 10:53 pm    Post subject: Reply with quote

It's impossible for you to get the message you're seeing from a call to SDL_GL_SetAttribute, because the message is part of an Exception thrown by DerelictGL.loadExtensions when it finds that no valid OpenGL context exists.

You aren't doing any error checking on the pointer returned by SDL_SetVideoMode. If that call is failing, which it very well could be, then that would mean that no OGL context is being created, yet the loadExtensions call is still being executing because you aren't aborting on the failure. I'm willing to bet that's exactly what's happening.

So try testing the return value of SDL_SetVideoMode against null:

Code:

if(m_screen is null)
{
    //  report failure and abort
}


If it is failing, that probably means that the OGL drivers on your Linux box (or partition, or whatever) don't support multisample buffers.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group