Sign in to follow this  

i just implement reflection and everything goes slow, it is normal?????

This topic is 3855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Of course it will go slower than without it. You are double rendering everything. Have you profiled the code yet to see what the bottleneck is?

-me

Share this post


Link to post
Share on other sites
thanks Palidine for the answer.
the code i just download(nehe) was slow because was running windowed,
fullscreen run perfect.

But my code still slow:

void display (void)
{
allegro_gl_begin();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
double eqr[]={0.0f,-2.0f, 0.0f, 0.0f};
glLoadIdentity ();
camera();
glColorMask(0,0,0,0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glDisable(GL_DEPTH_TEST);

glEnable (GL_TEXTURE_2D);
pasto();//load texture pcx for the ground pasto=grass
//i enable and disable texture because if not 3d model i load
//before get darker
//ground is a plane positioned on (0,-2,0)
glDisable (GL_TEXTURE_2D);

glEnable(GL_DEPTH_TEST);
glColorMask(1,1,1,1);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0, eqr);
glPushMatrix();
glScalef(1.0f, -1.0f, 1.0f);
luz(GL_LIGHT0,LightPos);//positional ligth positioned on (0,3,0)
//with (0,-1,0) direction
glPushMatrix();
glTranslatef(0.0, aa+4, 0.0);//for move the the 3d model on the y-axis
//if key "J" is pressed aa=aa+0.1;
//object moves 0.1 to down
//if key "K" is pressed aa=aa+0.1;
//object moves 0.1 to Up
glCallList(object->model_list);//draw a 3d model load from a obj file
glPopMatrix();

glPopMatrix();
glDisable(GL_CLIP_PLANE0);
glDisable(GL_STENCIL_TEST);
luz(GL_LIGHT0,LightPos);//positional ligth positioned on (0,3,0)
//with (0,-1,0) direction
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glEnable (GL_TEXTURE_2D);
pasto();
glDisable (GL_TEXTURE_2D);

glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
glPushMatrix();
glTranslatef(0.0, aa, 0.0);
glCallList(object->model_list);
glPopMatrix();
glFlush();
allegro_gl_flip();
allegro_gl_end();
}

ANY SUGGEST WOULD BE VERY APRECIATED
BYE,THANKS

Share this post


Link to post
Share on other sites
Ok.. so your fps is 1.. maybe... what was it before? And I hope you don't say 2.

I'm serious its important to know how fast you had it working in the first place.

Quote:

pasto();//load texture pcx for the ground pasto=grass


In the quote above you say you are loading a pcx, I hope you mean binding the
texture, because if you are doing I/O in you draw loop this is bad.

Share this post


Link to post
Share on other sites
Palidine, again thanks for the answer.

fps before was 32.

my graphic card is:
geforce 2 MX/MX 64MB

when i say "load a texture..." i mean binding the texture
. |
. |
. |
glBindTexture(GL_TEXTURE_2D, tierraText);<----
glBegin(GL_QUADS);
glNormal3f(0,1,0);
glTexCoord2f(0.0, 0.0);
glVertex3f(i,-2,j);
glTexCoord2f(1.0, 0.0);
glVertex3f(i,-2,j-1);
glTexCoord2f(1.0, 1.0);
glVertex3f(i-1,-2,j-1);
glTexCoord2f(0.0, 1.0);
glVertex3f(i-1,-2,j
.
.
.

Share this post


Link to post
Share on other sites
let see, mayve i dont expres myself to good.

I download from nehe:reflection turorial,code and exe.
I run the exe on windowed mode and give no more than 1 fps
I run the exe on fullscreen mode and run perflectly.

i make my code very similar to nehe`s reflaction code.
I work with allegrogl,c++,dev-cpp

i run my code on fullscreen:
void main()
.
.
.
allegro_gl_clear_settings();
allegro_gl_set (AGL_COLOR_DEPTH, 24);
allegro_gl_set (AGL_Z_DEPTH, 8);
allegro_gl_set(AGL_FULLSCREEN, TRUE);
allegro_gl_set (AGL_DOUBLEBUFFER, 1);
allegro_gl_set (AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_Z_DEPTH | AGL_DOUBLEBUFFER );
set_gfx_mode(GFX_OPENGL, res_x,res_y , 0, 0);
.
.
.
}

well i thing i did (maybe here i have the problem)

I run on fullscreen mode 1024×768 and give no more than 1 fps
I run on fullscreen mode 512×384 and give no more than 2 fps

i think i dont know how to set fullscreen mode on allegrrogl,
but the only thing i am very sure is if i run on windowed mode
nehe´s reflaction exe it run relly relly slow, similar to my code.

But if that run ok (nehe's reflaction exe) even on windowed, am pretty sure i
am doing something wrong.

PLEASE HELP, AND VERY THANKS FOR THE ANSWERS

Share this post


Link to post
Share on other sites
if anyone have the same problem, i solved:

"If you are noticing extremely slow frame rates, try switching to fullscreen mode, or setting your desktop colour depth to 32bpp."
"If you are having problems with Windowed mode, make sure your desktop color depth is not set to 16bit. In 16bit color mode, the stencil buffer is emulated, resulting in sluggish performance. There are no problems in 32bit mode.

On AllegroGL inicialization do this:

allegro_gl_set( AGL_COLOR_DEPTH, 32 );
allegro_gl_set( AGL_Z_DEPTH, 8 );
allegro_gl_set(AGL_RENDERMETHOD, 1);
allegro_gl_set(AGL_FULLSCREEN, 1);
allegro_gl_set(AGL_STENCIL_DEPTH,1);
allegro_gl_set( AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_Z_DEPTH | AGL_DOUBLEBUFFER | AGL_RENDERMETHOD | AGL_FULLSCREEN | AGL_STENCIL_DEPTH);

this are optional:
allegro_gl_set(AGL_RENDERMETHOD, 1);
allegro_gl_set(AGL_FULLSCREEN, 1);

thanks to all.

Share this post


Link to post
Share on other sites

This topic is 3855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this