![]() |
| | #1 |
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| SDL -- openGL -- video mode attributes Significance of exit() and now I am kind of curious about some things. SDL requires you to set the video mode. SDL_SetVideoMode(WIDTH, HEIGHT, BPP, flags); (And yes, I am error checking this.) When I used OGL with glut, there was no setting of video modes -- you just pick a window size, any window size, and away you go. So with my first couple of experiments using SDL (without GL), I just set WIDTH and HEIGHT to anything, or maybe the exact dimensions of my monitor if I was using SDL_FULLSCREEN. No problems. But with GL, if I set the video mode above 640x480, I run a significant chance of crashing the windowing system right after the program exits. Otherwise it seems to work (but I haven't done much yet). Working with example 2.8 from the SDL Guide, BPP in a GL setting is determined this way: Code: const SDL_VideoInfo *info = SDL_GetVideoInfo(); int BPP= info->vfmt->BitsPerPixel; Code: 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 );
I'm kind of familiar with GL's interface and AFAIK this is not part of it -- this is for SDL's interface to GL, I guess. Which makes it kind of crappy they can't be bothered to explain this better (or at all), since the docs seem decent otherwise, so far. The reason I'm asking is presumably the seg fault (which occurs in libglx.so, part of X windows) is because of this. I do not have a very good video card -- it's an onboard via chrome -- but with glut, the video mode or whatever always matched the window size. Now it seems I am stuck with a 640x480 window (or fullscreen in 640x480 mode) which sucks. I guess this won't make much difference to the design of the app itself, etc, since video modes are system dependent. But does anyone have any insight here, like
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge |
| MK27 is offline | |
| | #2 |
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| Grrr. Looks like that wasn't it either -- well, maybe it is a factor, but I finally got the SDL Guide's demo to do it, when not running fullscreen, and I really can't look beyond the documentation for a solution. So so much for SDL & portability. At one point after the crash, there was a faint repeated image of a giant X cursor down the left side of the text console. That cleared up when I restarted X. Maybe it's my hardware? I could not find any previous complaints about this specifically, though there are oodles of people who've reported SDL apps crashing on linux in some manner. I imagine if you weren't programming, this wouldn't be such a big deal since it does run fine, it just crashes X windows afterward. Back to glut or something...
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge |
| MK27 is offline | |
| | #3 |
| Hail to the king, baby. Join Date: Oct 2008 Location: Faroe Islands
Posts: 718
| your equation that equals 31, don't you have to add 1 to it to take the 'all switches off' factor? That is if it's in binary... Other than that I'm clueless about this, but I think I had the same problem with the resolution thingy when I tried SDL
__________________ Currently research OpenGL |
| Akkernight is offline | |
| | #4 |
| Registered User Join Date: Oct 2008
Posts: 983
| Hmm I have some experience with SDL + OpenGL programming and never had much problems. I've never seen those GL attributes being set though, so you might want to try without it. Also, please tell us exactly the values of the width, height, bpp and flags. You might want to try different values of bpp, see if it still crashes. Try 16 or 24 for instance. Also, do you call SDL_Init() before SDL_SetVideoMode()? If so, with what flags? Do you call SQL_Quit() when the program terminates? If not, in my experience, X will start using the new resolution without ever updating the window manager. So it would make it possible the window manager has a bug that causes it to crash if the resolution isn't restored. Though I probably prefer a crash to what I experience if I forget to call SDL_Quit() or the program crashes before it reaches that function. Really, I think it's clever to code everything in windowed mode until you actually need it full screen. |
| EVOEx is offline | |
| | #5 | ||
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| Quote:
![]() I posted at the OGL forum, if anyone has an answer, hopefully it's them. Maybe all that cross-platform compatibility was too much to ask for. Like, if I'm gonna make a game, I want my friends to be able to use it...but they're all MS users. I guess glut is portable too, but there's no integrated sound. Quote:
I'm not really sure what the windows equivalent of this is -- on linux the windowing system can crash and then you are in a plain text terminal (like "safe mode"), so you can get a backtrace of the fault, and restart the windowing system.
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge | ||
| MK27 is offline | |
| | #6 |
| Registered User Join Date: Aug 2003
Posts: 848
| Whenever i set those attributes i use the following: Code: 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_BUFFER_SIZE, 32); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); |
| Shakti is offline | |
| | #7 | |
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| Thanks for that Shaki, altho it does not seem to solve the problem. Do you know how these relate to the depth setting for SetVideoMode? Eg, if GL_DEPTH is 32, should it also be 32? The guide demo does not use the ALPHA attribute, which is strange because when I searched the rest of the guide, it is referred to in only one place, and Quote:
![]() [later]Ah, now SetVideoMode fails if I use your settings. The key seems to be GL_DEPTH_SIZE, which is limited to 16 on my crap video card (I guess). But bpp keeps coming out 32... Well, I'll keep going, we'll see. I don't like having to run in fullscreen all the time tho.
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge Last edited by MK27; 11-18-2009 at 09:32 AM. | |
| MK27 is offline | |
| | #8 |
| Registered User Join Date: Aug 2003
Posts: 848
| Here is my init-function for OpenGL under SDL: Code: 6 bool CSdlGlWin::InitGL(int x, int y, int bpp, unsigned int flags)
7 {
8 m_iWinX = x;
9 m_iWinY = y;
10 SDL_Init(SDL_INIT_VIDEO);
11 m_pSurface = SDL_SetVideoMode(x, y, bpp, flags | SDL_OPENGL);
12 if(m_pSurface == NULL)
13 return false;
14
15 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
16 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
17 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
18 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
19 SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
20 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
21 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); // 16 Bit depth-buffer
22
23 glViewport(0, 0, x, y);
24
25 glMatrixMode(GL_PROJECTION);
26 glLoadIdentity();
27 gluPerspective(45, ((float)x)/((float)y), 0.0f, 100.0f);
28
29
30 glMatrixMode(GL_MODELVIEW);
31 glLoadIdentity();
32
33 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
34 glClearDepth(1.0);
35 glDepthFunc(GL_ALWAYS);
36 glEnable(GL_DEPTH_TEST);
37 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
38
39 glShadeModel(GL_SMOOTH);
40
41 //glEnable(GL_CULL_FACE);
42 //glCullFace(GL_FRONT);
43
44 ilInit();
45
46 return true;
47 }
Code: app.InitGL(1280, 800, 32, SDL_HWSURFACE | SDL_FULLSCREEN); Last edited by Shakti; 11-18-2009 at 09:36 AM. |
| Shakti is offline | |
| | #9 |
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| Well, if it works, then don't fix it, but going by that line "While you can set most OpenGL attributes normally, the attributes list above* must be known before SDL sets the video mode", you shouldn't call SetVideoMode until after you set the GL attributes. You values "work" here if I set them after SetVideoMode is called. If I set them first, SetVideoMode fails unless I reduce DEPTH to 16. So this must have some significance (and maybe it is why people don't do it hahaha). Do you wanna try that and see? I am using the same bpp as you, which was returned by GetVideoInfo. ps. what OS are you using? * that list is: SDL_GL_RED_SIZE SDL_GL_GREEN_SIZE SDL_GL_BLUE_SIZE SDL_GL_ALPHA_SIZE SDL_GL_DOUBLEBUFFER SDL_GL_BUFFER_SIZE SDL_GL_DEPTH_SIZE SDL_GL_STENCIL_SIZE SDL_GL_ACCUM_RED_SIZE SDL_GL_ACCUM_GREEN_SIZE SDL_GL_ACCUM_BLUE_SIZE SDL_GL_ACCUM_ALPHA_SIZE
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge Last edited by MK27; 11-18-2009 at 09:46 AM. |
| MK27 is offline | |
| | #10 |
| Registered User Join Date: Aug 2003
Posts: 848
| My bad, when i changed bpp to 16 i didnt segfault any longer, but i never noticed that X crashed for me. How often does it crash if you do this? Last edited by Shakti; 11-18-2009 at 09:50 AM. |
| Shakti is offline | |
| | #11 | |
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| Quote:
I hate half-assed documentation. I've posted to the SDL forum about all this, presumably they will have something to say sooner or later.
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge | |
| MK27 is offline | |
| | #12 | |
| dat is, vast staat Join Date: Jul 2008 Location: SE Queens
Posts: 6,612
| Quote:
However, I presume it will, which is probably a particular problem here. X's libglx.so is I believe a module to drive the video card's GL capabilities, or emulate them if it isn't capable, which mine isn't (and yours is), so this is probably a significant factor. Hopefully I will be able to stick this out. If you are on linux too and don't have this problem, then I guess SDL GL is feasible. You know, I want everyone playing this game in the spring
__________________ C programming resources: GNU C Function and Macro Index -- glibc reference manual The C Book -- nice online learner guide Current ISO draft standard CCAN -- new CPAN like open source library repository GDB tutorial #1 -- gnu debugger tutorials -- GDB tutorial #2 cpwiki -- our wiki on sourceforge | |
| MK27 is offline | |
| | #13 |
| Registered User Join Date: Aug 2003
Posts: 848
| Yah at this point i would think that the video-card (and its driver) may be at fault rather than X itself, because i have never ever had this problem with OpenGL under SDL. |
| Shakti is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linking OpenGL in Dev-C++ | linkofazeroth | Game Programming | 4 | 09-13-2005 10:17 AM |
| OpenGL Window | Morgul | Game Programming | 1 | 05-15-2005 12:34 PM |
| OpenGL .dll vs video card dll | Silvercord | Game Programming | 14 | 02-12-2003 07:57 PM |
| OpenGL and Windows | sean345 | Game Programming | 5 | 06-24-2002 10:14 PM |
| opengl code not working | Unregistered | Windows Programming | 4 | 02-14-2002 10:01 PM |