It is currently Fri Jun 23, 2017 10:31 am

All times are UTC - 5 hours




 Page 1 of 1 [ 19 posts ] 
Author Message
 Post subject: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sat Jan 26, 2013 7:17 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
In this vmk we use vertex buffer objects which are part of the OpenGL v1.5 spec. By the end of the video you will learn how to store data in the graphics card's memory and use that data to render things on the screen.

If you don't want to manage your own OpenGL Extensions like I do in the vmk, then your best bet is to use GLee which is a library that does it for you: http://elf-stone.com/glee.php


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Wed Feb 13, 2013 1:00 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
I am working through the vmk; however when I get to the section to clean and build the solution, VS is reporting that glext.h is not found. When I go into the windows sdk dircetory for OpenGL there are only 2 files there and no glext.h ... Im not sure how to fix this problem, I am still using windows vista ultimate with sp2 and vs 2010 ultimate with sp1. I have the windows 7.0v sdk installed. Any help will be wonderful news. Thank You.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Wed Feb 13, 2013 4:48 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
You need to download the glext.h file from http://www.opengl.org/registry/

After you do, put it into your openGL directory where you have the other 2 files.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Wed Feb 13, 2013 7:47 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
I was able to get a copy of the file and all works well. Thank You!


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Wed Feb 20, 2013 5:38 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Wanted to share this wiki page which contains a good summary of Buffer Objects in OpenGL:
http://www.opengl.org/wiki/Buffer_Object


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sat Oct 18, 2014 11:42 am 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
Marek wrote:
You need to download the glext.h file from http://www.opengl.org/registry/

After you do, put it into your openGL directory where you have the other 2 files.


I have done this, but it won't work. I get error C3861 identifier not found. The glext.h file is included in the stdafx.h file.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sat Oct 18, 2014 12:49 pm 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
GoryImpaler wrote:
I have done this, but it won't work. I get error C3861 identifier not found. The glext.h file is included in the stdafx.h file.


Which identifier can not be found by the compiler? What is the exact error message?


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sat Oct 18, 2014 1:27 pm 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
Marek wrote:
GoryImpaler wrote:
I have done this, but it won't work. I get error C3861 identifier not found. The glext.h file is included in the stdafx.h file.


Which identifier can not be found by the compiler? What is the exact error message?


The functions introduced in the VMK ofcourse, that you need glext.h for. :P
glGenBuffers, glBindBuffer, e.t.c.

If I understand it correctly, I will need glext.h later on when getting in to shaders also. Shouldn't there be a .lib file to go
with the .h?


Ok, I just tried to include glext before GL, and now I get stuff like undeclared identifiers and syntax errors in glext.h >_<

Edit: I should also note that I use VS Express 2013


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sat Oct 18, 2014 3:58 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Gory,

Can you give us more specifics of where you downloaded and stored the glext.h file, in addition to your OS? There is no .lib file, just the included headers.

If you have Windows 8.1 the glext.h file can be stored at "C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl"

In your pre-compiled header you should have something similar to below but <gl/glext.h> instead of the <gl/wglext.h>

// OpenGL Specifics v3.x
#include <gl/glcorearb.h>
#include <gl/wglext.h>


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sat Oct 18, 2014 10:37 pm 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
Hey!

https://www.opengl.org/registry/api/GL/glext.h
C:\Program Files (x86)\Windows Kits\8.1\Include\um\gl
Windows 7

// From stdafx.h
#include <gl/GL.h>
#include <gl/glext.h>

Edit: I read yesterday that it could be outdated graphics drivers, so I got the "best for my hardware" according to AMD's automatic test thingy.
Didn't do anything.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 1:52 am 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Hmm, the window kit 8.1 and stating you're using Windows 7 is throwing me off.

Right click the <gl/gl.h> and select "Open Document". Then hover over the tab in Visual Studio and it will tell you where the basic Windows GL include folder is that <gl/...> is mapping to. If your glext.h is in this folder it should find it no problem.

-Mebourne


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 2:11 am 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
Mebourne wrote:
Hmm, the window kit 8.1 and stating you're using Windows 7 is throwing me off.

Right click the <gl/gl.h> and select "Open Document". Then hover over the tab in Visual Studio and it will tell you where the basic Windows GL include folder is that <gl/...> is mapping to. If your glext.h is in this folder it should find it no problem.

