I must draw lots of primitives with OpenGL (3.3, 4.2), I knew with glutSolidTeapot() ; I can draw a teapot primitive with glut.
But it seems there won't be a vertex array generated from this command, and I don't know if this kind of commands are deprecated or not.
And I noticed lots of modern OpenGL tutorials just loads their own primitives and avoided to just use glut, they even loaded simple geometry from 3d mesh format file.
My purpose is to just draw these primitives as quick as possible.And use the new OpenGL as much as possible.
So that how to draw primitives in modern OpenGL?
As GLUT (which is not part of OpenGL in any way) draws its primitves using immediate mode glBegin/glEnd
and using the deprecated fixed-function builtin attributes, you won't be able to use these anymore, if you want to concentrate on non-deprecated, modern core functionality.
Instead of using the builtin attributes (like glVertex
, glNormal
, ...) you have to use your own generic vertex attributes (in conjunction with an appropriate vertex shader, of course) and instead of glBegin/glEnd
calls you have to draw primitives using vertex arrays fed by VBOs and drawn using glDrawArrays/glDrawElements
and their derivatives.
Whereas nothing prevents you from storing the vertex data for these objects as variables in your source code or to generate them manually, loading them from files is the easiest and most generic way, at least for such rather complex objects like the Utah teapot. The Wavefront OBJ format is a rather simple ASCII based mesh file format that is quite easy to read and might be a starting point to look into, as it can be exported by virtually any modelling software.
Rendering with the new (non deprecated) OpenGL standards is done exclusively by using shaders.
Shader attribute can only be buffer objects.
Shortly, instead of having a set of arrays that specify vertex positions, colors, texture coordinates and so on, is client memory, you havfe to upload them in buffer objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With