# OpenGL using the video card

## Recommended Posts

Hi, I'm sure there is a simple answer to this, but I can't find anything that can tell me how to utilize the graphix card on a computer in OpenGL. Right now, i'm pretty sure anyways, all my graphics commands are processed by the CPU and that would slow down the computer. Is there an easy way to use my OpenGL commands, such as glVertex3f();, on the gfx card? any replies are appreciated

##### Share on other sites
I don't have a lot of experience in utilizing the graphics card for specific things (without having the graphics API as a level of abstraction between me and the gfx card), but I know that you can use VBOs (vertex buffer objects), which basically means that a set of geometry is stored on the graphics card, which makes rendering that set much faster.

And, you really shouldn't be using 'glVertexf', it would be better to start with vertex buffers.

But, no, I don't think that there is a lot that can be done to speed up a call to glVertex3f or anything else, as the vertex position still needs to be multiplied by the current model matrix and sent to the graphics card. Sending data to the gfx card will pretty much always take the same amount of time.

If you are interested, I believe that you'll find your answer, with the ARB Open GL extensions.

##### Share on other sites
Given any semi recent, not complete trash video card, transformation and Lighting will be done on the video card (I think the nVidia drivers may do some work on the CPU if they think there is a performance advantage). I'm fairly sure that the model matrix multiplication is included in Transformation and Lighting. Or in other words it's done on the card.

Now as for way your program is slow is because glVertex3f is a slow way to send geometry to the video card (As Endar said). Since each vertex requires a function call. There are two ways (that I can think of) to efficiently send geometry in large chunks, display lists and vertex arrays. Display lists are typically used for static geometry (they have some other uses). They can be setup with the glVertex3f syntax. Vertex Arrays allow you send arrays of vertexes and other per vertex values. So 1 function call for 10,000 vertexes, instead of 10,000 glVertex3f calls. VBOs allow you store the vertex arrays on the video card's memory. I think display lists are also stored on board the card.

All of the above have been standard for a quite a while and are no longer extensions. Although to use some of them may require going through the extension system (thanks Microsoft...). Glee or Glew will make using the extension system much easier.

##### Share on other sites

CG for example.

anything handled by the shader goed over the GPU. however, this GPU / CPU tradeoff is not simply to does as much as possible over the GPU.

and for the rest you should turn to vertex array for speed boosts of vertex buffer object like mentoined before.

the speed will be maximal when giving fixed vertices to the shader through a buffer/array and altering their position in the shader. However, as I said, beware of the tradeoffs, they are everywhere. Their is no simple way too speed up everything at once.

The most speedgains however will result from your skillz as a programmer, differentiate proper between static stuff and dynamic stuff (both types are maximized differently) , proper debugging and converting a good release file (this alone gives about 30fps)

##### Share on other sites
what you are all saying is "mostly" correct. The reason shaders, and transformation & lighting (T & L) are done on the card is because OpenGL is really a state machine. Now there's two parts to this state machine and they are known as the client and the server. The server is essentially the graphics card, so any operations performed by the server, such as T & L, inherently happen on the GPU.

If you want to utilize the GPU even more you can move your vertex (along with normals, colors, texture coords, etc.) over to "server" memory, or graphics card memory. This can be done by using VBOs or vertex buffer objects, which essentially load and store arbitrary data into the graphics card memory. This means we don't have to transfer this data from "client" memory (standard RAM) across the bus to the graphics card memory for these operations to be performed, thereby improving performance even further.

I'd recommend reading up on how the OpenGL state machine works, it will give you some good insight on these issues and plenty more :)

##### Share on other sites
so what was wrong with the post ? i didn't say anything untrue, right?

##### Share on other sites
Quote:
 Original post by EndarI don't have a lot of experience in utilizing the graphics card for specific things (without having the graphics API as a level of abstraction between me and the gfx card), but I know that you can use VBOs (vertex buffer objects), which basically means that a set of geometry is stored on the graphics card, which makes rendering that set much faster.

Not necessarily. The driver chooses where it will store something. If there is space in VRAM and your stuff is STATIC, it will likely be in VRAM.
If you use streaming, then AGP will likely b used. IN the case of PCIEx, regular RAM reserved by the driver.

BTW, VBOs are core since GL 1.5, so it doesn't make sense not to use them, whether you are a newbie or not.
The only reason to not use them is if you want to support very very old stuff.

##### Share on other sites
Thanks for the help, i realy appreciate it and i'll check this stuff out. :D

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627657
• Total Posts
2978472
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 10
• 12
• 22
• 13
• 33