View previous topic :: View next topic |
Author |
Message |
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Mon Sep 12, 2011 1:12 pm Post subject: VAOs and GL_DEPTH_CLAMP |
|
|
Hello,
At first I wanna say thanks, for these great bindings .
Now to the problem... It seems that derelict doesnt support VAOs, the functions "glBindVertexArray" and "glGenVertexArrays" dont exist. (They are added in OpenGL 3). There's also the GLenum "GL_DEPTH_CLAMP" missing.
Hopefully you can help me.
dav1d
//Edit:
Code: | static this() {
DerelictSDL.load();
DerelictGLU.load();
DerelictGL.load();
DerelictGL.loadModernVersions(GLVersion.GL30);
} |
Code: | void main() {
writefln("main");
if(SDL_Init(SDL_INIT_VIDEO)) {
writefln("error: SDL_INIT_VIDEO");
return;
} else {
writefln("no error (SDL_INIT_VIDEO)");
}
writefln("%s", vertex_data);
SDL_WM_SetCaption("gltut 1", "nirgends");
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL | SDL_RESIZABLE);
SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL);
DerelictGL.loadExtendedVersions();
//DerelictGL.loadExtensions();
// more code here, init opengl settings (Face culling, buffers etc.) and the mainloop
|
//Edit²: I have a ATI HD4850 it supports up to OpenGL 3.3 and I am on archlinux, with the fglrx driver
//Edit³: xD .. Derelict version: derelict2-svn 586-1 |
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Tue Sep 13, 2011 3:53 am Post subject: Re: VAOs and GL_DEPTH_CLAMP |
|
|
dav1d wrote: | Hello,
At first I wanna say thanks, for these great bindings . |
You're welcome!
Quote: |
Now to the problem... It seems that derelict doesnt support VAOs, the functions "glBindVertexArray" and "glGenVertexArrays" dont exist. (They are added in OpenGL 3). |
According to the gl3.h header I'm looking at, they are not defined under any of the major GL version blocks. They are instead defined as part of the GL_ARB_vertex_array_object extension. From the C header:
Code: |
#ifndef GL_ARB_vertex_array_object
#define GL_ARB_vertex_array_object 1
#ifdef GL3_PROTOTYPES
GLAPI void APIENTRY glBindVertexArray (GLuint array);
GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array);
#endif /* GL3_PROTOTYPES */
typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array);
#endif
|
As such, in Derelict they are implemented as part of the extension mechanism. You'll need to import derelict.opengl.glext and call DerelictGL.loadExtensions to use them.
Quote: |
There's also the GLenum "GL_DEPTH_CLAMP" missing.
|
Again, this one is implemented as part of an ARB extension in the C headers. However, I apparently haven't actually implemented that in Derelict yet. It seems there are several ARB extensions I've not implemented yet. I'll add this one as soon as I finish this post. (EDIT: I've updated SVN).
I also have a question about your code.
Quote: |
Code: | static this() {
DerelictSDL.load();
DerelictGLU.load();
DerelictGL.load();
DerelictGL.loadModernVersions(GLVersion.GL30);
} |
|
loadModernVersions really should be called after creating a context, just as loadExtendedVersions. Otherwise, your code will not work properly on Windows. In fact, Derelict should be throwing an exception here when no context has already be created. Is that not happening? Or did you not make it that far yet?
And one more thing -- SDL 1.2 does not create OpenGL 3.x contexts. You need to take some extra steps to get one. If you are already handling that, just ignore me _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Tue Sep 13, 2011 4:43 am Post subject: |
|
|
Oh ok, (I tried it with DerelictGL.loadExtensions , but I didnt import the file ).
Yeah I had some problems loading derelict, I tried serval ways, this one was the first working so I stayed with it, thanks for pointing it out. Well there's no exception, I just had an exception when putting DerelictGL.loadExtendedVersions there (I am on Linux not Windows).
To the last point (sdl), I just do what you can see there: Code: | if(SDL_Init(SDL_INIT_VIDEO)) {
writefln("error: SDL_INIT_VIDEO");
return;
} else {
writefln("no error (SDL_INIT_VIDEO)");
}
writefln("%s", vertex_data);
SDL_WM_SetCaption("gltut 1", "nirgends");
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL | SDL_RESIZABLE);
SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL);
| and it works...What would these extra steps be? |
|
Back to top |
|
|
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Tue Sep 13, 2011 4:55 am Post subject: |
|
|
MH I imported "derelict.opengl.glext" and called "DerelictGL.loadExtensions" after creating a Context. but it still gives me "Error: undefined identifier GL_DEPTH_CLAMP"
Code: |
static this() {
DerelictSDL.load();
DerelictGL.load();
}
void main() {
writefln("main");
if(SDL_Init(SDL_INIT_VIDEO)) {
writefln("error: SDL_INIT_VIDEO");
return;
} else {
writefln("no error (SDL_INIT_VIDEO)");
}
writefln("%s", vertex_data);
SDL_WM_SetCaption("gltut 1", "nirgends");
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL | SDL_RESIZABLE);
SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL);
DerelictGL.loadModernVersions(GLVersion.GL30);
DerelictGL.loadExtendedVersions();
DerelictGL.loadExtensions();
init(1000, 800);
main:
while(true) {
try {
handle_sdl_events();
} catch(WindowQuitException e) {
break main;
}
display();
}
scope(exit) SDL_Quit();
}
|
|
|
Back to top |
|
|
aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Tue Sep 13, 2011 4:58 am Post subject: |
|
|
dav1d wrote: | Well there's no exception, I just had an exception when putting DerelictGL.loadExtendedVersions there (I am on Linux not Windows). |
Well, that's a bug. I've just updated SVN so that now it throws if no context has been created before calling it. It doesn't matter on Linux, but on Windows you can't load anything beyond 1.1 without a valid context. In Derelict, I enforce this across all platforms for compatibility.
Quote: |
To the last point (sdl), I just do what you can see there: Code: | if(SDL_Init(SDL_INIT_VIDEO)) {
writefln("error: SDL_INIT_VIDEO");
return;
} else {
writefln("no error (SDL_INIT_VIDEO)");
}
writefln("%s", vertex_data);
SDL_WM_SetCaption("gltut 1", "nirgends");
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL | SDL_RESIZABLE);
SDL_SetVideoMode(1000, 800, 32, SDL_OPENGL);
| and it works...What would these extra steps be? |
Yes, it works in the sense that you can make use of all the OpenGL functions your card supports. What won't work, though, is if you want to get, say, a pure 3.3 context with no deprecated functions available. So if you want to avoid deprecated functions, you'll have to be extra vigilant.
The extra steps involve getting a handle to the Window from SDL, creating the forward compatible context yourself, then making it current. If you don't need that, though, it doesn't matter. But, now that I think about it, I never added the proper types for getting the window handle on Linux, so it won't work with Derelict anyway.
At any rate, in the very near future there will be a binding for SDL 1.3 added to Derelict and all of this will be moot. _________________ The One With D | The One With Aldacron | D Bits |
|
Back to top |
|
|
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Tue Sep 13, 2011 6:08 am Post subject: |
|
|
Yeah already read about SDL2 .
Well maybe I posted to fast, did you read my post before yours? The GL_DEPTH_CLAMP thing, am I loading it wrong? |
|
Back to top |
|
|
dav1d
Joined: 12 Sep 2011 Posts: 40
|
Posted: Tue Sep 13, 2011 6:41 am Post subject: |
|
|
Ok forget it, I updated, now it works |
|
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
|