OpenGL programming

Started by
10 comments, last by SolDirix 10 years, 4 months ago

Hello there...I am a beginner to graphics and game programming.I have a doubt.What do you mean by OpenGL programming?Is it the same as C++ graphics programming?

Advertisement

In general....OpenGL programming is c++ "graphics programming". Why i say that?

Because to code something which has graphical elements you need external libaries which

support such feature like OpenGL.

So C++ itself cannot do any graphical stuff at all. First additional libaries which their

API's allow the programmer to use function or classes that allow graphical programming.

Again OpenGL is such a libary. SDL would be an other one as example.

So OpenGL is a library.Which has built in functions for our uses...Its what helps us to do graphics programming.What we call OpenGL code is actually C++ code right?

  • I would not say built in functions, because the library itself provides functions we need for our purpose. In the library itself is nothing "built in"
    • but simply said yes you are right
  • OpenGL Code
    • if you use c++ as code language and use the OpenGL library then yes

OpenGL is a standard which can be implemented by just about anyone. Graphics drivers typically have OpenGL implementations installed with them. OpenGL specifies a C implementation, and the driver creators implement that by following the standard.

When you install Windows, it comes with a decades old OpenGL 1.1 dll. If you install graphics drivers from vendors who have modern implementations of OpenGL you can go all the way to OpenGL 4.2.

The most widely supported OpenGL version now is OpenGL 3.x. Some laptops with no GPU support OpenGL 2.x only. Please don't use it. Use 3.x.

As I said, OpenGL is a C-specification, and its a rasterizer. It doesn't require being hardware accelerated, but it sure helps.

To write your own OpenGL backend is very time consuming, but you'll learn alot. If you want to make games, don't do it. If you want to learn, go ahead. It can be frustrating, but very rewarding.

EDIT: I should probably add that a C-library works with C++. C++ can be thought of as an extension of C. C tends to have baggage from ye olde, but is very straightforward, while C++ has more functionality and stricter rules which could enable safer coding, and in some cases could end up with a class-hierarchy soup.

You will want to have classes in game programming, because projects tend to get big, fast. Abstracting away things which can go wrong into safe to use classes help alot. Just don't go overboard. If you find yourself overloading (float) in your vector class, you know you need counselling.

good luck!

C++ can be thought of as an extension of C. C tends to have baggage from ye olde, but is very straightforward, while C++ has more functionality and stricter rules which could enable safer coding, and in some cases could end up with a class-hierarchy soup.


I found thinking like that to be unhelpful and sometimes even dangerous. There was a time when C++ was indeed an extension of C (and C++ compilers actually worked by generating intermediate C code from the source C++ code). Those times are long gone though.
C and C++ are very different languages and they require completely different mindsets to work with efficiently. People who think of C++ as an extension of C very often end up with some kind of primitive 'C with classes'. They very often end up getting the disadvantages of both languages and the advantages of neither.

Obviously, you need a bit of C. Crossing library borders without a clean, pure C interface is either suicidal or requires strict rules and well-defined assumptions. But code from just about all languages communicates with each other over some kind of C interface - that is no reason to start thinking of one of those language as an extension of C though.

OpenGL, like directx, are bits of code stored in a dll. It doesn't matter which language use them, as long as the language can load dlls, and you have the proper include files to access those functions from the dll, you'll be fine. For example, you could do OpenGL or dx in delphi or c# if you want to, it's just a bit more trouble to make it work at first, but when you're setuped, it's pretty much the same as c++.

Learning pure opengl is not easy at first, but fesable. You could start with glut since it handle the setup of a basic application for you, which mean you can concentrate on the code that really matter. Or try something like SDL.

OpenGL, like directx, are bits of code stored in a dll. It doesn't matter which language use them, as long as the language can load dlls, and you have the proper include files to access those functions from the dll, you'll be fine. For example, you could do OpenGL or dx in delphi or c# if you want to, it's just a bit more trouble to make it work at first, but when you're setuped, it's pretty much the same as c++.

Learning pure opengl is not easy at first, but fesable. You could start with glut since it handle the setup of a basic application for you, which mean you can concentrate on the code that really matter. Or try something like SDL.

what is pure OpenGL?

I would guess he meant writing OpenGL code without any helper libraries. That is usually not a good idea. There is a lot of boiler plate code to be written until you get a window you can draw in. SFML, GLFW or SDL both simplify that process massively and are relatively easy to use (and cross-platform). I would not recommend GLUT.

If you are working on Windows you will also want GLEW since you only get (completely useless) OpenGL 1.1 out of the box.

Then each language will have different codes while working with OpenGL right?There is no OpenGL code..Only C++ or any other language code implementing OpenGL functions..right?

This topic is closed to new replies.

Advertisement