Hi,

On 2014-04-07 13:00, Iosif Hamlatzis wrote:
ok I have managed to rotate my display and convert the touch co-ordinates but I have a lot flashes on the screen. I presume it has to do with the call to glScissor

At some places in my code I call glScissor and glGetIntegerv modify and retrieve the scissor box. If I don't call these there is no problem I have no flashes but obviously my rendering is wrong as I render outside my rectangle.

Does the rotation matrix (either in projection or model view mode) affect the glScissor and glGetIntegerv calls or do I have to manually calculate the rotation for the scissor box?

glScissor operates on "window coordinates" (just like, for example, glViewport):
https://www.khronos.org/opengles/sdk/docs/man/xhtml/glScissor.xml

How to get from object coordinates to world coordinates is described here:
http://www.opengl.org/sdk/docs/man2/xhtml/gluProject.xml
(you usually don't have gluProject available in GLES directly, as it's part of GLU)

In some simple cases, you might be able to just swap the axes and subtract the axis value from the width/height to rotate it by 90 degrees instead of going through the full matrix multiplication.

So yes, you have to manually calculate the rotation for the scissor box; the easiest being to do the same that gluProject does.


HTH :)
Thomas

The code I use for scissoring is:

//---------------------------------------------------------------------------------------------------------
RECT Presenter::ClippingRegion() const
{
RECT rc;
SetRect( &rc, 0, 0, mnScreenWidth, mnScreenHeight);

if ( glIsEnabled(GL_SCISSOR_TEST) )
{
GLint clip[4];
glGetIntegerv( GL_SCISSOR_BOX, &(clip[0]) );

SetRect(&rc, clip[0], clip[1], (clip[0]+clip[2]), (clip[1]+clip[3] );
}

return rc;
}
//---------------------------------------------------------------------------------------------------------
void Presenter::ClippingRegion(const RECT& rc)
{
glEnable( GL_SCISSOR_TEST );

GLsizei width = rc.right - rc.left;
GLsizei height = rc.bottom - rc.top;

GLint x = rc.left;
GLint y = rc.top;
GLint y_modified = mnScreenHeight-(y+height);

glScissor(x, y_modified, width, height);
}

Where in the above code RECT is a struct similar to Microsoft's RECT and SetRect(left, top, right, bottom) is a function similar to Microsoft's for setting left, top, right and bottom co-ordinates for a RECT.

So do I have to calculate the rotation for the parameters or is it automatically done by the rotation matrix?



_______________________________________________
SailfishOS.org Devel mailing list

_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to