🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

glfwExtensionSupported == false on Linux

Started by
8 comments, last by elFarto 16 years, 11 months ago
I am trying to get VBO's to work on linux using gcc with the Code::Blocks IDE and the GLFW library. I have never used VBO's before I and haven't the slightest clue what is absolutely mandatory for:
GenBuffersARB=(PFNGLGENBUFFERSARBPROC)glfwGetProcAddress("glGenBuffersARB");
GLuint id;
GenBuffersARB(1,&id);
...to not cause a segmentation fault. When I try:
if (!glfwExtensionSupported("GL_ARB_vertex_buffer_object"))
    return false;
"return false" gets executed every time. GLFW is working just fine without VBO's rending in immediate mode and loading textures. I even linked "/usr/lib/libGL.so," "/usr/lib/libGLU.so," and "/usr/lib/libglut.so" and nothing changed. I have a GeForce 8800 GLX with the nVidia 9755 driver installed on Linux Kubuntu. Surely the GeForce 8800 supports VBO's.
Programming since 1995.
Advertisement
try "$ glxinfo | grep vertex_buffer"

If nothing happens, then you probably don't have this extension. Maybe you did not install your driver correctly.

$ glxinfo gives you a pretty big output. Somewhere in there is your opengl version. and vendor string. If the vendor is mesa and the version is sub 2.0 then you probably doing software rendering.


Also you should make sure that your linked in -lGL is the correct nvidia one. Not the mesa-software-library. (apparently I am not really sure howto do it, or even if it is possible to make a mistake there - Have you checked your opengl version inside your program? )
Thank you, and I don't think I have Mesa, I tried to install it but that never worked. Regardless, here is my console output from your suggestion.
Quote: Kubuntu Konsole
$ glxinfo | grep vertex_buffer
GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader
Programming since 1995.
Again, another simple mistake. I tried to use a static object to initialize those function pointers and I didn't realize that I needed the context to be created first.
*edit*
I still can't get anything to show up on screen, but it doesn't crash anymore.

[Edited by - T1Oracle on July 20, 2007 4:49:12 PM]
Programming since 1995.
In an attempt to rule out all of my OO code as being the culprit, I came up with a minimal example of VBO's using GLFW based on my (limited) understandings of the two.
#include <GL/glfw.h>int main(){    bool	running = true;    unsigned width=640,height=480;    glfwInit();    if( !glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) )    {        glfwTerminate();        return 0;    }    glfwSetWindowTitle("GLFW VBO Demo");    GLfloat data[] = { -1.0f, 1.0f, 0.0f,					 -1.0f, -1.0f, 0.0f,					 1.0f, -1.0f, 0.0f };	GLuint buffer = 0;	PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;	PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;	PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;	PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;	// set up OpenGL	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluPerspective(45, (float) width / (float) height, 1, 512);    if (glfwExtensionSupported("GL_ARB_vertex_buffer_object")==false)        return 1;	glBindBufferARB = (PFNGLBINDBUFFERARBPROC)glfwGetProcAddress("glBindBufferARB");	glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glfwGetProcAddress("glGenBuffersARB");	glBufferDataARB = (PFNGLBUFFERDATAARBPROC)glfwGetProcAddress("glBufferDataARB");	glDeleteBuffersARB=(PFNGLDELETEBUFFERSARBPROC)glfwGetProcAddress("glDeleteBuffersARB");	// enable depth testing	glEnable(GL_DEPTH_TEST);	glDepthFunc(GL_LEQUAL);	glEnableClientState(GL_VERTEX_ARRAY);	glClearColor(0.5f, 0.5f, 1.0f, 1.0f);	glGenBuffersARB(1, &buffer);	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);	glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB);    while(running)	{		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		glMatrixMode(GL_MODELVIEW);		glLoadIdentity();		glTranslatef(0, 0, -3);		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);		glVertexPointer(3, GL_FLOAT, 0, 0);		glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);        glfwSwapBuffers();        // exit if ESC was pressed or window was closed        running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam( GLFW_OPENED);	}	glDeleteBuffersARB(1, &buffer);    glfwTerminate();    return 0;}


