PocketMatrix forums

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

Issue with Perspective2D in internal and OpenGL renderer.

tinybulb.com · 12 Jan 2009, 08:47 UTC
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
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.
tinybulb.com · 12 Jan 2009, 18:54 UTC
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 · 13 Jan 2009, 04:34 UTC
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 :-/)
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?
tinybulb.com · 13 Jan 2009, 14:57 UTC
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!