The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Best way to use transformation matrices?
razerwolf


Joined: 23 Aug 2013
Posts: 5
Location: United States
I was wondering what the best way to use transformation matrices with SDL2, Previously I have had success with SDL_RenderCopyEx, but now in order to get the desired effect, I need to do several transformations in order to get the effect I want:
Code:

    glPushMatrix();
    glTranslatef(xTranslation, yTranslation, 0);
    glRotatef(imageRotation, 0,0,1);
    glScalef(xScale, yScale, 1);
    glRotatef(rotation, 0,0,1);
    SDL_RenderCopy(renderer, texture, NULL, &(SDL_Rect){-rotationCenterX, -rotationCenterY,textureWidth, textureHeight});
    glPopMatrix();

Is this safe to do? is there anyway to ensure that a renderer is using OpenGL? or should I check the rendererInfo for which driver is being used (OpenGL, DirectX, or GLES) and modify my code accordingly?