Quake3World.com Forums
     Programming Discussion
        Ceating a vertex buffer object in Q3


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Ceating a vertex buffer object in Q3

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 07-15-2015 11:51 AM           Profile Send private message  E-mail  Edit post Reply with quote


I've been trying to get Quake 3 to use a vertex buffer object (VBO). I feel like I'm a step away from it working but for some reason at startup I get the message "... GL_ARB_vertex_buffer_object not found" I've even tried porting much of the code from io urban terror's VBO, and got the same message. It just won't detect the GL_ARB_vertex_buffer_object in win_glimp.c It feels like I'm forgetting to include something that links Q3 to something in opengl. I'm willing to send the engine code parts off to anyone who knows about the subject to see what's wrong. Bare with me, I don't have internet at home and can only check this forum when I'm in town.

And let me prerespond to all of the following responses that are actually nonresponses to this subject:
I'm not looking to start this project all over from another engine like ioquake 3 or some offshoot of it, or Doom3, or Unreal engine, etc. The answer to how do you do something is not 'do something else.' The subject here is how to get a VBO working with regular Quake 3 code. I've seen some projects out there do it and I was wondering how they did.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 42131
PostPosted: 07-16-2015 12:05 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Captaintoottoot wrote:
The answer to how do you do something is not 'do something else.'

I don't have an answer for you, sorry, but I'd give you a +1 thumbs up for this comment if I could.




Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 07-16-2015 05:58 PM           Profile Send private message  E-mail  Edit post Reply with quote


I guess a short summary question of this topic would be: What would cause a GL extension to not be seen by Quake 3? I'm going to spend the next couple days looking into what's different with Q3 and io urban terror.




Top
                 

Recruit
Recruit
Joined: 28 Jan 2011
Posts: 6
PostPosted: 07-17-2015 09:09 PM           Profile Send private message  E-mail  Edit post Reply with quote


You have to import OpenGL functions. For windows look in win_qgl.c and qgl.h.




Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 07-20-2015 03:06 PM           Profile Send private message  E-mail  Edit post Reply with quote


I actually replaced all of win_qgl.c and qgl.h with io urban terror's just to see if it would work and nothing. Cyberstorm, what do you mean when you say 'import openGL functions? Is there some extra step i'm not doing?




Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 07-21-2015 02:31 PM           Profile Send private message  E-mail  Edit post Reply with quote


Let me post come code to show what I'm talking about.

In QGL.h:
Code:
#ifndef GL_ARB_vertex_buffer_object
#define GL_BUFFER_SIZE_ARB                0x8764
#define GL_BUFFER_USAGE_ARB               0x8765
#define GL_ARRAY_BUFFER_ARB               0x8892
#define GL_ELEMENT_ARRAY_BUFFER_ARB       0x8893
#define GL_ARRAY_BUFFER_BINDING_ARB       0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
#define GL_READ_ONLY_ARB                  0x88B8
#define GL_WRITE_ONLY_ARB                 0x88B9
#define GL_READ_WRITE_ARB                 0x88BA
#define GL_BUFFER_ACCESS_ARB              0x88BB
#define GL_BUFFER_MAPPED_ARB              0x88BC
#define GL_BUFFER_MAP_POINTER_ARB         0x88BD
#define GL_STREAM_DRAW_ARB                0x88E0
#define GL_STREAM_READ_ARB                0x88E1
#define GL_STREAM_COPY_ARB                0x88E2
#define GL_STATIC_DRAW_ARB                0x88E4
#define GL_STATIC_READ_ARB                0x88E5
#define GL_STATIC_COPY_ARB                0x88E6
#define GL_DYNAMIC_DRAW_ARB               0x88E8
#define GL_DYNAMIC_READ_ARB               0x88E9
#define GL_DYNAMIC_COPY_ARB               0x88EA
#endif