-Mebourne


That's what I did. It's 8.1 since I'm using VS express 2013 I guess. It's 8.0 for VS express 2012, and I added glext.h to that folder also, but no luck.
The function declarations are all there, and the file is included in the project, but it can't even find the identifiers.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 6:50 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Copy and paste what you have in your whole stdafx.h file so that we can see what you did. Also copy and paste the whole output that the compiler is giving you. Without seeing exactly what you have, it is really hard for us to help you.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 7:08 am 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
stdafx.h
#ifndef STDAFX_H
#define STDAFX_H

#define VC_EXTRALEAN

#include "targetver.h"
#include <Windows.h>

#include <string>
#include <vector>
#include <array>

#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>

#include <tchar.h>

#include <glm/glm.hpp>

#include <gl/GL.h>
#include <gl/glext.h>

// Shader engine specific
#include "ExceptionHandler.h"


namespace gengine {

enum ReturnCodes {
   RETURN_OK = 0,
   RETURN_ERROR
};

extern const glm::vec4 COLOR_BLACK;

} // gengine

#endif


Game.log
Build started 2014-10-19 14:04:51.
     1>Project "C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\Game.vcxproj" on node 2 (Build target(s)).
     1>InitializeBuildStatus:
         Touching "Debug\Game.tlog\unsuccessfulbuild".
       ClCompile:
         C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /I"C:\programming libs\glm" /I"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Engine" /I"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Engine\fileHandlers\\" /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt Game.cpp _main.cpp
         Game.cpp
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(112): error C3861: 'glGenBuffers': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(113): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(114): error C3861: 'glBufferData': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(116): error C3861: 'glGenBuffers': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(117): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(118): error C3861: 'glBufferData': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(120): error C3861: 'glGenBuffers': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(121): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(122): error C3861: 'glBufferData': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(124): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(125): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(131): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(132): error C3861: 'glDeleteBuffers': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(136): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(137): error C3861: 'glDeleteBuffers': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(141): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(142): error C3861: 'glDeleteBuffers': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(171): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(174): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(177): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(187): error C3861: 'glBindBuffer': identifier not found
     1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(188): error C3861: 'glBindBuffer': identifier not found
         Generating Code...
         Compiling...
         _main.cpp
         Generating Code...
     1>Done Building Project "C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\Game.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:02.93


There you go. The declarations, as I said, are present in glext.h.


Edit:
If I add #define GL_GLEXT_PROTOTYPES just below #define VC_EXTRALEAN I get these messages:
Build started 2014-10-19 14:21:49.
     1>Project "C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\Game.vcxproj" on node 2 (Build target(s)).
     1>InitializeBuildStatus:
         Touching "Debug\Game.tlog\unsuccessfulbuild".
       ClCompile:
         C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /I"C:\programming libs\glm" /I"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Engine" /I"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Engine\fileHandlers\\" /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt Game.cpp
         Game.cpp
       Link:
         C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\_build\Game_debug.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\lib" Opengl32.lib Engine_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\_build\Game_debug.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\_build\Game_debug.lib" /MACHINE:X86 Debug\Game.obj
         Debug\_main.obj
     1>Game.obj : error LNK2019: unresolved external symbol _glBindBuffer@8 referenced in function "public: __thiscall gengine::Game::Game(void)" (??0Game@gengine@@QAE@XZ)
     1>Game.obj : error LNK2019: unresolved external symbol _glDeleteBuffers@8 referenced in function "public: virtual __thiscall gengine::Game::~Game(void)" (??1Game@gengine@@UAE@XZ)
     1>Game.obj : error LNK2019: unresolved external symbol _glGenBuffers@8 referenced in function "public: __thiscall gengine::Game::Game(void)" (??0Game@gengine@@QAE@XZ)
     1>Game.obj : error LNK2019: unresolved external symbol _glBufferData@16 referenced in function "public: __thiscall gengine::Game::Game(void)" (??0Game@gengine@@QAE@XZ)
     1>C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\_build\Game_debug.exe : fatal error LNK1120: 4 unresolved externals
     1>Done Building Project "C:\Users\Alexander\documents\visual studio 2013\Projects\ShaderEngine\Game\Game.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:02.30


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 12:02 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
I tried to recreate your errors and I think I see the problem. I'm seeing "1>c:\users\alexander\documents\visual studio 2013\projects\shaderengine\game\game.cpp(112): error C3861: 'glGenBuffers': identifier not found" which means you have linked the header, but you may have not declared and defined pointers to the various calls, glBindBuffer, glDeleteBuffer from your specific OpenGL implementation (OS / Graphics Card, etc). Would you post where you got the address to these function pointers if you have?