Unfortunately that code does nothing more then render a colored screen with no sign of any geometry being rendered. I haven't the slightest clue as to why.

I copied and modified the code from a devmaster.net article to create this example.

[Edited by - T1Oracle on July 21, 2007 1:28:05 AM]
Programming since 1995.
Quote: Original post by T1Oracle
Quote: Kubuntu Konsole
$ glxinfo | grep vertex_buffer
GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader


This means GL_ARB_vertex_buffer_object, is available.

So it has to be somethings else. Sadly I am not in to graphics that much. Sorry
Quote: Original post by hydroo
Quote: Original post by T1Oracle
Quote: Kubuntu Konsole
$ glxinfo | grep vertex_buffer
GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader


This means GL_ARB_vertex_buffer_object, is available.

So it has to be somethings else. Sadly I am not in to graphics that much. Sorry


I got it to detect the GL_ARB_vertex_buffer_object, the problem was that I tested for it before I had an Opengl context through GLFW. Unfortunately my problem still isn't resolved because I cannot get anything to render. From what I understand, the test code I posted should work but it isn't working for me. Nothing gets rendered, although it does detect GL_ARB_vertex_buffer_object just fine.
Programming since 1995.
You might ask in the opengl forums. This may not be a linux-related problem.
I fixed it, I was binding 0 instead of the buffer. That's what I get for copy and pasting. Although that's not what I did with my engine code. Unfortunately the engine code still doesn't work but I'm sure I'll work that out. The working minimal example is
#include <GL/glfw.h>int main(){    bool	running = true;    unsigned width=640,height=480;    glfwInit();    if( !glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) )    {        glfwTerminate();        return 0;    }    glfwSetWindowTitle("GLFW VBO Demo");    GLfloat data[] = { -1.0f, 1.0f, 0.0f,					 -1.0f, -1.0f, 0.0f,					 1.0f, -1.0f, 0.0f };	GLuint buffer = 0;	PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;	PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;	PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;	PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;	// set up OpenGL	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluPerspective(45, (float) width / (float) height, 1, 512);	glViewport(0, 0, width, height);    if (glfwExtensionSupported("GL_ARB_vertex_buffer_object")==false)        return 1;	glBindBufferARB = (PFNGLBINDBUFFERARBPROC)glfwGetProcAddress("glBindBufferARB");	glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glfwGetProcAddress("glGenBuffersARB");	glBufferDataARB = (PFNGLBUFFERDATAARBPROC)glfwGetProcAddress("glBufferDataARB");	glDeleteBuffersARB=(PFNGLDELETEBUFFERSARBPROC)glfwGetProcAddress("glDeleteBuffersARB");	// enable depth testing	glEnable(GL_DEPTH_TEST);	glDepthFunc(GL_LEQUAL);	glEnableClientState(GL_VERTEX_ARRAY);	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);	glGenBuffersARB(1, &buffer);	glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer); // THIS IS WHERE I HAD 0 INSTEAD OF buffer	glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB);    while(running)	{		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		glMatrixMode(GL_MODELVIEW);		glLoadIdentity();		glTranslatef(0, 0, -3);		glColor3f(1.0f,1.0f,1.0f);		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);		glVertexPointer(3, GL_FLOAT, 0, 0);		glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);        glfwSwapBuffers();        // exit if ESC was pressed or window was closed        running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam( GLFW_OPENED);	}	glDeleteBuffersARB(1, &buffer);    glfwTerminate();    return 0;}

I work so much better in the mornings than at night, sometimes you just have to sleep.
Programming since 1995.
This line is not correct (or at least, not what you want):

if( !glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) )

This will not give you a depth buffer. Change the bolded 0 to 24 or 32.

Regards
elFarto

This topic is closed to new replies.

Advertisement