in win_qgl.c:
Code:
void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer);
void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers);
void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers);
GLboolean (APIENTRY * qglIsBufferARB) (GLuint buffer);
void (APIENTRY * qglBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage);
void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data);
void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data);
GLvoid *(APIENTRY * qglMapBufferARB) (GLenum target, GLenum access);
GLboolean (APIENTRY * qglUnmapBufferARB) (GLenum target);
void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params);
void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params);


in win_glimp.c above GLW_InitExtensions():
Code:
static qboolean GLimp_HaveExtension(const char *ext)
{
   const char *ptr = Q_stristr( glConfig.extensions_string, ext );
   if (ptr == NULL)
      return qfalse;
   ptr += strlen(ext);
   return ((*ptr == ' ') || (*ptr == '\0'));  // verify it's complete string.
}

#define SDL_GL_GetProcAddress( a) qwglGetProcAddress(  a )


in GLW_InitExtensions() in win_glimp.c:

Code:
   vertexBufferObjects = qfalse;
   qglBindBufferARB = NULL;
   qglDeleteBuffersARB = NULL;
   qglGenBuffersARB = NULL;
   qglIsBufferARB = NULL;
   qglBufferDataARB = NULL;
   qglBufferSubDataARB = NULL;
   qglGetBufferSubDataARB = NULL;
   qglMapBufferARB = NULL;
   qglUnmapBufferARB = NULL;
   qglGetBufferParameterivARB = NULL;
   qglGetBufferPointervARB = NULL;
   if ( GLimp_HaveExtension( "GL_ARB_vertex_buffer_object" ) )
   {
      if ( r_ext_vertex_buffer_object->integer ) {
         qglBindBufferARB = (void (APIENTRY *)(GLenum, GLuint)) SDL_GL_GetProcAddress("glBindBufferARB");
         qglDeleteBuffersARB = (void (APIENTRY *)(GLsizei, const GLuint *)) SDL_GL_GetProcAddress("glDeleteBuffersARB");
         qglGenBuffersARB = (void (APIENTRY *)(GLsizei, GLuint *)) SDL_GL_GetProcAddress("glGenBuffersARB");
         qglIsBufferARB = (GLboolean (APIENTRY *)(GLuint)) SDL_GL_GetProcAddress("glIsBufferARB");
         qglBufferDataARB = (void (APIENTRY *)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum)) SDL_GL_GetProcAddress("glBufferDataARB");
         qglBufferSubDataARB = (void (APIENTRY *)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *)) SDL_GL_GetProcAddress("glBufferSubDataARB");
         qglGetBufferSubDataARB = (void (APIENTRY *)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *)) SDL_GL_GetProcAddress("glGetBufferSubDataARB");
         qglMapBufferARB = (GLvoid *(APIENTRY *)(GLenum, GLenum)) SDL_GL_GetProcAddress("glMapBufferARB");
         qglUnmapBufferARB = (GLboolean (APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glUnmapBufferARB");
         qglGetBufferParameterivARB = (void (APIENTRY *)(GLenum, GLenum, GLint *)) SDL_GL_GetProcAddress("glGetBufferParameterivARB");
         qglGetBufferPointervARB = (void (APIENTRY *)(GLenum, GLenum, GLvoid **)) SDL_GL_GetProcAddress("glGetBufferPointervARB");
         vertexBufferObjects = qtrue;
         ri.Printf( PRINT_ALL, "...using GL_ARB_vertex_buffer_object\n" );
      }
      else
      {
            ri.Printf( PRINT_WARNING, "...ignoring GL_ARB_vertex_buffer_object\n" );
      }
   }
   else
   {
      ri.Printf( PRINT_DEVELOPER, "...GL_ARB_vertex_buffer_object not found\n" );
   }



I start the game up and in the console I see the message "...GL_ARB_vertex_buffer_object not found"




Top
                 

Recruit
Recruit
Joined: 28 Jan 2011
Posts: 6
PostPosted: 07-22-2015 05:53 PM           Profile Send private message  E-mail  Edit post Reply with quote


