Reputation: 1011
When I use:
glUseProgramObjectARB(program);
DrawCube();
glUseProgramObjectARB(0);
Where function DrawCube() is:
DrawCube(){
glBegin(GL_QUADS);
glVertex3f(... data ...);
glVertex3f(... data ...);
glVertex3f(... data ...);
glVertex3f(... data ...);
glEnd();
}
My questions is: Does this function is performed on the graphics card? Is it faster if I use direct mode [glBegin() - glEnd()] or if I use VBO?
Upvotes: 0
Views: 209
Reputation: 117
Now a days OpenGL Fixed pipeline is removed from most of the graphics pipeline. Everything is done with shaders. In order to preserve compatibility, the GL driver generates a shader which emulates the fixed functionality.
If u want to get a performance boost, u have to use VAO,VBO with shaders and perform ur own mathamatics.there are plenty of math libraries that are compatible with the new version of GLSL implementations. example : http://glm.g-truc.net/
VBO are used to copy the primitive data form Computer memory to GPU memory.VAO is the collection of VBO , which can be implemented using one VAO call.
also during implementation of shaders u have to check for the shadres version used , as many of the function are deprecated in higher version of GLSL implementations. References: http://en.wikipedia.org/wiki/GLSL
Upvotes: -1
Reputation: 162317
The use of shaders and the method used to send in geometry are orthogonal, i.e. the one thing has nothing to do with the other.
The big problem with Immediate Mode is, that it hogs your CPU, as all these little calls go up and down through plenty of code. The secondary problem is, that both Immediate Mode and Client Side Vertex Arrays are limited by system bus bandwidth. To put this into numbers: PCI-Express Gen 3 with 16 Lanes can transfer about 15GiB/s (in practical applications it's more like 10GiB/s). The GPU memory is connected with bandwidth of at least 10 times that. By using a VBO^1 you can make the GPU draw huge amounts of geometry by sending only a few bytes (whatever the glDrawElements command translates into).
Shaders OTOH are the little programs executed on the GPU that turn geometry data into on-screen-locations and fill them with pixel values. The shader doesn't care which way the data was sent into the GPU. Also "not using" a shader doesn't mean things don't happen on the GPU. For one there are default shaders written in-situ to match the configured fixed function state. And even if that wasn't the case, what makes you think not using a shader would put things off the GPU?
[1] Vertex Array Objects are only abstract state holders, collecting a set of VBOs and which vertex attributes they're bound to.
Upvotes: 2
Reputation: 11496
Although the tests in this link show that using fixed mode vs programmable has no noticeable performance difference , I must say that I don't "buy" it .The tester doesn't show his benchmark source code.And I suspect his programmable test was not "clean " enough.I can just say from my personal experience.I had an old engine written with the old (GL 2.1) which we then had rewritten to GL4.2 fully programmable pipeline.We got clear ,at least %80 performance boost and in some modules ,like offscreen FBO rendering we got 300% performance boost.And I am even not touching effects and post -processing stuff most of which would be slow de-facto or just impossible without using programmable pipeline.
Also take a look at this link which explains fixed vs programmable pipeline.
Upvotes: 3