FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

gl3n

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
dav1d



Joined: 12 Sep 2011
Posts: 40

PostPosted: Tue Nov 29, 2011 9:30 am    Post subject: gl3n Reply with quote

Hello,

This has nothing to do with derelict directly, more with OpenGL.

I've recently written, well I am still working on it, gl3n, it's a D library which provides all the math you need to work with OpenGL, currently it supports vector, matrices, quats, interpolation (lerp, slerp, hermite, catmull rom, nearest) and nearly all math functions available in GLSL (according to spec 4.1). The reason why I present it here is, I need some help, ideas, things you miss or need, because I am quite new to OpenGL programming (about 3 month). Unfortunatly there is no documentation, but it's on my TODO list Wink, but it shouldn't be hard to understand how it works, if you need some help, take a look inside the source, I did add unittests to each function/method so it shouldn't be hard to get it working. Furthermore I am often at #D on freenode.

Some examples:
Code:
vec4 v4 = vec4(1.0f, vec3(2.0f, 3.0f, 4.0f));
vec4 v4 = vec4(1.0f, vec4(1.0f, 2.0f, 3.0f, 4.0f).xyz)); // "dynamic" swizzling with opDispatch
mat4.translation(-0.5f, -0.54f, 0.42f).rotatex(PI).rotatez(PI/2).value_ptr;

struct Camera {
    vec3 position = vec3(0.0f, 0.0f, 0.0f);
    quat orientation = quat.identity;
   
    Camera rotatex(real alpha) { orientation.rotatex(alpha); return this; }
    Camera rotatey(real alpha) { orientation.rotatey(alpha); return this; }
    Camera rotatez(real alpha) { orientation.rotatez(alpha); return this; }
   
    Camera move(float x, float y, float z) {
        position += vec3(x, y, z);
        return this;
    }
    Camera move(vec3 s) {
        position += s;
        return this;
    }
   
    @property camera() {
        //writefln("yaw: %s, pitch: %s, roll: %s", degrees(orientation.yaw), degrees(orientation.pitch), degrees(orientation.roll));
        return mat4.translation(position.x, position.y, position.z) * orientation.to_matrix!(4,4);
    }
}

        glUniformMatrix4fv(programs.main.view, 1, GL_TRUE, cam.camera.value_ptr);
        glUniformMatrix3fv(programs.main.inv_rot, 1, GL_TRUE, cam.orientation.to_matrix!(3,3).inverse.value_ptr);


And the source, which is licensed under MIT: https://bitbucket.org/dav1d/gl3n/overview

Would be cool, if I could get some feedback Smile.

PS: I hope it is ok, when I post this here.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Nov 29, 2011 11:22 pm    Post subject: Reply with quote

Looks like an interesting little package. I suggest you also post something in the D newsgroups (perhaps D.announce). You'll get more eyes on it there, I'm sure. I'll post something about it on my blog in a bit as well.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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