Re: [SailfishDevel] Landscape mode in Sailfish?
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
Re: [SailfishDevel] Landscape mode in Sailfish?
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? 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
Re: [SailfishDevel] Landscape mode in Sailfish?
On 05 Apr 2014, at 09:29, Iosif Hamlatzis wrote: > Is there a c/c++ (not Qt and QML) API that I can use to force landscape mode? > > Generally speaking is there an API (not Qt and QML) documentation anywhere? In general, you can use set_buffer_transform on the Wayland surface: http://wayland.freedesktop.org/docs/html/protocol-spec-interface-wl_surface.html You also want to set the orientation and/or other window flags, that’s a Wayland protocol extension from QtWayland, which lipstick (the window manger in SFOS) uses: https://github.com/qtproject/qtwayland/blob/stable/src/extensions/surface-extension.xml In SDL, you can get the Wayland display, surface and shell surface via the SDL_syswm interface: https://hg.libsdl.org/SDL/file/default/include/SDL_syswm.h In almost all cases, it’s better to just rotate the contents of your drawing (by doing a 90 degree rotation in your projection matrix) and then also map the input events. This makes it a little easier for the compositor to optimize drawing of fullscreen content, and gives the compositor better chances of ideally just reading out the window contents directly onto the framebuffer without any additional transformation (independent of whether or not the target device has hardware composer functionality or not - in case it has, it might not be so problematic, but in case the target device doesn’t have a hwc or it isn’t used fully, the rotation to frame buffer orientation would have to happen using GL, and that takes away some fill rate [think: textured fullscreen quad] from the GPU’s per-frame budget at runtime - mapping input events and modifying the projection matrix on resize is very very very cheap in comparison). A simple resize function that is rotation-aware could look like this: bool resize(int w, int h) { setViewport(0, 0, w, h); projection = Matrix4x4(); if (h > w) { std::swap(w, h); projection *= Matrix4x4::rotation(-90.f, 0.f, 0.f, 1.f); rotated = true; } else { rotated = false; } // do your normal projection things here } When you call that method you store the “rotated” value somewhere and then access it when input events come in to transform their coordinates (for a more generic approach, you can also un-project the projection like the old gluUnProject does, and don’t have to care about rotation or not - you will always turn window coordinates into object coordinates): Point2D maptouch(Point2D pos) { if (rotated) { return Point2D(height - pos.y, pos.x); } return pos; } HTH :) Thomas ___ SailfishOS.org Devel mailing list
[SailfishDevel] Landscape mode in Sailfish?
Is there a c/c++ (not Qt and QML) API that I can use to force landscape mode? Generally speaking is there an API (not Qt and QML) documentation anywhere? ___ SailfishOS.org Devel mailing list