PDA

View Full Version : only redraw parts of the screen - Scissor



monnti
04-08-2011, 02:55 PM
hi,

i have a problem with the preformace of my opengl android app. The main problem is that i have to redraw many static objects. is there a way to redraw only the changing objects and not the whole screen???


i have tried this:



if(!hasInit){
gl.glClear( GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT );
backgroundRenderer.update(gl, activity, simulation);
hasInit = true;
}

gl.glEnable(GL10.GL_SCISSOR_TEST);
gl.glScissor(0, 0, 150, 150);
gl.glClear( GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT );

backgroundRenderer.update(gl, activity, simulation);
boxRenderer.update(gl, activity, simulation);

gl.glDisable(GL10.GL_SCISSOR_TEST);




but now I have weird flashing effects, except in the defined glScissor area.

carsten neumann
04-08-2011, 07:13 PM
please put [ code]/[ /code] (without the leading " ") around source snippets for better readability.

why is backgroundRenderer.update() also in the scissor test scope?

if you are using double buffering you need to make sure to have your static content drawn into both buffers and on OpenGL ES, swapping buffers may clear the buffer - IIRC there is an implementation dependent control for it though.

if you really have a large amount of static content that is not affected by camera movement or the like, you can render it once into a texture and then each frame the first thing you render is a full screen quad with that texture applied.

monnti
04-09-2011, 06:07 AM
sorry for the forgotten [ code]/[ /code]

i think i have to say that i am really new on openGl. so please excuse if i have stupid questions ;)

my main problem is that i want some objects not to be redrawn. The only promising that i have found by google is scissor. But with the code of mine, the background outside of the scissor_test area is blinking on the emulator and drawn 100000 times in the whole screen on my mobile.

i have put the backgroundRenderer.update() part in the scissor test scope, cause if i don't, the background is gone in the scissor area.

i'm sorry, but i don't know any thing about double buffering. So if you could give me some tutorial links it would be great.

The whole background in one texture thing could work in this case, but this is only my scissor_test test. Normally i want to stop rendering other objects by every frame. These objects can be influenced by the player. If this is the case i would have to modify the single background texture.