View previous topic :: View next topic |
Author |
Message |
Nrgyzer
Joined: 12 Dec 2009 Posts: 31
|
Posted: Sat Jun 11, 2011 1:31 am Post subject: How to load max available version |
|
|
Hey there,
how can I load the max available version of OGL? My current code looks like:
Code: | DerelictGL.load();
DerelictSDL.load();
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);
GLVersion ver = DerelictGL.loadModernVersions(GLVersion.HighestSupported);
writeln(ver);
DerelictGL.unload();
DerelictSDL.unload(); |
When I start my app, it always says "derelict.util.exception.DerelictException@derelict\util\exception.d(43): Required GL version OpenGL Version 4.0 is not available."
How can I load the latest available version of OGL? OpenGL Extensions Viewer says that the latest available version on my system is 3.1, why does it try to load OGL 4.0?
... Thanks |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Sat Jun 11, 2011 6:28 am Post subject: |
|
|
If you pass GLVersion.HighestSupported to loadModernVersions, then what you are saying is that your application absolutely requires that version and the method should throw an exception if it is not available. On the other hand, if you pass GLVersion.GL30, it will load version 3.0 and whatever higher versions are available, only throwing an exception if 3.0 is unavailable. Actually, I see I need to modify the source to make that the default value so that it can be called with no args.
Additionally, you ought to call loadClassicVersions, otherwise older functions won't be available. This won't cause loadModernVersions to fail if you don't call it, but your program will crash when you try to call something like glClear.
Code: |
DerelictGL.load();
DerelictSDL.load();
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);
// Require the maximum classic version be loaded (GLVersion.GL21
// or GLVersion.MaxClassic)
DerelictGL.loadClassicVersions(GLVersion.MaxClassic);
// Require at least GLVersion.GL30 -- if you have higher, it will
// be loaded as well.
GLVersion ver = DerelictGL.loadModernVersions(GLVersion.GL30);
writeln(ver);
|
See dgl.d in Derelict2's root directory. It's a little test module I use when I update DerelictGL to make sure it loads properly. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
Nrgyzer
Joined: 12 Dec 2009 Posts: 31
|
Posted: Sat Jun 11, 2011 7:42 am Post subject: |
|
|
I need to load at least OGL 1.5... so I tried to load it by using loadModernVersions:
Code: | GLVersion ver = DerelictGL.loadModernVersions(GLVersion.GL15);
writeln(ver) |
This prints 11 (OGL 1.1) is loaded... but when I use
Code: | GLVersion ver = DerelictGL.loadClassicVersions(GLVersion.GL15);
writeln(ver) |
it prints 21 (OGL 2.1) which seems to be the latest available version on my computer (GLViewer says 3.1), but okay... 2.1 is enought. But why does loadModernVersion() do not load at least OGL 2.1 and loadClassicVersions load it? |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Sat Jun 11, 2011 12:12 pm Post subject: |
|
|
Nrgyzer wrote: | I need to load at least OGL 1.5... so I tried to load it by using loadModernVersions:
Code: | GLVersion ver = DerelictGL.loadModernVersions(GLVersion.GL15);
writeln(ver) |
This prints 11 (OGL 1.1) is loaded... but when I use
Code: | GLVersion ver = DerelictGL.loadClassicVersions(GLVersion.GL15);
writeln(ver) |
it prints 21 (OGL 2.1) which seems to be the latest available version on my computer (GLViewer says 3.1), but okay... 2.1 is enought. But why does loadModernVersion() do not load at least OGL 2.1 and loadClassicVersions load it? |
You're misunderstanding what the different methods do. loadClassicVersions loads versions 1.1 to 2.1. It does not load anything higher, no matter what your graphics card supports. loadModernVersions loads 3.0 and higher. It does not load anything below 3.0. So if you require version 1.5, then you should do this:
Code: |
DerelictGL.loadClassicVersions(GLVersion.GL15);
|
This means that if anything between 1.1 and 1.5 fails to load, an exception will be thrown. However, anything above 1.5 that the driver supports up to 2.1 will be loaded as well with no exceptions on failure. For OpenGL 1.5, you do not need to call loadModernVersions at all.
So if you need support for <= 2.1, you call loadClassicVersions. If you need support for >= 3.0, you call loadClassicVersins and loadModernVersions. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
Nrgyzer
Joined: 12 Dec 2009 Posts: 31
|
Posted: Sat Jun 11, 2011 1:49 pm Post subject: |
|
|
Ah, okay... I really misunderstood you - thanks |
|
Back to top |
|
|
|
|
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
|