The challenging programming

Reading Time: 4 minutes

 Today I have been facing new challenges in the PATRIA engine development.

I am migrating all the PATRIA core functions from the OpenGL obsolete immediate mode to the most advanced Vertex Array and Vertex Buffer Object.

Useless to say that the theory took me a while before I started the implementation, I was excited and scared at the same time to alter the so well working engine, once I felt sure about my overall knowledge of the topic, I started to modify the core functionts.

Once I started I found out a lot of problems, first of all, core functions such as glGenBuffers was not recognized, I therefore started to check the main reasons behind it.

Important to say that I am using Ubuntu 10.10 + Eclipse CDT Helios SR1.

Digging around, I checked if the VBO extensions were supported by the OpenGL driver in use, I did it using the glxinfo command, if it is not insalled, you can easily install it by running the following command:

sudo apt-get install mesa-utils

Once you run it in a command shell, you should notice a very complex output such as:

 

OpenGL extensions:
    GL_ARB_copy_buffer, GL_ARB_depth_clamp, GL_ARB_depth_texture, 
    GL_ARB_draw_buffers, GL_ARB_draw_elements_base_vertex, 
    GL_ARB_fragment_coord_conventions, GL_ARB_fragment_program, 
    GL_ARB_fragment_program_shadow, GL_ARB_fragment_shader, 
    GL_ARB_framebuffer_object, GL_ARB_half_float_pixel, 
    GL_ARB_half_float_vertex, GL_ARB_map_buffer_range, GL_ARB_multisample, 
    GL_ARB_multitexture, GL_ARB_occlusion_query, GL_ARB_pixel_buffer_object, 
    GL_ARB_point_parameters, GL_ARB_point_sprite, GL_ARB_provoking_vertex, 
    GL_ARB_seamless_cube_map, GL_ARB_shader_objects, 
……

 

Checking about the vertex buffer object, everything was there (at least using the MESA implementations, SW based).

I found out some information about the required ARB (ARB_vertex_buffer_object) here:

http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt

Later on, digging the internet, I found out that the Vertex Buffer Object support in Linux was provided by the GLEW extension (The OpenGL Extension Wrangler Library)

http://glew.sourceforge.net/

In order to install the GLEW development environment, run the following shell command:

sudo apt-get install  libglew-dev

 Once the GLEW library was installed, I tried to write my VBO code and I reconfigured the Eclipse client, I have included the glew header files:

#include <GL/glew.h>

and added the required compile library:

1. Project/Properties

2. C/C++ Build\Settings

3. Libraries (-l)

4. Add the library claled GLEW

At the end of the day, the libraries at gcc level should be like this:

 -lGLEW -lglut

 Once this is done, I was able to compile the code….OK, fine, I was happy, I tried my code and the best I have achieved was a runtime error.

In particular, my very simple C call:

glGenBuffers(1,PATRIA_VBO_LASER_PLAYER);

generated the following misterious error (noticed while debugging).

No source available for "0x0" 

I have then started a very long troubleshooting operation which took about 4 hours to be solved, a lot of headache and real bad mood all day long.

Since I spent so much time, I wanted to document it so other people (you) don’t have to spend so much time on it.

 

If you notice such a problem, it is because you did not init the glew library (which I didn’t know it was required) using the very ultra simple call:

glewInit();

 

I can’t believe I spent so much time in a so obvious troubleshooting.

Ok, now everything works and I can continue with the PATRIA development!

No one can stop me! 🙂

 

Growing in numbers 

Growing in speed
Can’t fight the future
Can’t fight what I see

People they come together
People they fall apart
No one can stop us now 
‘Cause we are all made of stars

Efforts of lovers
Left in my mind
I sing in the reaches
We’ll see what we find 

People they come together
People they fall apart
No one can stop us now 
‘Cause we are all made of stars

People they come together
People they fall apart
No one can stop us now 
‘Cause we are all made of stars

Slow slow slow, come come
Someone come come come
Even love is goin’ ’round 
You can’t ignore what is goin’ ’round

Slowly rebuilding 
I feel it in me 
Growing in numbers
Growing in peace

People they come together
People they fall apart
No one can stop us now 
‘Cause we are all made of stars

People they come together
People they fall apart
No one can stop us now 
‘Cause we are all made of stars

People they come together
(People they come together)
People they fall apart
(People they fall apart)
No one can stop us now 
(No one can stop us now)
‘Cause we are all made of stars
(We are all made of stars)

We are all made of stars
People they come together
We are all made of stars
(People they fall apart)
We are all made of stars
(No one can stop us now)
‘Cause we are all made of stars

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.