Recently in OpenGL Category

GPU Raymarching with Distance Fields

| No Comments
These last two weeks I've been pretty distracted with personal issues, and to get back on track it always helps me to start a small personal project in which I experiment something I've never done before. So here we go: GPU Raymarching using Distance Fields.

This project is completely based on the work of Iñigo Quilez, the great IQ from rgba. He put some slides in his website explaining how to do this kind of rendering, and after reading them I just had to try it for myself.

If you want to read more, just go here: 

And now, time for some videos:



 

I already have another build with more shapes and weird things, but it'll have to wait until I get distracted again ;-)

Voronoi image-filling

| No Comments
Little test to see what can you do to approximate a big image using only a few samples, and using Voronoi diagrams for that. It's not amazingly cool or anything, but it runs in real-time :)

Time for some OpenGL bashing

| No Comments

Yes, I know, I'm a bit late to the game, but today (after 8 years of using OpenGL exclusively) I've just gotten the small rendering engine I'm working on to use DirectX 9. 

Why DX9 and not 10 (or 11)? Because I need it to run on computers with WinXP (could Microsoft have been more stupid, limiting DirectX like that?)

Anyway, the engine was working on MacOS and Linux, but I needed to be sure to support DX as well (OpenGL drivers for Windows are known to be buggy as hell and fairly incomplete in some cases). So here we are, coding using a propietary Microsoft library. Yes, I know I'm unclean and un-free, but such is life (and for what it's worth, I'm still using bash, g++ and vim, even on Windows ;)

The thing is, after using DirectX for 2 days, I wish OpenGL was more like it in some ways. 

Small example. First, OpenGL code to render from a vertex buffer object:

glBindBuffer(GL_ARRAY_BUFFER, mdataBuffer);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); 
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexData), (char*)NULL+sizeof(uint8t)*3);
glVertexPointer(3, GL_FLOAT, sizeof(VertexData), 0);
glDrawArrays(GL_TRIANGLES, startVertex, endVertex-startVertex);

And now, equivalent DirectX9 code:

md3dDevice->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE);
md3dDevice->SetStreamSource( 0, mdataBuffer, 0, sizeof(VertexData) );
md3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, startVertex, (endVertex-startVertex)/3);

Those 2 blocks of code do exactly the same thing: take information from a buffer about a bunch of vertices (vertex position and color), and use that info to render some triangles. Just that.
 
But see the difference in the code? Now choose the cleaner, saner API. I don't think many will choose OpenGL. And that's a shame.

Sometimes I hope for a clean API redesign for OpenGL, and do away with all that crap. ...sigh...

I highly recomend this session (page 194) (btw, thanks to shash for that link) where an NVidia engineer talks about problems the OpenGL API (and DirectX's too) causes for application portability.