Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Issue with Perspective2D in internal and OpenGL renderer.


Issue with Perspective2D in internal and OpenGL renderer.

Postby tinybulb.com » Jan 12, 2009 @ 9:47am

Hello,

I am developing game for iPhone with use of your library and have issue with setting up Perspective2D. In case if i am using internal renderer, with Perspective2D comand the coordinates sets in -4096 ... 4096 in fixed point space on both axes, this case is ok. But in case if i am setting EGL_USEGL and use Perspective2D the coordinatse sets in 0 ... display->GetWidth(), 0 ... display->GetHeight() this is no acceptable for me because in this case moving of objects can't be done with subpixel accuracy and there is no possability to render moving of objects smooth but only with increment equal to 1 pixel :-/ is there any way to get same behavior(same coordinat sets) for Perspective2D in OpenGL ES as in internal renderer?

With best regards,
Nikita Leonov
tinybulb.com
pm Member
 
Posts: 32
Joined: Dec 16, 2008 @ 12:09am
Location: Minsk


Postby edge » Jan 12, 2009 @ 2:26pm

Hi,

The best way to handle objects is to move them in units. When rendering them, divide its position by a certain value.

For example, you can say that one pixel is 256 units. When creating the object at pixel x,y = 10,23 you can multiply those values by 256 and store them with the object. When rendering and blitting its position in OpenGL, divide the object position by 256.

Using values such as 128, 256 or 512 is a good idea, because dividing by those values is optimized for the processor.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby tinybulb.com » Jan 12, 2009 @ 7:54pm

Hi,

Thanks for answer. I am familiar with fixed point math, but this question is not about internal application business logic but about how this data can be rendered with use of edge. Currently when i am use internal renderer and call Perspective2D, it sets x and y measurement between -4096 and 4096, but if i will tring to use Perspective2D with OpenGL it sets x and y measurement between 0 and IPHONE_WIDTH, 0 and IPHONE_HEIGHT. correspondingly. With such small axis measurements (for iPhone 0 ... 320, 0 ... 480) it makes render of object movements looks ugly, because it is _render_ movement of objects with not lesser than 1 pixel shifts.

So, in internal render we have measurement between -4096 and 4096 and able to render objects for example with coordinates 100.75f, 0.15f in fixed point equivalent, but in case if i am using OpenGL on iPhone Perspective2D sets strict mesurement between 0 and 320, 0 and 480 as results there is no possability to render objects with shifts lesser than 1 pixel.
tinybulb.com
pm Member
 
Posts: 32
Joined: Dec 16, 2008 @ 12:09am
Location: Minsk


Postby tinybulb.com » Jan 13, 2009 @ 5:34am

To be clear I am do not use OpenGL commands like glDrawArrays for rendering, but display->render and E3DSurfaces. I also tried to move objects with use of OpenGL commands like glTranslatef because it is accept floats but it seems like any of OpenGL commands do not affects E3DSurfaces render. (but for display->DrawFont it works :-/)
tinybulb.com
pm Member
 
Posts: 32
Joined: Dec 16, 2008 @ 12:09am
Location: Minsk


Postby edge » Jan 13, 2009 @ 2:29pm

Hi,

Actually, the problem is that the internal renderer doesn't support the Perspective2D function (it ignores it), leaving the settings from the Perspective3D function called earlier.

The glRotate/translate commands are ignored, because the translation is stored in the display/object matrices and will overwrite when rendering. Also, aren't you able to specify a bigger width/height to the Perspective2D function?
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Postby tinybulb.com » Jan 13, 2009 @ 3:57pm

Perfect! Thanks a lot! It is all because of misunderstanding of internal edgelib logic. For now everything works perfect. I just initialize Perspective2D with 4096 for height and width when i need supixel accuracy and when i need to draw on pixel basis i just initialize it with corrcet width and height. Thanks!
tinybulb.com
pm Member
 
Posts: 32
Joined: Dec 16, 2008 @ 12:09am
Location: Minsk


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron