Vertex buffers, using glut

graphics

Vertex buffers, using glut

Postby alloh » Mon, 14 Mar 2005 19:05:09 GMT

Hi,

I'm trying to work out how to use vertex buffers using the 
GL_ARB-vertex_buffer_object extension.  I have been working in linux 
using glut, but trying to stay as portable as possible.

Anyway, I'm trying to work out how to load the functions needed.  There 
are lots of web resources on how to do it using SDL library, but I can't 
find how to do it without using SDL.

I thought I could use glutGetProcAddress(...), but on one linux setup it 
said 'glutGetProcAddress' undeclared even though I included <GL/glut.h>.
I also was not sure what type it would return.

I see in Windows it's something like
PFNGLBINDBUFFERARBPROC glBindBufferARB = (PFNGLBINDBUFFERARBPROC) 
wglGetProcAddress("glBindBufferARB");

If I just use glXGetProcAddress, can I do something similar?  What do I 
use as the return type (instead of PFNGLBINDBUFFERARBPROC)?

Thanks for your help.

Re: Vertex buffers, using glut

Postby fungus » Mon, 14 Mar 2005 23:42:39 GMT



Yes, that's what you need to use.


PFNGLBINDBUFFERARBPROC is defined in "glext.h"
which you can get here:

 http://www.**--****.com/ 

-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

Re: Vertex buffers, using glut

Postby Rolf Magnus » Tue, 15 Mar 2005 00:59:19 GMT




Tried glew? See  http://www.**--****.com/ 


Re: Vertex buffers, using glut

Postby alloh » Tue, 15 Mar 2005 14:46:04 GMT







Thanks for your help.  Now I'm doing something like this:

PFNGLBINDBUFFERARBPROC pglBindBufferARB = NULL;
pglBindBufferARB = (PFNGLBINDBUFFERARBPROC) 
glXGetProcAddress("glBindBufferARB");

I hope this isn't a stupid question, but I'm getting an error due to an 
"invalid conversion from `const char*' to `const GLubyte*'.  How can I 
prevent this?  Casting didn't seem to work :/

Also, I noticed in glext.h that the function glBindBufferARB is already 
defined.  Is the above still necessary?  I'm a bit confused as to what 
the glXGetProcAddress is doing.  The way I understood was this was to 
load the function that may be defined by the drivers.. I assume it is 
necessary in non-Windows implementations.  The glBindBufferARB function 
didn't seem to work if I called it directly.

If I can't get this going, I might try GLEW - it looked quite good.

Thanks again.

Re: Vertex buffers, using glut

Postby fungus » Tue, 15 Mar 2005 19:05:39 GMT



Dunno. Ask the people who wrote your compiler...


No it isn't. There's a function prototype but that's
not the same thing. You still need to have your own
pointer somewhere in your program.


-- 
<\___/>
/ O O \
\_____/  FTB.    For email, remove my socks.

Re: Vertex buffers, using glut

Postby Rolf Magnus » Tue, 15 Mar 2005 23:44:48 GMT







GLubyte is usually a typedef for unsigned char.


Hmm, on my Linux box, I can use it directly. The problem about that is that
your program then will only run if the OpenGL library actually supports
that extension. If you try other ones, you'll get a linker error. To
prevent this, you don't call the function directly, but instead try to get
a pointer to it and only call the function through that pointer. In this
case, the linker isn't involved, so your program will still link if the
function isn't provided, so it can contain a fallback solution for OpenGL
implementations that don't support the extension.


It is.


Re: Vertex buffers, using glut

Postby alloh » Wed, 16 Mar 2005 15:04:17 GMT

Thanks again guys.  I solved the GLubyte* problem, for some reason it 
worked with casting if (and only if) I stored the intermediate result as 
a GLubyte* and then used that.

I'm getting closer.  However, I now have a linking problem.  Although it 
compiles fine, I get an error when linking saying "undefined reference 
to `glXGetProcAddress'".  I was thinking this might be due to missing 
glx libraries?  I am using '-L/usr/local/lib -lGL -lGLU -lglut 
-L/usr/X11R6/lib'

Any ideas?

Re: Vertex buffers, using glut

Postby JB West » Wed, 16 Mar 2005 23:34:33 GMT






Order is important. Try -lglut -lGLU -lGL
jbw



Re: Vertex buffers, using glut

Postby alloh » Thu, 17 Mar 2005 15:49:38 GMT









Thanks for the help, but I still get the error.

Re: Vertex buffers, using glut

Postby alloh » Fri, 18 Mar 2005 14:02:25 GMT

Thanks for the help everyone, I have solved the problem by using 
glXGetProcAddressARB (was using glXGetProcAddress before) - and by 
defining GLX_GLXEXT_PROTOTYPES.








Re: Vertex buffers, using glut

Postby Ian Romanick » Thu, 07 Apr 2005 01:46:09 GMT

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1




What compiler are you using?  doing 'glXGetProcAddressARB( (const
GLubyte *) "foo" );' shouldn't generate any compiler warnings or errors.


Depending on how old your libGL is, you may need to use
glXGetProcAddressARB.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Fedora -  http://www.**--****.com/ 

iD8DBQFCUsDPX1gOwKyEAw8RAk3yAJ0d2Iitxp/rfc+x+NVU4onSdH04MACgkkkT
yadS5jf5nBtAB/CFAXnflQo=
=Hugt
-----END PGP SIGNATURE-----

Similar Threads:

1.Changing vertex color after vertex buffer and index buffer definition

Hi,

Say you have this custom vertex structure:

struct CUSTOMVERTEX
{
	float x, y, z;
	DWORD color;
};

Is it possible once you've defined values for a vertex 
buffer using that structure to subsequently change the 
color for a vertex that you defined? If so, how?

Thanks :)

2.Problem cleaning up after using vertex buffer.

Ok.. so I tried to take my first step to create a 3D object with VertexBuffers but I have a problem cleaning up. For some reason, after I do CreateVertexBuffer call and I try to exit the application, it keeps saying "reference count for D3D object is non-null". I am releasing the vertex buffer before I exit the application, and I'm using D3DPOOL_MANAGED for vertex buffer. 
Am I missing an important step here? Tutorial doesn't really have any special clean up either but it works fine for tutorials and samples. If anyone can give me few pointers or things to watch out for, I would appreciate it. Or if anyone can tell me what I"m doing wrong, that would even be better. ^^; Thanks. 

3.Animation using Vertex Buffer Objects

If I want to animate a large model stored in a VBO, does that mean I
have to map the buffer to change the value every frame of animation?
It seems like that would drop the framerate considerably.

4.vertex buffer, index buffer

there is setup time internally both for a VB and for a particular 
FVF/components. its less if you stay with the same format/stride, but there 
is still some cost with switching just the VB.

minimize it if you can without heroic rewriting, but dont worry about it if 
its a huge rewrite unless you measure thats a significant factor in your 
particular performance signature.

tools are required for measurement. VTune or other static performance 
analysis tool and a dynamic analysis tool like Pix that shows your API usage 
per frame is good, you can zero in on most issues that way.

"Hanna-Barbera" < XXXX@XXXXX.COM > wrote in message 
news: XXXX@XXXXX.COM ...
> Hi,
>
> Does switching VB and IBs a lot cost too much?
> Is it better to store multiple things to be rendered in one VB/IB?
> Is it considered one of the costliest things, that must be dealt with.
> What about the size of the buffers.
> I know 16 bit indices are recommended, which is what I use.
>
> I know my question is abstract, but I would like to know in relative 
> terms,
> compared to swithcing textures, switching shaders, and so on.
>
> Right now, my engine may be switching texture, and VB and IB per object.
> Shader are not switched so often cause the object's share the same shader.
>
> Thanks
>
> 


5.Large Vertex Buffers and Vertex Streams?

6. Vertex Arrays, Vertex Buffer Objects

7. How to set the Precision of Depth Buffer in GLUT

8. Vertex buffer and multiple matrices?



Return to graphics

 

Who is online

Users browsing this forum: No registered users and 28 guest