Jump to content
  • Advertisement
Sign in to follow this  
jirri

OpenGL Can't render using Vertex Buffer Object (VBO)

This topic is 2220 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been following a tutorial series for a while now and got stuck on a lesson where Vertex Buffer Objects (VBO) are introduced. The lesson im stuck at is: http://lazyfoo.net/t...jects/index.php. There is source code at the bottom of the link page.

The code is supposed to render a white rectangle on a black background. When I run the code it just opens a window with a black background. I've even tried using the source code from the tutorial. The strange thing is, I'm pretty sure that i managed to run the program properly yesterday. But today i went back because i encountered the same problem on following lessons. Only thing changed since yesterday is that i updated my graphic card drivers (ATI).

I'm not sure but I think it might have something to do with GLEW. I can still use some functionality introduced with GLEW in earlier lessons, but when the problems arise when using VBO (e.g. glBindBuffer) i think.

Have I "installed" GLEW correctly? I'm using Win7 64 bit and Visual C++ 2010 express.
* I downloaded: http://glew.sourceforge.net/ -> Binaries Windows 32-bit. (With the 64-bit download i just got errors.)
* I added Include and Library file paths to project, and added link to glew32.lib in VC++.
* I copied the DLL files to both: C:\Windows\System32 and C:\Windows\SysWOW64 (Didn't know which was correct.)
* Finally: #include <GL/glew.h>
#include <GL/freeglut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>

I'm pretty new to both C++ and OpenGL so keep that in mind if I said something entirely incorrect. I know that it's a long post but if anyone had any idea a would really appreciate it, really want to be able to continue! Thank you in advance!

Oh and i get the following text in VC++ after i close the black window:
'OpenGLtutorialLF.exe': Loaded 'C:\Users\Juri\Documents\Visual Studio 2010\Projects\OpenGLtutorialLF\Debug\OpenGLtutorialLF.exe', Symbols loaded.
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\freeglut.dll', Binary was not built with debug information.
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\DevIL.dll', Binary was not built with debug information.
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcp90.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\ILU.dll', Binary was not built with debug information.
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\glew32.dll', Binary was not built with debug information.
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\atiglpxx.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\atioglxx.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\atiadlxy.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\userenv.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\profapi.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\wtsapi32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\psapi.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\wsock32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\atigktxx.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\aticfx32.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Unloaded 'C:\Windows\SysWOW64\atigktxx.dll'
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\atigktxx.dll', Cannot find or open the PDB file
'OpenGLtutorialLF.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0x11d8) has exited with code 0 (0x0).
The program '[4028] OpenGLtutorialLF.exe: Native' has exited with code 0 (0x0).[/quote]

Share this post


Link to post
Share on other sites
Advertisement
I think you should copy the dll's where the project is as copying them to system files is ugly. Not sure if it applies to the dev machine tho.

Check glGetError or whatever it was if theres an error. I dont think its glew if it runs...

Also what opengl context version are you asking for? maybe try asking for a different version or something...

Share this post


Link to post
Share on other sites
I've prepared simple code to help you with creating and rendering VBO, i hope this helps you.
If it doesn't work then check your projection and modelview matrices and make sure you aren't using core profile of GL 3.0+.

[source lang="cpp"]typedef struct vert //32 bytes per vertex
{
float origin[3];
float normal[3];
float uv[2];
} vert_t;

#define BUFFER_OFFSET(i) (reinterpret_cast<void*>(i))

unsigned int vbo; //this is our vbo id


void InitVBO()
{
int numVerts = 3;
vert_t *verts = new vert_t[numVerts];

//add some verticles
verts[0]->origin[0] = -2.0f;
verts[0]->origin[1] = 0.0f;
verts[0]->origin[2] = 0.0f;

verts[1]->origin[0] = 2.0f;
verts[1]->origin[1] = 0.0f;
verts[1]->origin[2] = 0.0f;

verts[2]->origin[0] = 0.0f;
verts[2]->origin[1] = 3.0f;
verts[2]->origin[2] = 0.0f;

int size = (int)(numVerts * sizeof(vert_t)); //this is required by VBO

// create and bind vbo
glGenBuffersARB( 1, &vbo );
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo );

glBufferDataARB( GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB );
glBufferSubDataARB( GL_ARRAY_BUFFER_ARB, 0, size, &verts[0]->origin[0] ); //bind data to buffer

// dont need verticles in ram memory anymore, unless you want to modify them at a later time
delete[] verts;
}

// this is how we draw VBO
// I didn't mention GL_COLOR_ARRAY but i think you will know how to implement it when you look at this code.
void DrawVBO()
{
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );

glBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo ); // bind our VBO for drawning

glVertexPointer( 3, GL_FLOAT, sizeof(vert_t), BUFFER_OFFSET(0) );
glNormalPointer( GL_FLOAT, sizeof(vert_t), BUFFER_OFFSET(12) );
glTexCoordPointer( 2, GL_FLOAT, sizeof(vert_t), BUFFER_OFFSET(24) );

glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );

}

// delete vbo buffer when you don't need it anymore.
void DeleteVBO()
{
if( !vbo )
return;
glDeleteBuffersARB( 1, vbo );
}[/source] Edited by BraXi

Share this post


Link to post
Share on other sites
Thank you for the code and for the help! Now it works, renders properly. Although I'm not sure if I made the correct changes? I changed:
glutInitContextVersion( 2, 1 ); to glutInitContextVersion( 3, 0 );

But is OpenGL context the same as core profile in "...make sure you aren't using core profile of GL 3.0+..."? In that case, I am violating that condition but it still works? Will this cause more problems further on? (If there's anything obvious that comes to mind)

I'm still a bit confused, when I googled around I found info saying that this should be supported for OpenGL versions > 1.4. Well, thank you again anyways!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!