SDL 1.3 and OpenGL = Random garbage

First, many thanks to those who have helped me on here the past couple of days. Your help has been invaluable!

My issue is this: while the “gltest” that comes with SDL 1.3 runs just fine, my own program does not – it creates a window with garbage that does not update, even though I can verify in the debugger that the various gl functions are indeed being called. I decided then to try out this basic OpenGL test, posted on opengl.org:

http://www.opengl.org/wiki/Tutorial1:Creating_a_Cross_Platform_OpenGL_3.2_Context_in_SDL%28C_/_SDL%29

Turns out it has the same problem! I get a window with random garbage that doesn’t update/animate. (It should display red, wait 2 seconds, blue, wait 2 seconds, green, wait 2 and quit.) Instead I get random garbage, and then it quits after 6 seconds.

This is what happens even when pasting the code above directly into the “gltest.c” source file, compiling normally. (In other words, all project settings, including things being linked against, are exactly the same as for the normal SDL testgl program.)

Even this simple test above worked fine when I ran it on a Mac some months ago. Any help with what I’m not understanding about Windows that’s causing this to fail? Thanks again so much…

Fortunately this one should be easy to duplicate if you want to see if yourselves.

-Vern

Oh, and also:

I downloaded the gl3.h file on the tutorial’s webpage, and put it into:

C:\Program Files\Microsoft Visual Studio 10.0\VC\include\

as the tutorial instructed. I then modified:

#include <GL3/gl3.h>

to instead be:

#include <gl3.h>

I also modified in the source code:

void checkSDLError(int line = -1)

to be

void checkSDLError(int line)

Hey VernJensen, maybe this will help:

http://code.google.com/p/opengl-3x-tutorials-sdl/source/browse/common/sdlapp.hpp
http://code.google.com/p/opengl-3x-tutorials-sdl/source/browse/common/sdlapp.cpp

These are some C++ classes I wrote for OpenGL 3.x and above - maybe it will
help you out, I’m not sure.
Take care,
-AlexOn Wed, Nov 2, 2011 at 7:50 PM, VernJensen wrote:

**
Oh, and also:

I downloaded the gl3.h file on the tutorial’s webpage, and put it into:

C:\Program Files\Microsoft Visual Studio 10.0\VC\include\

as the tutorial instructed. I then modified:

#include **

to instead be:

#include **

I also modified in the source code:

void checkSDLError(int line = -1)

to be

void checkSDLError(int line)


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I figured out the problem with the tutorial. The SDL_GL_SetAttribute calls must be made after calling SDL_GL_CreateContext. Otherwise, the random garbage problem happens (at least on the current SDL 1.3 build). I’ve updated the tutorial so it works again.

I’m pretty sure that SDL_GL_SetAttribute needs to be before creating the
window and context, but maybe I’m wrong.
http://wiki.libsdl.org/moin.cgi/SDL_GL_SetAttribute?highlight=(\bCategoryVideo\b)|(CategoryEnum)|(CategoryStruct)
^ That seems to think it needs to be before the context too, so it may be
an SDL bug?
-AlexOn Thu, Nov 3, 2011 at 6:06 PM, VernJensen wrote:

**
I figured out the problem with the tutorial. The SDL_GL_SetAttribute calls
must be made after calling SDL_GL_CreateContext. Otherwise, the random
garbage problem happens (at least on the current SDL 1.3 build). I’ve
updated the tutorial so it works again.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

…and now my own program works as well. yeay!

I’m going to update the SDL 1.3 Documentation Wiki for SDL_GL_SetAttribute to mention that these must be called after a valid GL context has been created, otherwise they’ll wreak havoc!

Hmm, the documentation on the Wiki states the exact opposite. It says SDL_GL_SetAttribute should be called before window creation. Yet it’s following this that causes problems. I’ll report it as a bug.

I’m going to update the SDL 1.3 Documentation Wiki for
SDL_GL_SetAttribute to mention that these must be called after a valid
GL context has been created, otherwise they’ll wreak havoc!

No! OpenGL attributes must be set before the context is created. If you
set them afterwards, they won’t be used until the next context you
create, if any.

The random garbage is either a bug in SDL, or a bug in your code.
Presumably we have some sort of GL3 compatibility problem somewhere, if
this works when you don’t ask for a GL3 context before context creation.

–ryan.

Hmm, it’s a bug in SDL code then, because:

A) It happened with pretty simple code (not mine) available on opengl’s wiki, and

B) I’m pretty sure that it happened without the gl3 header being used, too. Simply calling those functions anytime before the context was set up made things not work.

Will submit an official bug report soon.

-Vern

Ryan C. Gordon wrote:>

I’m going to update the SDL 1.3 Documentation Wiki for
SDL_GL_SetAttribute to mention that these must be called after a valid
GL context has been created, otherwise they’ll wreak havoc!

No! OpenGL attributes must be set before the context is created. If you
set them afterwards, they won’t be used until the next context you
create, if any.

The random garbage is either a bug in SDL, or a bug in your code.
Presumably we have some sort of GL3 compatibility problem somewhere, if
this works when you don’t ask for a GL3 context before context creation.

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Bug submitted:

http://bugzilla.libsdl.org/show_bug.cgi?id=1323

