raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
22.65k stars 2.27k forks source link

[rlgl] Camera2D y-axis flip does not work as expected #3786

Closed planetis-m closed 9 months ago

planetis-m commented 9 months ago

Please, before submitting a new issue verify and check:

Issue description

I am trying to flip the y-axis of the Camera2D system, but nothing is shown on the screen when I do so. I used this SO question as a guide: https://stackoverflow.com/q/75783405 The expected result is to see a circle with the origin at the center of the screen. The actual result is a blank screen.

Environment

OpenGL vendor string: AMD
OpenGL renderer string: AMD Radeon Graphics (radeonsi, renoir, LLVM 16.0.6, DRM 3.49, 6.1.71-1-MANJARO)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.3.3-manjaro1.1
OpenGL core profile shading language version string: 4.60

Code Example

#include "raylib.h"
#include "rlgl.h"
#include <stdlib.h>

#define screenWidth 800
#define screenHeight 450

int main(void) {
    // Initialization
    // --------------------------------------------------------------------------------------
    // Set up the raylib window
    InitWindow(screenWidth, screenHeight, "raylib - perceptron");
    Camera2D camera = {0};
    // Move the origin to the center of the screen
    camera.offset = (Vector2){screenWidth/2.0f, screenHeight/2.0f};
    camera.zoom = 1.0f;
    SetTargetFPS(60); // Set our game to run at 60 frames-per-second
    // --------------------------------------------------------------------------------------
    // Main game loop
    while (!WindowShouldClose()) { // Detect window close button or ESC key
        // Update
        // ------------------------------------------------------------------------------------
        // Draw
        // ------------------------------------------------------------------------------------
        BeginDrawing();
            ClearBackground(RAYWHITE);
            // Reorient the canvas to match a traditional Cartesian plane
            BeginMode2D(camera);
                rlPushMatrix();
                rlScalef(1.0, -1.0, 1.0);
                DrawCircleV((Vector2){0, 0}, screenWidth, DARKGRAY);
                rlPopMatrix();
            EndMode2D();
        EndDrawing();
        // ------------------------------------------------------------------------------------
    }
    // De-Initialization
    // --------------------------------------------------------------------------------------
    CloseWindow(); // Close window and OpenGL context
    return 0;
}
veins1 commented 9 months ago

Negating Y axis switches what's considered clockwise and anti-clockwise. You can either switch backface culling accordingly or turn it off entirely.

planetis-m commented 9 months ago

@veins1 thank you for your comment, turns out it wasn't an issue with raylib after all.