8

I want to know if there is a possibility of using OpenGL in C without even scratching c++, tutorials or basic source codes are most welcome!

And if it is possible, how deep would my C skills have to be to understand and use it? I'm currently still mostly learning, and I like to do that by biting off more than I can chew.

genpfault
  • 51,148
  • 11
  • 85
  • 139
BigBadWolf
  • 603
  • 2
  • 8
  • 17
  • Yes. You can use OpenGL with only C, but I can't think of any tutorials that cover that. There's a lot of nifty features in C++ that makes your life easer (not to mention the wide range of libraries that can compliment your program and reduce development time). Although I can think of cases where C++ just isn't an option. Is there something specific your aiming at? Perhaps we can give better suggestionz if we know what your end goal is. – Xonar Nov 16 '13 at 21:39
  • As I said, I am still learning. And before I take off to C++, I want to be confident with my C skills, since I need them as an ongoing Engineer. But what really motivates me, I have to say, is just my interest how the graphics work on a fundamental machine level, and the polar opposite, and that is how those beautiful graphics engines, like CryTec etc, are written. I appreciate it, thanks! – BigBadWolf Nov 16 '13 at 23:03

1 Answers1

23

OpenGL is a C library, not a C++ one.

The only thing why almost all programs use C++ for OpenGL is there is a higher and simpler level manipulating it through some wrappers, libraries or frameworks. It's just more comfortable.

Here are some good examples which were distributed along with the OpenGL "Redbook" (version 2.0).

However, those examples use old-style OpenGL (rendering through functions), which is deprecated, you should always use shaders and buffers instead. Although I think for beginning it can help.

Here on StackOverflow was also discussed where to find new OpenGL examples.

Beyondo
  • 2,952
  • 1
  • 17
  • 42
Zaffy
  • 16,801
  • 8
  • 50
  • 77
  • 1
    those examples use "old" style OpenGL. I don't think you should encourage people to learn it. (Although I agree that it's a good example of what the author wanted - OpenGL with C) – Xonar Nov 16 '13 at 21:42
  • @Xonar You're right I almost forgot about that. Thanks – Zaffy Nov 16 '13 at 21:45
  • @Zaffy: OpenGL is not really a library (despite its name), it's mostly an API specification. I backronymed it to Open Graphics Layer. – datenwolf Nov 16 '13 at 22:54
  • @datenwolf It is a library. But implementations may vary by specific vendors. – Zaffy Nov 16 '13 at 22:56
  • @Zaffy: Yes, that is another reason why I was confused. In the OpenGL wiki it explicitly stated that it is not a library and thus not #included and the language doesn't matter, while the specifications said it was a C based library. So, this "redbook" is outdated. And OpenGL is still based in C, if I'm correct? So - are there any C examples for the new generation of OpenGL? Much obliged, thank you! – BigBadWolf Nov 16 '13 at 23:00
  • @Zaffy: No, OpenGL **is not** a library. It's an API specification and there is no requirement in the specification whatsoever, that it's to be linked into a program as a library. It could very well be implemented in the form of messages that are sent using protocol buffers directly to the GPU. Or look at GLX/X11 transport. Just because you link a interface hook library into your program to use OpenGL doesn't mean that OpenGL, or any implementation of it, is tied to a library at all. – datenwolf Nov 16 '13 at 23:29
  • @BigBadWolf Take a look [here](http://stackoverflow.com/q/4559286/823738) – Zaffy Nov 17 '13 at 09:51