Do I (really) need openGL?

Started by
15 comments, last by Irlan Robson 10 years, 7 months ago

I was following some tutorials on C++ with SDL and openGL, and as I was listening to the guy he mentioned what may be a key point for me: "openGL is an interface to your video card, so you can do 3D things".

So I was wondering, is this entirely true? Would I ever need openGL for 2D games?

I'm not planning on doing anything 3D and I guess I won't be for quite some time. So if this is true I may just skip openGL learning for now and focus on what I actually need.

I created a pointer of type Toilet so I don't have to go to the bathroom as often.

Advertisement

Thats a wrong conclusion. Ultimately you need something to tell your video card what to show, its irrelevant if its 3D or 2D.

You could learn some other library thats less useful for 3D, but you will need to learn some library anyway and then you possibly discover later you learned something less capable or less widely used and you have to relearn.

SDL can handle 2D graphics just fine (I recommend using SDL 2.0 since it has more flexibility in this regard) so you could just stick with that for the time being.

Indeed, I'm using SDL and not yet openGL but I was thinking of mixing them. So perhaps I will leave openGL aside for now, since I'm already a bit into SDL, and I may get back to it when I'm experienced enough that I can mostly write a game on my own without melting my brain.

I don't have a problem with learning it later. I have more of an issue with having too much to worry about now, it may become too confusing. I think I prefer to go a step at a time as they become needed.

Thanks both of you for your feedback.

I created a pointer of type Toilet so I don't have to go to the bathroom as often.

As mentioned above, OpenGL is more like something that tells the video card to do something. DirectX does the same, but it is only available on Windows.

In a certain sense, you do need OpenGL ( or DirectX ), but you don't always have to work with its code. Ultimately, SDL, Allegro, and the other similar libraries use OpenGL ( or DirectX ), but they provide a nice layer of abstraction so you don't have to mess with the low-level things.

Not entirely sure I understand. Does that mean these libraries may have "something" related to openGL within them?

I created a pointer of type Toilet so I don't have to go to the bathroom as often.

Not entirely sure I understand. Does that mean these libraries may have "something" related to openGL within them?

Yes, they are running on top of OpenGL, it means that they utilize it to render things on the screen. OpenGL and Direct3D are libraries, providing API to your video card hardware, this is true. The whole thing about 3D vs 2D is irrelevant, since they are essentially the same, they just utilize different projection matrices and coordinates.

Yes, I see. I remember now that some people made some actual 3D renderings with flash ActionScript 2, even though it was never intended to support it. And now that I think about it, it makes sense, since openGL (or any other such library) basically uses "raw" C++ (or the associated language) to achieve what it does.

So I guess it basically comes down to "do I need a video card or not?". Would a game made solely with SDL or Allegro (or FSML) only ever use the CPU? (considering that I wouldn't know how to deal with a video card on my own, purely with C++, I would assume so)

And just by the way, would you consider using the video card for even 2D games like say, a tetris clone, or an adventure game based on static images, or a platformer like Metal Slug)? I ask this just because I'm wondering when will I cross the line between good performace just using the CPU and the need for a little help from the video card.

Sorry if I'm asking lots of questions, I just want to have a consistent understanding of what I'm doing and what I'm dealing with.

I created a pointer of type Toilet so I don't have to go to the bathroom as often.

About the 2D/3D: most 2D/3D related calculations can easily be extended (A 2D vector addition can also be done as a 3D addition with the last element zero) and most API's accept 2D data as well. This means that you can perfectly use the OpenGL/Direct3D or any abstraction (SDL/SFML/Allegro...) for 2D games and still utilize the power of the GPU. Given that a GPU has a raw processing power that is far beyond a CPU's, even for simple 2D games like platformers I'd recommend using it.

About the "do I need a videocard"; the whole pipeline goes a little like this:

Application <-> (optional) Abstraction layer (such as SDL) <-> OpenGL/DirectX <-> Video Drivers <-> Hardware

This means that if there is a video driver that uses the CPU instead of the GPU; then you can run a game without a videocard but given the fact that the CPU has a lot less processing power (but is a lot more flexible) it probably won't be very smooth.

The hardware (GPU's) are there because they offer enormous amounts of power,

The drivers are there because every hardware is different and every vendor has their own architectures, (and because of this writing code directly for one GPU architecture is a very bad idea!)

The OpenGL/Direct3D api's are there because they standardize calls: you don't want vendors to include their own special features so you have to write your graphics code only once to run on all GPU's that support a certain OpenGL/Direct3D level,

The abstraction layers are there because the OpenGL and Direct3D API's are suited for all possible graphics applications and libraries such as SDL make certain applications easier (and often provide other features such as input handling which a graphics API doesn't provide).

Yes, I see. I remember now that some people made some actual 3D renderings with flash ActionScript 2, even though it was never intended to support it. And now that I think about it, it makes sense, since openGL (or any other such library) basically uses "raw" C++ (or the associated language) to achieve what it does.

So I guess it basically comes down to "do I need a video card or not?". Would a game made solely with SDL or Allegro (or FSML) only ever use the CPU? (considering that I wouldn't know how to deal with a video card on my own, purely with C++, I would assume so)

And just by the way, would you consider using the video card for even 2D games like say, a tetris clone, or an adventure game based on static images, or a platformer like Metal Slug)? I ask this just because I'm wondering when will I cross the line between good performace just using the CPU and the need for a little help from the video card.

Sorry if I'm asking lots of questions, I just want to have a consistent understanding of what I'm doing and what I'm dealing with.

Well, I can't even imagine the situation where you don't have graphics card on user desktop with friendly OS. It is integrated into motherboard, into CPU or discrete. CPU alone couldn't process modern OS user interface and maintain the good performing business logic at the same time, because rendering task is extremely hard if you do not parallelize it by means of additional accelerator.

I think you are confusing general C++ concepts with GPU concepts. GPU is a SIMD processing unit, which has its own driver from manufacturer, which hides hardware specifications and provide more friendly and common interfaces to OpenGL and Direct3D. C++ doesn't have to do anything with GPU, it just manages GPU through some kind of interface, provided by video card's manufacturer.

Regarding 2D games. You can use whatever game engine you want, but know this - they will utilize OpenGL or Direct3D in order to present your game onto the screen. Usually those kind of engines are providing simple user-friendly interface and hide rendering mechanism, but at the end of the day, even emulated or "software" rendering will be presented on your screen by means of video card, thus utilizing OpenGL or Direct3D on OS level.

This topic is closed to new replies.

Advertisement