View mode: basic / threaded / horizontal-split · Log in · Help
February 22, 2012
D, Derelict2, and OpenGL
I have been reading the book "The D Programming Language" and am 
really enjoying D. However, my current motivation to use D was 
specifically for programming through OpenGL, and I was excited 
when I found out Dereict2 provided support for OpenGL.

My current Gfx card can only support up to OpenGL 3.3, Can 
Derelict2 support up to OpenGL 3.3?

Also, and most importantly, would it be possible for me to follow 
a book such as the "Red Book" to learn about using OpenGL with D?

Does anyone have a recommendation for a book about OpenGL that is 
geared towards people new to OpenGL?
February 22, 2012
Re: D, Derelict2, and OpenGL
Am 22.02.2012 23:36, schrieb Chris Pons:
> I have been reading the book "The D Programming Language" and am really
> enjoying D. However, my current motivation to use D was specifically for
> programming through OpenGL, and I was excited when I found out Dereict2
> provided support for OpenGL.
>
> My current Gfx card can only support up to OpenGL 3.3, Can Derelict2
> support up to OpenGL 3.3?
>
> Also, and most importantly, would it be possible for me to follow a book
> such as the "Red Book" to learn about using OpenGL with D?
>
> Does anyone have a recommendation for a book about OpenGL that is geared
> towards people new to OpenGL?
Hello,

Yes Derelict2 supports OpenGL 3(.3), you maybe wanna take a look at 
Derelict3, but be aware, that's just a binding to the gl3-Header, which 
means you dont have the deprecated function-set (aka. fixed pipeline, 
<3.0). You can also follow any OpenGL-programming book you like, you've 
just to port the examples to D, which isn't that hard (opengl function 
names stay the same), I did it also. Sometimes it's a bit tricky, but 
it's really doable (e.g. .sizeof on a dynamic array does not return it's 
size in memory as you would expect as a C-programmer).

I used http://www.arcsynthesis.org/gltut/ to teach myself OpenGL, all in 
all it's a great book, but the source-code is in my opinion really 
"ugly" and you can't port all the code (well you can but that will take 
you very long, since they are using their own mesh-formats and loader), 
therefor I've written some librarys which may be usefule for you: 
https://bitbucket.org/dav1d/gljm - gljm loads meshes from 2 common 
formats (.ply and .obj, blender e.g. can export to them) and a custom 
json format. https://bitbucket.org/dav1d/gl3n - gl3n which implements 
vector/matrix/quaternion math.

Hope this helps
- David
February 23, 2012
Re: D, Derelict2, and OpenGL
I am doing almost exactly what you are doing, and to get more familiar 
with both SDL/OpenGL and D, I used Derelict2.

To get familiar with basic graphics in SDL, I used this C++ tutorial, 
http://www.sdltutorials.com/.  The functions pretty much convert 1-to-1 in 
Derelict2.

If it helps, I also have a small project that is hopefully simple enough 
that it is educational.  https://github.com/vnayar/dsdl

 - Vijay

On Wed, 22 Feb 2012, Chris Pons wrote:

> I have been reading the book "The D Programming Language" and am really 
> enjoying D. However, my current motivation to use D was specifically for 
> programming through OpenGL, and I was excited when I found out Dereict2 
> provided support for OpenGL.
>
> My current Gfx card can only support up to OpenGL 3.3, Can Derelict2 support 
> up to OpenGL 3.3?
>
> Also, and most importantly, would it be possible for me to follow a book such 
> as the "Red Book" to learn about using OpenGL with D?
>
> Does anyone have a recommendation for a book about OpenGL that is geared 
> towards people new to OpenGL?
>
February 23, 2012
Re: D, Derelict2, and OpenGL
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?
February 23, 2012
Re: D, Derelict2, and OpenGL
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
}

---------------
February 23, 2012
Re: D, Derelict2, and OpenGL
Ok, thanks for clearing that up. I am really looking forward to 
seeing what D and Derelict2 can offer. However, I would have 
liked to post this in the Derelict forums because it seems like 
the more appropriate place.

I know that Aldacron is only one man, and I appreciate his hard 
work, but how long does it take to get approved to post on that 
forum?

I read that I had to wait for moderator activation (unless I was 
mistaken) ?

On Thursday, 23 February 2012 at 01:15:17 UTC, David wrote:
> 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
> }
>
> ---------------
February 23, 2012
Re: D, Derelict2, and OpenGL
On 2/23/2012 10:29 AM, Chris Pons wrote:
> Ok, thanks for clearing that up. I am really looking forward to seeing
> what D and Derelict2 can offer. However, I would have liked to post this
> in the Derelict forums because it seems like the more appropriate place.
>
> I know that Aldacron is only one man, and I appreciate his hard work,
> but how long does it take to get approved to post on that forum?
>
> I read that I had to wait for moderator activation (unless I was
> mistaken) ?
>

I don't know if you are mistaken or not, but looking at the member list 
sorted by join date, several new members have registered recently. So if 
approval *is* required, it probably isn't too long. Did you try to log in?

At any, rate, I (Aldacron) have nothing to do with approval of members 
of the forums as a whole. All I can do is moderate posts specifically in 
the Derelict forum.
February 23, 2012
Re: D, Derelict2, and OpenGL
Ok, well it must be something wrong on my end. I have tried 
logging in with no result. I'll try to work it.


> I don't know if you are mistaken or not, but looking at the 
> member list sorted by join date, several new members have 
> registered recently. So if approval *is* required, it probably 
> isn't too long. Did you try to log in?
>
> At any, rate, I (Aldacron) have nothing to do with approval of 
> members of the forums as a whole. All I can do is moderate 
> posts specifically in the Derelict forum.
February 23, 2012
Re: D, Derelict2, and OpenGL
I find that when learning a complicated system or library, the best
way is to write out the code examples, compile them, then change
things until they break, fix it, then make more changes. Eventually
you end up with the worst code ever known to man and a thorough
understanding of the system at hand. I did it recently when figuring
out that there is more to terminal emulation than just IO redirection
and interpreting Terminal codes.

Most of the time, you'll bang your head against your desk screaming
"why wont you work" until you brain-damage your way into an epiphany,
fix everything, achieve enlightenment, ???, PROFIT!
February 24, 2012
Re: D, Derelict2, and OpenGL
On Thursday, 23 February 2012 at 19:26:31 UTC, James Miller wrote:
> I find that when learning a complicated system or library, the 
> best
> way is to write out the code examples, compile them, then change
> things until they break, fix it, then make more changes. 
> Eventually
> you end up with the worst code ever known to man and a thorough
> understanding of the system at hand. I did it recently when 
> figuring
> out that there is more to terminal emulation than just IO 
> redirection
> and interpreting Terminal codes.
>
> Most of the time, you'll bang your head against your desk 
> screaming
> "why wont you work" until you brain-damage your way into an 
> epiphany,
> fix everything, achieve enlightenment, ???, PROFIT!

I have followed this same pattern when I work with the UDK. 
Although, with that, its more about searching through source 
code, reading over the foundation I'm building upon and moving 
from there to try to implement my classes.

For me, that method has been the best to learn. Along with some 
frustration when it doesn't go as planned.

Is the documentation up-to-date on this site? So that I can 
search through and try to learn more about a certain library and 
how it could help me?
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home