al_set_clipping_rectangle behaivor
AMCerasoli

Guys I don't understand how the clipping rectangle function works.

I'm drawing a rectangle using this:

    int x,y,w,h;
    al_get_clipping_rectangle(&x, &y, &w, &h);
    std::cout<<"x: "<<x<<" y: "<<y<<" w: "<<w<<" h: "<<h<<std::endl;
    awDrawRectangle(x,
                    y,
                    w,
                    h,
                    255, 0, 0, 255, false);

and setting the clipping rectangle like this:

        al_set_clipping_rectangle(mouse.posX,
                                  mouse.posY,
                                  mouse.posX+50,
                                  mouse.posY+50);

And I'm getting this:

video

I don't understand why that's happening. Shouldn't I see only that tiny rectangle filled with the back-buffer bitmap?

Edgar Reynaldo

You're passing the bottom right x and y instead of the width and height.

al_set_clipping_rectangle(x,y,w,h);

AMCerasoli

Oh it's true man! hehehe I'm burned out, too much programming for now, I was unable to see that, so the function already adds the width and height relative to the position.

Edgar... :-* Eeeedddgaaar :-* Come on, say yes... :-*:-*

Edgar Reynaldo

Sorry AMC, my heart belongs to someone else. :P

Thread #614179. Printed from Allegro.cc