PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

iPhone - Emulating landscape orientation

Hi! I've tried the temporary solution suggested in this thread in order to emulate a landscape orientation on iPhone, but all I got was a black screen.

I switched back to Visual Studio in order to make OpenGL work on PC first and found out that the following transformation works as expected (I'm attaching a screenshot that shows the program output):

Code:

glTranslatef(320.0f, 0, 0);
glRotatef(90.0f, 0, 0.0f, 1.0f);


As a side note, I've also made the following function call inside ClassMain::OnDisplayInit:

Code:

ecd.dsp->Perspective2D(320,480,false);


I still don't know why am I not getting a correct output on the iPhone, maybe a missing flag or something?

Thanks in advance for your answer!

--Nacho
Attachments:
FlipDisc-320x480-Win32.rar (277 KB)
Hi Nacho,

Can you tell me if portrait mode works correctly (try to show a simple image)?

If portrait mode works, you can try calling glTranslatef only (for example, try to translate 1 pixel to the right). After that you can also try to call glRotatef with smaller values. This way you can determine the correct values for the iPhone more easily.

If you still don't see anything or the image slides across the screen, you need to call glLoadIdentity before setting translation/rotation values.
Hi edge,

Yes, portrait mode works correctly. I tried your suggestion and found out that the following transformations work fine:

Code:

glLoadIdentity(); // I was already making the call to this function in the previous version.
glTranslatef(.0049f, 0, 0);
glRotatef(90.0f, 0, 0.0f, 1.0f);


Since the 0.0049f was determined by trial-and-error, I'd like to know which formula should I apply in order to come up with that number so that I can avoid using conditional compilation for the PC and the iPhone versions.

Once again, thanks for your support.

--Nacho

Edit: Even though the 0.0049f value works fine, I notice a slight artifact at the bottom of the screen which means I should refine the value a little bit more. Again, I might do that by trial-and-error, but I think it would be better if you can provide me a formula so that I can find the exact value.
Hi Nacho,

The translation value doesn't make sense. Are you sure you've called Perspective2D (not 3D) correctly before calling those functions?
Hi Edge,

Yes, I'm calling Perspective2D with the following code inside ClassMain::OnDisplayInit:

Code:

ecd.dsp->Perspective2D(320,480,false);


--Nacho

Update: I'm attaching a very simple project that outputs "HELLO WORLD!" to the screen in a landscape orientation and that makes use of a weird number (.0048775f) for the transformation in order to make it look right.
Attachments:
TranslateSample.zip (20 KB)
Hi Nacho,

After checking again, it makes sense. The solution is to call glTranslatex on the iPhone, because the coordinates are set up as fixed point (the value 1 in float is 65536 in fixed point).

This also makes it possible to use this formula if you still like to use glTranslatef: 320 / 65536 = 0,0048828125.
Does the OpenGL renderer in iPhone use fixed-point internally?

--Nacho
Hi Nacho,

Yes that's right, EDGELIB uses fixed point internally for all structures.