Sounds like a driver problem. Does UT give u that message?




Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 07-23-2015 07:48 PM           Profile Send private message  E-mail  Edit post Reply with quote


I solved the problem. It's as as I thought weeks ago that it has nothing to do with programming. I deleted stuff out of the baseq3 directory and bam, it can see all of the beautiful extensions now. I think it was like pak3 or pak4 or something. That's it. heh. I'll never know what file specifically or what it was doing. But considering how long it took to just get q3 to see the gl extensions, once they have holodeck games invented I will probably have a fully functional VBO. sigh I'm having issues getting it to work. Maybe I'll post back in a couple weeks if I've hit another wall.




Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1622
PostPosted: 07-23-2015 11:06 PM           Profile Send private message  E-mail  Edit post Reply with quote


If you have corrupted PK3's (corrupted shader - syntax errors inside, e.g.) somewhere in the game files, it might corrupt entire game. And search for the reason then :(



_________________
[ Quake III Arena by CZghost | Facebook | Twitter | YouTube | Google+ ]
While you feel the worst ever, turn around facing to Sun and all shadows will pass behind you.” - John Lennon


Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 07-30-2015 06:30 PM           Profile Send private message  E-mail  Edit post Reply with quote


Ok this is agony. I've got something that almost works but think I've hit a wall. Basically it does everything that the IOUrbanTerror VBO does except it borks the lightmaps and draws the lightmap in place of any custom shaders. When I tested the same maps on IoUT, the lightmaps were also messed up. I know that IoUT limited their lightmap sizes to 128x128 and I've got larger ones in use. It looks like unless I totally redo it as sometihng new doing it the way IoUT did it will always produce the same borked results with the lightmaps and shaders. I wish I didn't even have to use fragment programs like they do. I give up... for a while anyway.




Top
                 

The Afflicted
The Afflicted
Joined: 21 Apr 2005
Posts: 505
PostPosted: 12-29-2016 10:15 PM           Profile Send private message  E-mail  Edit post Reply with quote


What would you need to use this "vbo" for? What's the purpose?




Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 12-31-2016 06:27 AM           Profile Send private message  E-mail  Edit post Reply with quote


Big ass maps with lots of stuff.




Top
                 

The Afflicted
The Afflicted
Joined: 21 Apr 2005
Posts: 505
PostPosted: 12-31-2016 04:29 PM           Profile Send private message  E-mail  Edit post Reply with quote


My understanding is that it speeds up rendering somehow by storing the information in a buffer?

Iirc it's just new for idtech3 since idtech3 is very old, right?




Top
                 

Grunt
Grunt
Joined: 28 Mar 2014
Posts: 55
PostPosted: 01-03-2017 05:07 AM           Profile Send private message  E-mail  Edit post Reply with quote


Yes. Its the process of storing all the static verts on the video card so it doesn't have to send it each frame. Saves on CPU bigtime. Most modern games do this always but idtech3 didn't. There are only a couple of Q3 mods out there that did it successfully. I wish I could get in touch with someone who knows how to do this. I almost had it at one point.




Top
                 

The Afflicted
The Afflicted
Joined: 21 Apr 2005
Posts: 505
PostPosted: 01-03-2017 06:39 PM           Profile Send private message  E-mail  Edit post Reply with quote


From what I'm seeing, Xreal does it and is open source:

https://sourceforge.net/p/xreal/svn/HEA ... unk/xreal/

Use the Download Snapshot button to get the source for the last version they released. You need to use the premake vs 10 or 2010 (iirc) file to produce the SLN. It should compile fine, but I can't get it to run in Debug, only Release. I keep getting a weird error about converting some larger datatype to a smaller one. "runtime check failure #2" or something.

In xreal the renderer project is a file packaged into the Xreal project, instead of Q3 which is its own lib. Also some files are in separate folders, if they're shared between projects, like how qshared is used.

Using something like winmerge to compare between Xreal's renderer code and Q3A'S might be a good starting point.

Might I ask, are you trying to implement better graphics, like enhanced shadows?




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group