in your precompiled header (or another place for globals) you should have the following (just a sample of the various calls) and not have the #define GL_GLEXT_PROTOTYPES

// Pch.h or stdafx.h
extern PFNGLBINDBUFFERPROC              GLBindBuffer;
extern PFNGLBUFFERDATAPROC         GLBufferData;
extern PFNGLBUFFERSUBDATAPROC      GLBufferSubData;
extern PFNGLDELETEBUFFERSPROC         GLDeleteBuffers;
extern PFNGLGENBUFFERSPROC         GLGenBuffers;


// Pch.cpp or stdafx.cpp
PFNGLGENBUFFERSPROC           GLGenBuffers             = nullptr;
PFNGLDELETEBUFFERSPROC           GLDeleteBuffers           = nullptr;
PFNGLBINDBUFFERPROC           GLBindBuffer             = nullptr;
PFNGLBUFFERDATAPROC           GLBufferData             = nullptr;
PFNGLBUFFERSUBDATAPROC           GLBufferSubData          = nullptr;


And then you need in some file, for me it's in my OpenGLRHI.cpp, a place where you get the correct pointer to OpenGL's functions. This is where the magic happens! Don't be confused by my use of capital letters for the function pointers, that's just my style naming conventions. You need to ensure the string you send wglGetProcAddress matches OpenGL's implementation, ie "glBindBuffer".

// VBO
   StrApiName = "glBindBuffer";
   if ((GLBindBuffer = (PFNGLBINDBUFFERPROC) wglGetProcAddress(StrApiName.c_str())) == nullptr)
   {
      StrStream << FUtilities::WStrFromString(StrApiName);
      throw FExceptionHandler(StrStream);
   }

   StrApiName = "glBufferData";
   if ((GLBufferData = (PFNGLBUFFERDATAPROC) wglGetProcAddress(StrApiName.c_str())) == nullptr)
   {
      StrStream << FUtilities::WStrFromString(StrApiName);
      throw FExceptionHandler(StrStream);
   }

   StrApiName = "glBufferSubData";
   if ((GLBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress(StrApiName.c_str())) == nullptr)
   {
      StrStream << FUtilities::WStrFromString(StrApiName);
      throw FExceptionHandler(StrStream);
   }

   StrApiName = "glDeleteBuffers";
   if ((GLDeleteBuffers = (PFNGLDELETEBUFFERSPROC) wglGetProcAddress(StrApiName.c_str())) == nullptr)
   {
      StrStream << FUtilities::WStrFromString(StrApiName);
      throw FExceptionHandler(StrStream);
   }

   StrApiName = "glGenBuffers";
   if ((GLGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress(StrApiName.c_str())) == nullptr)
   {
      StrStream << FUtilities::WStrFromString(StrApiName);
      throw FExceptionHandler(StrStream);
   }


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 11:15 pm 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
No, I certainly don't have anything like that. Did Marek ever go through this?
I'll look into it after work.

Thanks!


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Sun Oct 19, 2014 11:46 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Yep, Marek went through it. Been awhile, but check around VMK 20. Let us know if this works or if you run into more trouble.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Mon Oct 20, 2014 8:54 am 

Joined: Thu Sep 27, 2007 5:51 pm
Posts: 48
Man, did I f@#k up here. Sorry for wasting your time guys, I must have felt asleep or something, because it's right there at the end of the
video. A bouquet of oopsie daisies were plucked.


Offline
 Profile  
 
 Post subject: Re: Shader VMK 20 - Vertex Buffer Objects
PostPosted: Mon Oct 20, 2014 7:50 pm 

Joined: Mon Mar 24, 2014 2:25 pm
Posts: 69
Awesome, glad you were able to figure it out! Don't apologize, part of learning! I'm always asking questions in various places.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 19 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron