I would like to ask you to share your experience about using core OpenGL API with C/C++ (and making own wrapper classes) vs using available C++ OpenGL libraries.
What are pros and cons of using C/C++ (please without performance wars). I am newbie in OpenGL area, and have some experience in C and much more in C++.
There is much more resources about C (GL) then C++(GL) available online… So can someone recommend me C++ library worth of learning if this is way to go.
I’d have to say: when you start wrapping, go for C++.
Once you go beyond simple experiments, you’re better off with C++ because you can make your code a lot cleaner. (vector classes, different behaviour for different types of objects etc).
And you can still use the C functions from C++ anyway, so you might as well start with C functions in C++, and “grow” the code into classes.
the syntax is very free. in c++ you can define variables almost anywhere you want:
int main(argc, char *argv[]) {
for(int i = 0; i < 100; i++)
printf(" %3i
", i);
float x = M_PI, y;
y = sin(x);
}
classes. you can define a vertex class, for example, with many different constructors, which allow you to simplify declaration of local objects in your code like
Vertex v1(1., 0., 0.), v2(0., 1., 0.); // define vertices with coordinates
Vertex v3(v1, v2, false); // v3 = diff vector from v1 to v2
Vertex v4(v1, v2, true); // v4 = normalized diff vector from v1 to v2
Vertex v5(v1, v2, 5.0); // v5 = diff vector from v1 to v2, length = 5. units
Originally posted by RigidBody:
[b]what exactly do you mean with C api?
if you program in c++, you still use C libs and include files like stdio.h, stdlib.h, string.h, math.h … PLUS additional c++ libs.[/b]
Probably my bad english.
OpenGL api is C api. Correct?
I can use it:
-as it is, pure C
-as it is, (plus own made classes C++)
-as(in) some higher level OpenGL C++ library ???
You already answered my first question, in your first reply. Second one was about existing C++ libs for ogl programming.