Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with coordinate_mode = 1 (math coords) #211

Open
raivis-berzins opened this issue Dec 23, 2020 · 0 comments
Open

Problems with coordinate_mode = 1 (math coords) #211

raivis-berzins opened this issue Dec 23, 2020 · 0 comments

Comments

@raivis-berzins
Copy link

When using math coordinates and drawing an image with ever-increasing x and y coordinates, the image itself is flipped vertically and still moves from top-left to bottom-right, instead of the expected behavior of being upright and moving from bottom-left to top-right.

Code:

int main(int argc, char* args[])
{
    GPU_Target *target = GPU_Init(1024, 576, GPU_DEFAULT_INIT_FLAGS);
    if (!target)
    {
        GPU_LogError("no target");
        return 0;
    }

    GPU_SetCoordinateMode(1);
    GPU_Image *img =  GPU_LoadImage("data/test.png");
    
    float pos_x = 0.0f;
    float pos_y = 0.0f;

    float x_virt, y_virt;
    GPU_GetVirtualCoords(target, &x_virt, &y_virt, 5.0f, 5.0f);

    GPU_LogInfo("x, y: %f, %f\n", x_virt, y_virt);
    // output:
    // x, y: 5.000000, 571.000000
    // (as expected)

    bool quit = false;
    while (!quit)
    {
        SDL_Event e;
        while (SDL_PollEvent(&e))
        {
            if (e.type == SDL_QUIT)
            {
                quit = true;
            }
        }
        
        GPU_ClearRGBA(target, 220, 100, 200, 255);

        GPU_Blit(img, NULL, target, pos_x, pos_y);
        pos_x += 0.25f;
        pos_y += 0.25f;
        GPU_Flip(target);
    }
    return 0;
}

Behavior:
https://user-images.githubusercontent.com/67956318/103039776-59367580-457a-11eb-8ca0-169f7daef62d.mp4

If GPU_SetCoordinateMode(1); is omitted, everything works as expected: the image is normal, and the GPU_LogInfo prints x, y: 5.000000, 5.000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant