01-20-2012 02:50 PM
Hello,
I am new to mobile device development, and was trying a little bit of OpenGL ES on my blackberry playbook.
I am running the native SDK 1, and started my project from the OpenGL ES 1.1 template.
I modified it so it would use OpenGL ES 2. What my program does basically is sending two triangles in order to cover all the screen, and then using the fragment shader to do some raymarching.
However the result is very slow, so I wanted to decrease the resolution, this way my fragment shader is not called as often as before. To do that, I divided by two the resolution in the main.c file.
GLint surface_width, surface_height; eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width); eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);
// My modifications
surface_width /= 2.f; surface_height /= 2.f; ... glViewport(0, 0, surface_width, surface_height);
So now my program is fast, but is displayed on a fourth of the screen. I guess I missed a step here, but can't find where. I tried dividing some resolution values in the bbutil.c with no results.
Would someone know how to solve this?
01-20-2012 04:45 PM
I kept trying to think this over but all my ideas wouldn't work with making a "low resolution" game. I did a quick search and found this: http://gamedev.stackexchange.com/questions/7449/is
This way you can render to whatever resolution you want, then simply draw the framebuffer to the screen (there is a bit of extra work there if you treat the FBO as a texture).
It is a little extra work but it still works quite well and fast.
01-20-2012 06:36 PM
Oh yes, I did not think of using a FBO. That will work if I don't find any native way. It's weird though as when you use OpenGL on a computer the resolution of OpenGL is not related to the resolution of your window.
Thank you anyway, I will try that
01-20-2012 08:01 PM
01-23-2012 01:58 PM
Hey bobbyblues.
The result that you see is a correct behavior. Under the covers bbutil sets up a native window surface, calling
glViewport(0, 0, surface_width / 2, surface_height / 2);
Tells GL driver to render to only a quarter of your screen.
Instead, you need 2 separate steps
1. Render at desired (lower) resolution.
2. Resize results from step1 to PlayBook's 1024x600.
There are several ways to do something like this. Probably the easiest is to render to a gl texture in step 1 and later on apply this texture to a full-screen quad to get it "resized".
These should be a good starting point on this technique:
http://www.opengl.org/wiki/Framebuffer_Object
http://nehe.gamedev.net/tutorial/radial_blur__rend
01-23-2012 02:04 PM
Hello,
thank you for your links. This weekend I implemented a FBO to render in a texture and then put the texture on a quad.
However, it still needs some debuging, as my texture is all black. I will keep investigating that, and let you know when it works ![]()
Hopefully I will find in your links where my mistake lies.
Thanks again!