PDA

View Full Version : SDL GL vs. dglOpenGL



andygfx
20-08-2007, 06:09 PM
If i call:


procedure TF3D_TextureFactory.BindTextureToLayer(id: integer; target: integer);
begin

glActiveTextureARB(GL_TEXTURE0 + target);
glEnable(GL_TEXTURE_2D);
glBindTexture(texture_list[id].GLtarget, texture_list[id].Texture);

end;

with SDL OpenGL, program crash, but with dglOpenGL and no SDL work cool. What is problem?

vgo
20-08-2007, 06:24 PM
Are you sure that you did a complete rebuild for your project? I use both SDL GL and dglOpenGL and sometimes I forget to do a complete rebuild when switching between these two and get some nasty crashes.

andygfx
20-08-2007, 06:38 PM
Actualy i use only SDL opengl like gl,glu,glext from JEDI-SDL, and i always clean compiler data. I use CodeGear Win32 on Vista x64.

Other stange thing is i.e. if i call

glGetIntegerv(GL_MAX_TEXTURE_UNITS, @MAX_TEXTURE_UNITS);

result is 0.

M109uk
20-08-2007, 08:05 PM
I had that exact problem with SDL and dglOpenGL when i wanted to use some of the extensions, i know use SDL with dglOpenGL and it seems to work fine.

Im not sure why but when ever i used the GL units that come with SDL, none of the extensions get loaded, not sure if you need to load them seperatly or not.

If your intrested i can give you the source to my engine screen?

vgo
20-08-2007, 08:11 PM
Indeed, you have to manually load all extensions if you use the SDL GL headers, dglOpenGL does this automatically.


const
MAX_EXTENSION = 1;
Extensions: array [0..MAX_EXTENSION] of String = (
'GL_ARB_multitexture',
'xxx'
);


for i := 0 to MAX_EXTENSION do
if glext_ExtensionSupported(PChar(Extensions[i]), #0) then
glext_LoadExtension(Extensions[i])
else
s := Extensions[i] + #13#10;
if s <> '' then
raise EOpenGLError('All needed OpenGL extensions are not supported! Unsupported extensions: ' + #13#10 + s);


That's what I seem to have in my OpenGL initialization when using SDL.

andygfx
20-08-2007, 08:18 PM
Exist any function for automatic load all possible extensions? Because write now LIST OF ALL EXT are crazy for me. :)

vgo
20-08-2007, 08:26 PM
Maybe if you load extensions GL_version_1_4, GL_version_1_5, GL_version_2_0 and so on, in theory those should include everything?

andygfx
20-08-2007, 08:34 PM
Maybe if you load extensions GL_version_1_4, GL_version_1_5, GL_version_2_0 and so on, in theory those should include everything?

Yes. I tried this, but don't work for all EXT.

I have sollution:

create GL_EXT.list file as stringlist like this:


glext.Load_GL_ARB_multitexture();
glext.Load_GL_version_1_2();
glext.Load_GL_version_1_3();
glext.Load_GL_version_1_4();
glext.Load_GL_version_1_5();
glext.Load_GL_version_2_0();

...

an then after SDL init i include it via:

{$I GL_EXT.list}


Now i tested and work cool ;) Will be implemented in my engine ver. 0.05.

technomage
21-08-2007, 08:13 AM
You just need to call

Load_GL_Version_x_x

after creating the SDL window.

Don't forget to also call


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); // 24 or 32 bit buffer
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); // 24 bit z buffer
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if createStencilBuffer then
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); // 8 bit stencil buffer


BEFORE you call SDL_SetVideoMode to setup opengl correctly. look at
http://www.cerebral-bicycle.co.uk/viewdoc.asp?doc=307&date=Y for more info.

andygfx
21-08-2007, 09:16 AM
thx