Glfw examples ? (or general advice using opengl in julia)

From the Julia package GLFW page:

“The Julia interface is almost identical to the underlying C interface, with a few notable differences:”

while that’s true, figuring out how to translate things like,

 glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);

into Julia is proving to be a bit of a task, consisting almost entierly of trial and error. This is really a more general question as to how to translate opengl code in general, thanks to opengl specific types, etc… for example,

const GLint vcol_location = glGetAttribLocation(program, "vCol");

glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(Vertex, col));

There’s a whole lotta learning curve here, and looking for something to help me get down that curve a little faster.

Thank you !

3 Likes

Have you given ModernGL.jl a try? It wraps most (all?) of OpenGL’s API and makes it trivial to translate C/C++ OpenGL programs to Julia.

Also, for a comprehensive demo, my DesignatedShader.jl package/demo is a good reference point, IMO. Just clone it, change into the DesignatedShader/ directory, and run julia --project bin/main.jl to run the demo. Currently it assumes you have OpenGL 3.3 available.

2 Likes

I wrote some simple step-by-step OpenGL demos a while ago , not all of them can work with the latest Julia though.

3 Likes

i tried to and, once again, had trouble finding examples of how it worked. Also, from the ModernGL page,

GLAbstraction is a library, that offers Julian wrappers around often used OpenGL functions and types.

GLWindow essentially wraps GLFW (but might be extended to context creation methods) and gives you an easy way to create a window and access window events .

GLVisualize Offers a simple to use API to create 2D/3D visualization and animations.

GLAbstraction and GLWindow seem to both be dead, or at least, dead to 1.3. then, somehow i got the impression that ModernGL depended on them, i think due to some crufty examples I was looking at, so i gave up on the whole lot of it. It didn’t help that ModernGL has not been updated very much lately (maybe because it just doesn’t need to be). I will go back to ModernGL with your example and see if i can make some progress.

perfect! even if they don’t work, they will at least get me down the learning curve faster. I very much hope i can make them work and then contribute the changes. Julia needs solid opengl examples in the worst way…

Thanks very much for the suggestions !

Quick note: you should comment out the following line to prevent an error: ~jpsamaroo/DesignatedShader.jl: bin/main.jl - sourcehut git

I was working on rendering a cat mesh model, but haven’t yet gotten it to work well :smile:

haha. ok. will do

@Gnimuc i have started on the demos. so far finding just a few issues. i have no idea how to do PRs, but if i can figure it out i’ll start moving my changes back to the tree. they are quite minor at this time. i’ve just found something a little tricky to handle, but i think i’ll figure it out, once i figure out how flipdims worked…

i find it very funny how often that colored triangle demo shows up. everybody takes it and it ends up being a demo in every language’s FFI to GLFW/OpenGL.

opengl programmers have something against cubes ? :laughing:

my first goal is to make a cube demo, and get into the demo project :smiley:

1 Like