A) It happened with pretty simple code (not mine) available on opengl’s
wiki, and

Well, to be fair, they got the SetAttribute thing wrong. :slight_smile:

–ryan.

Ryan C. Gordon wrote:

Well, to be fair, they got the SetAttribute thing wrong. :slight_smile:

If you’r referring to how the SetAttribute calls were after context creation, that was because I updated the tutorial (since it’s a wiki article) after I discovered that was what was required to make it work. However, I’ve changed it back to the way it was before (the calls are now before window creation).

To note, I’ve been making OpenGL 3.x and 4.x contexts without this random
garbage. I’m running Windows 7 32-bit, and have an AMD Radeon HD 6650M.
I suspect it’s more of a driver issue, but it may be something with SDL.
-AlexOn Fri, Nov 4, 2011 at 2:43 AM, VernJensen wrote:

**

Ryan C. Gordon wrote:

Well, to be fair, they got the SetAttribute thing wrong. [image: Smile]

If you’r referring to how the SetAttribute calls were after context
creation, that was because I updated the tutorial (since it’s a wiki
article) after I discovered that was what was required to make it work.
However, I’ve changed it back to the way it was before (the calls are now
before window creation).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Not really sure, but did you by any chance install the preview drivers for Rage?
I had to switch back to the latest stable version of AMD drivers because many programs stopped working.On 04.11.2011 15:01, Alex Barry wrote:

To note, I’ve been making OpenGL 3.x and 4.x contexts without this random
garbage. I’m running Windows 7 32-bit, and have an AMD Radeon HD 6650M.
I suspect it’s more of a driver issue, but it may be something with SDL.
-Alex

On Fri, Nov 4, 2011 at 2:43 AM, VernJensen wrote:

**

Ryan C. Gordon wrote:

Well, to be fair, they got the SetAttribute thing wrong. [image: Smile]

If you’r referring to how the SetAttribute calls were after context
creation, that was because I updated the tutorial (since it’s a wiki
article) after I discovered that was what was required to make it work.
However, I’ve changed it back to the way it was before (the calls are now
before window creation).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Christoph Harder wrote:> Not really sure, but did you by any chance install the preview drivers for Rage?

I had to switch back to the latest stable version of AMD drivers because many programs stopped working.

On 04.11.2011 15:01, Alex Barry wrote:

To note, I’ve been making OpenGL 3.x and 4.x contexts without this random
garbage. I’m running Windows 7 32-bit, and have an AMD Radeon HD 6650M.
I suspect it’s more of a driver issue, but it may be something with SDL.
-Alex

On Fri, Nov 4, 2011 at 2:43 AM, VernJensen<@VernJensen> wrote:

**

Nope. But this is a “Boot Camp” install on OS X, so maybe OS X has installed custom OpenGL drivers for the ATI card that’s in my iMac, I’m not sure.

Ryan C. Gordon wrote:

Well, to be fair, they got the SetAttribute thing wrong. [image: Smile]

If you’r referring to how the SetAttribute calls were after context
creation, that was because I updated the tutorial (since it’s a wiki
article) after I discovered that was what was required to make it work.
However, I’ve changed it back to the way it was before (the calls are now
before window creation).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Christoph Harder wrote:

Not really sure, but did you by any chance install the preview drivers for Rage?
I had to switch back to the latest stable version of AMD drivers because many programs stopped working.

Nope. But this is a “Boot Camp” install on OS X, so maybe OS X has installed custom OpenGL drivers for the ATI card that’s in my iMac, I’m not sure.

Nope. But this is a “Boot Camp” install on OS X, so maybe OS X has
installed custom OpenGL drivers for the ATI card that’s in my iMac, I’m
not sure.

Is it possible the Windows Boot Camp drivers don’t have GL3 support?

–ryan.

Ryan C. Gordon wrote:

Is it possible the Windows Boot Camp drivers don’t have GL3 support?

–ryan.

Well again, even without using hte gl3 headers, just calling the basic functions directly (including the normal gl headers), the same problem occurred. (I’m assuming including gl3.h is what you mean by GL3 support?)

The version of OpenGL reported on my system by OpenGL Extensions Viewer is 2.1. (for the shading language)

Hi,

sorry for asking something that has already been asked before, as I lost
track of the mail discussions.

Which Mac OS X version are you using? OpenGL 3 is only supported in Lion.–
Paulo

On Mon, Nov 7, 2011 at 5:02 PM, VernJensen wrote:

**

Ryan C. Gordon wrote:

Is it possible the Windows Boot Camp drivers don’t have GL3 support?

–ryan.

Well again, even without using hte gl3 headers, just calling the basic
functions directly (including the normal gl headers), the same problem
occurred. (I’m assuming including gl3.h is what you mean by GL3 support?)

The version of OpenGL reported on my system by OpenGL Extensions Viewer is
2.1. (for the shading language)


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Well again, even without using hte gl3 headers, just calling the basic
functions directly (including the normal gl headers), the same problem
occurred. (I’m assuming including gl3.h is what you mean by GL3 support?)

It has nothing to do with the headers; the whole discussion is about how
the thing fails to render if you ask for a GL3 context with
SDL_GL_SetAttribute(). I’m wondering if we’re failing to get one in SDL,
and handling that failing incorrectly.

–ryan.