SDL and OpenGL

Hello!

I am having a little problem with SDL and OpenGL. My desktop is in
1024x768x32bpp and I try to make my app run in full screen with 32bpp. The
problem is that it changes to some 64bit accumulation buffer which slows
down my aplication by 30% beacuse the driver cannot do hardware aceleration
on the accumulation buffer. I do not even use Accum buffer. When my
application was written in glut or Win32 api I had 30% more FPS with the
same settings I have now in SDL - and the only change is the accumulation
buffer reported. This is how I do it

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_STENCIL_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

flags = SDL_OPENGL | SDL_FULLSCREEN;

SDL_SetVideoMode((int)Render->graphicSettings.screenX,(int)Render->graphicSe
ttings.screenY,
0,flags);

I even tried to set all SDL_GL_ACCUM_* to 8 or 5551 and it still gives me 16
for everything. I know this because I execute a SDL_GL_GetAttribute on
everything after I set the video mode.

Now when I run in 16bpp I ask again for 0 accum but then it works (of course
I get only 16depth and 0 stencil which is the right way).

My card is Geforce2 MX and I run on Win32. I will give it a try in linux see
if I experince the same. I run with SDL 1.2.0

Anybody any idea on this?

Thanks in advance,
Vlad.

Hi,

I’ve written this OpenGL program (actually i’m reading the GL redbook,
and this is the first example), but i don’t think it’s exiting properly
(w/ my voodoo3, windowed OpenGL programs brighten my whole screen (like
xgamma -g 1.25 or something) and usually when a program exits my gamma
goes back to normal, but not w/ this program. Could someone tell me
what i’m doing wrong? I’ll attach the source (it’s very short).

Thanks,
Cameron Matheson

PS it’s named glutrectangle because the example in the book uses GLUT
and i was using that initially too.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: glutrectangle.cc
Type: text/x-c++src
Size: 1359 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021022/173f04cd/attachment.cc

since voodoo is no more, their drivers are really bad. I had lots of
problems with writing gl programs with my voodoo3 and thought it was SDL or
something i was doing wrong for the longest time. Then i got a geforce 4 ti
4600 and the problems disapeared (:

it might still be something in your code, but if you get limited info back
you might wanna consider getting a diff video card cause your code that
works on your computer may not work on others and visa versa.> ----- Original Message -----

From: cmatheson3@hotpop.com (Cameron Matheson)
To:
Sent: Tuesday, October 22, 2002 9:46 PM
Subject: [SDL] SDL and OpenGL

Hi,

I’ve written this OpenGL program (actually i’m reading the GL redbook,
and this is the first example), but i don’t think it’s exiting properly
(w/ my voodoo3, windowed OpenGL programs brighten my whole screen (like
xgamma -g 1.25 or something) and usually when a program exits my gamma
goes back to normal, but not w/ this program. Could someone tell me
what i’m doing wrong? I’ll attach the source (it’s very short).

Thanks,
Cameron Matheson

PS it’s named glutrectangle because the example in the book uses GLUT
and i was using that initially too.



//glutrectangle.cc

//Cameron Matheson
//cmatheson3 at hotpop.com

#include <GL/gl.h>
#include <SDL/SDL.h>
#include <stdlib.h>

void init();
void display();

int main(int argc, char **argv)
{
SDL_Surface *screen;

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf(“Error initializing SDL: %s\n”, SDL_GetError());
exit(1);
}
SDL_Init(SDL_INIT_VIDEO);

atexit(SDL_Quit);

screen = SDL_SetVideoMode(300, 300, 0, SDL_HWSURFACE | SDL_OPENGLBLIT);
if (screen == NULL) {
printf(“Error setting video mode: %s”, SDL_GetError());
exit(2);
}

init();
display();

bool done = false;
SDL_Event event;
while (done == false)
while (SDL_PollEvent(&event))
if (event.type == SDL_KEYDOWN)
done = true;

SDL_Quit();
return 0;
}

//function to initialize window/gl/etc.
void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);

//viewing mode
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

//function to display the rectangle
void display()
{
glClear(GL_COLOR_BUFFER_BIT); //clear the window
glColor3f(1.0, 1.0, 1.0); //draw w/ white

glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();

glFlush(); //don’t wait in any queues or anything
SDL_GL_SwapBuffers();
}

if you link with SDLmain, I suggest
no to use SDL_Quit neither atexit(SDL_Quit)
because they’re called automatiquely by SDLmain module

actually, SDLmain module call even SDL_Init, but
with NO_PARACHUTE argument only. So we can call SDL_InitSubSystem
safely and at the end of the program do return come_error_code.

but it is safer to have a sentinel, for example a variable
remembering if we quit safely: we does it like this:

int safe_exit;

int main(…) {

safe_exit = 0;
atexit(func_cleaner);
SDL_InitSubSystem(SDL_INIT_VIDEO);

// … your code

safe_exit = 1;
return 0;
}

void func_cleaner() {
if (!safe_exit) SDL_Quit();
}

I hope it can help. Look at the SDL reference, too.

Sylvain

I am a C++ programmer. I just finished learning how to use SDL. Now I want to
incorperate OpenGL 3d graphics into SDL 2d graphics. Is there any good
tutorials? If there isn’t, is there any good tutorials for Direct3D? They
must be C++ tutorials, not Win32.

Thanks,
Theron

El jue, 15-09-2005 a las 22:52, Theron Luhn escribi?:

I am a C++ programmer. I just finished learning how to use SDL. Now I want to
incorperate OpenGL 3d graphics into SDL 2d graphics. Is there any good
tutorials? If there isn’t, is there any good tutorials for Direct3D? They
must be C++ tutorials, not Win32.
nehe.gamedev.net?
Even a terrible stupid in graphics programming like me can understand
Open GL with NeHe tutorials.–
Roger D. Vargas
Linux user #180787
dsgp.blogspot.com

  • No hay nada tan importante que no pueda ser olvidado *
    Alzheimer

nehe.gamedev.net?
Even a terrible stupid in graphics programming like me can understand
Open GL with NeHe tutorials.

They very good tutorials. However, do yourself a favor and download the
source files that were adapted for SDL by Sam Lantinga, found on the
libdsl.org webpage in the OpenGL section. I had a devil of a time trying to
get things to work at first with OpenGL, since Nehe’s tutorials assume you
are using Windows, and the setup routine to get things going is a bit
different - and of course, easier with SDL… :slight_smile:
After you get the idea of how to establish an OpenGL window, Nehe’s tuts are
really great. And the SDL versions of the code by Sam will help clarify some
things like how to load BMP, and how to use that to put textures on your 3D
objects, etc…
-Dave_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello !

I just tested SDL CVS and on my
system and OpenGL is not working.
I tried testgl and testdyngl,
both open a window and then exit immdiately.

config.log says yes OpenGL and Open WGL available.

CU

To use openGL with SDL do i need to configure my computer and ide as to
using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio alredy are
’prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths stuff”(
on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.

As far as I know, you won’t need to do anything to your IDE if you
have it set up for SDL already. It should be set up to find the
headers and libs.

The only thing you’ll need to do is add opengl32.lib to your project’s
list of libraries (alongside SDL.lib and SDLmain.lib).

http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL
This tutorial seems reasonable, but I would skip textures for now and
just get the window opening, screen clearing (glClear) and buffers
swapping (SDL_GL_SwapBuffers).

(OpenGL tutorials really should teach error checking before texturing,
as many people get tripped up by passing bad parameters into the
texturing functions.)

If you’ve not done so already, I would have a quick read of the first
few chapters in the Red Book:
http://fly.srk.fer.hr/~unreal/theredbook/

Hope this helps,
Peter

2008/10/9 Giuliano Pieta :> To use openGL with SDL do i need to configure my computer and ide as to

using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio alredy are
’prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths stuff”(
on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.


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

Hi,

you only have to ensure that your OpenGL drivers are up to date.

If you have a NVidia or ATI card, having the correct drivers should suffice.

On Windows you just have to ensure that the OpenGL import libraries are part
of the linker configuration.

You need at least OpenGL32.lib.

Sorry I cannot explain better, at work I don’t have a working VC++
installation.–
Paulo

On Thu, Oct 9, 2008 at 3:49 PM, Giuliano Pieta wrote:

To use openGL with SDL do i need to configure my computer and ide as to
using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio alredy are
’prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths stuff”(
on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.


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

My video card is a SiS 300/305 32 MB
-__- worst card ever
But in my mind i figure out something like: if i run games like gta 3,
stronghold, hitman, max payne,so im ok with OpenGL…Am I stupid? o.o

2008/10/9 Paulo Pinto > Hi,

you only have to ensure that your OpenGL drivers are up to date.

If you have a NVidia or ATI card, having the correct drivers should
suffice.

On Windows you just have to ensure that the OpenGL import libraries are
part of the linker configuration.

You need at least OpenGL32.lib.

Sorry I cannot explain better, at work I don’t have a working VC++
installation.


Paulo

On Thu, Oct 9, 2008 at 3:49 PM, Giuliano Pieta <@Giuliano_Pieta> wrote:

To use openGL with SDL do i need to configure my computer and ide as to
using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio alredy
are ‘prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths stuff”(
on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.


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

Hi,

those games use DirectX. It may be that your manufacter is only supporting
DX and not OpenGL.

You should install a OpenGL capabilities tester like:

http://downloads.guru3d.com/download.php?det=1584

And see what your card is capable of.–
Paulo

On Thu, Oct 9, 2008 at 4:38 PM, Giuliano Pieta wrote:

My video card is a SiS 300/305 32 MB
-__- worst card ever
But in my mind i figure out something like: if i run games like gta 3,
stronghold, hitman, max payne,so im ok with OpenGL…Am I stupid? o.o

2008/10/9 Paulo Pinto <@Paulo_Pinto>

Hi,

you only have to ensure that your OpenGL drivers are up to date.

If you have a NVidia or ATI card, having the correct drivers should
suffice.

On Windows you just have to ensure that the OpenGL import libraries are
part of the linker configuration.

You need at least OpenGL32.lib.

Sorry I cannot explain better, at work I don’t have a working VC++
installation.


Paulo

On Thu, Oct 9, 2008 at 3:49 PM, Giuliano Pieta wrote:

To use openGL with SDL do i need to configure my computer and ide as to
using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio alredy
are ‘prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths
stuff”( on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.


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

I downloaded the OpenGL Extensions Viewer, its a program lique dxdiag but
for opengl
In the rendering tests i can run test 1.1, 1.2 and 1.3,
1.4, 1.5, 2.0 and 2.1 doesnt work, but i think thats not important…

2008/10/9 Giuliano Pieta <@Giuliano_Pieta>> So…?

Anexing other print

2008/10/9 Paulo Pinto

Hi,

those games use DirectX. It may be that your manufacter is only supporting
DX and not OpenGL.

You should install a OpenGL capabilities tester like:

http://downloads.guru3d.com/download.php?det=1584

And see what your card is capable of.


Paulo

On Thu, Oct 9, 2008 at 4:38 PM, Giuliano Pieta <@Giuliano_Pieta>wrote:

My video card is a SiS 300/305 32 MB
-__- worst card ever
But in my mind i figure out something like: if i run games like gta 3,
stronghold, hitman, max payne,so im ok with OpenGL…Am I stupid? o.o

2008/10/9 Paulo Pinto

Hi,

you only have to ensure that your OpenGL drivers are up to date.

If you have a NVidia or ATI card, having the correct drivers should
suffice.

On Windows you just have to ensure that the OpenGL import libraries are
part of the linker configuration.

You need at least OpenGL32.lib.

Sorry I cannot explain better, at work I don’t have a working VC++
installation.


Paulo

On Thu, Oct 9, 2008 at 3:49 PM, Giuliano Pieta <@Giuliano_Pieta>wrote:

To use openGL with SDL do i need to configure my computer and ide as to
using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio alredy
are ‘prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths
stuff”( on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.


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


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

Sorry flooding the list
I compiled a tutorial from video tutorials rock
i just noticed the code works( it just open a windows and show 3 forms, i
suppose it dont do anything else), but when it exits it shows the same
"windows has triggered" message…
heres the output:
*HEAP[Open GL Teste1.exe]: Invalid Address specified to RtlFreeHeap( 130000,
15bfc0 )
Windows has triggered a breakpoint in Open GL Teste1.exe.

This may be due to a corruption of the heap, and indicates a bug in Open GL
Teste1.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
The program ‘[1288] Open GL Teste1.exe: Native’ has exited with code 0
(0x0).*

Now im really worring about it, thats mean i cant program opengl cause my
computer just doesnt suport it? is it possible?

2008/10/9 Giuliano Pieta <@Giuliano_Pieta>> I downloaded the OpenGL Extensions Viewer, its a program lique dxdiag but

for opengl
In the rendering tests i can run test 1.1, 1.2 and 1.3,
1.4, 1.5, 2.0 and 2.1 doesnt work, but i think thats not important…

2008/10/9 Giuliano Pieta <@Giuliano_Pieta>

So…?

Anexing other print

2008/10/9 Paulo Pinto

Hi,

those games use DirectX. It may be that your manufacter is only
supporting DX and not OpenGL.

You should install a OpenGL capabilities tester like:

http://downloads.guru3d.com/download.php?det=1584

And see what your card is capable of.


Paulo

On Thu, Oct 9, 2008 at 4:38 PM, Giuliano Pieta <@Giuliano_Pieta>wrote:

My video card is a SiS 300/305 32 MB
-__- worst card ever
But in my mind i figure out something like: if i run games like gta 3,
stronghold, hitman, max payne,so im ok with OpenGL…Am I stupid? o.o

2008/10/9 Paulo Pinto

Hi,

you only have to ensure that your OpenGL drivers are up to date.

If you have a NVidia or ATI card, having the correct drivers should
suffice.

On Windows you just have to ensure that the OpenGL import libraries are
part of the linker configuration.

You need at least OpenGL32.lib.

Sorry I cannot explain better, at work I don’t have a working VC++
installation.


Paulo

On Thu, Oct 9, 2008 at 3:49 PM, Giuliano Pieta <@Giuliano_Pieta>wrote:

To use openGL with SDL do i need to configure my computer and ide as
to using “stand alone” opengl?

Im dont know what to do to start using open gl, all tutorials seems
different from each other…Do i need to download some opengl libs?
some tutorials say yes, but other says windows and visual studio
alredy are ‘prepared’ to it…

i also saw a video tutorial that the guy do a lot of “adding paths
stuff”( on windows, and on visual studio )
its like everyone found a different way to use open gl, im lost.


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


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