jnkvcu
jnkvcu

Reputation: 11

How to implement only a part of OpenGL code to game that is written using SDL?

So, I am making a game similar to Vector Runner. I have a background texture and a couple of texture object all implemented using SDL. I want to rotate background using glRotate. I don't want it to move or anything, I just want to have different view at it (similar to third person view) and leave it that way. Since everything is SDL right now, can I just make background.h and .cpp and implement OpenGL only there or do I need to use it through the whole code, or is there a way to do it using SDL?

Upvotes: 0

Views: 93

Answers (1)

rel
rel

Reputation: 794

Personally, I wouldn't try to mix OpenGL with SDL's 2D surface type code. I would either implement the sprites also with OpenGL (faster, more options for manipulation) or use SDL functions where possible (simplest option) or use software rendering to rotate the background (very portable and all under your control).

I want to rotate background using glRotate. I don't want it to move or anything, I just want to have different view at it (similar to third person view) and leave it that way.

If you want to do the rotation yourself, you could use texture mapping techniques, and render it yourself pixel by pixel. And if the background doesn't move, you would only have to do this once and store the result in a buffer.

SDL also has a render function that gives you an option to rotate the source image (without perspective transformation options): https://wiki.libsdl.org/SDL_RenderCopyEx

Upvotes: 1

Related Questions