D, Derelict2, and OpenGL

David d at dav1d.de
Wed Feb 22 17:15:16 PST 2012


Am 23.02.2012 01:20, schrieb Chris Pons:
> Hey David and Vijay,
>
> Thank you for the swift replies. It seems like this foray into D and
> OpenGL could be a bit overwhelming considering I would be learning D and
> SDL/OpenGL at the same time. So because of this, i'm going to make sure
> I have a solid base in D to start with.
>
> I am an Intermediate level C++ programmer, and I have used
> SDL/SFML/DirectX so the majority so far in the D programming book is
> very familiar.
>
> I however, do have a newbie Derelict2/OpenGL question. I have a basic
> program that simply spawns a window using SDL which I found from one of
> the SDL/OpenGL tuts on the derelict website.
>
> In order to use DerelictGL and DerelictSDL do I simply need to import
> derelict.opengl.gl and import derelict.sdl.sdl and then initialize the
> modules by typing DerelictSDL.load() , DerelictGL.load()?
>
> After this am I free to use SDL/OpenGL functions, like SDL_Init(...),
> SDL_Quit(); etc?
>
No you need also do init opengl after creating the context, here's how I 
am (was) doing it:

----------
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)");
     }

     SDL_WM_SetCaption("titel", "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();


     // rendering goes here
}

---------------



More information about the Digitalmars-d-learn mailing list