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

Started by
9 comments, last by xeexIII 16 years, 10 months ago
i just implement reflection ,code from nehe tutorial, and everything goes slow, it is normal????? by slow i mean relly relly relly slow.
Advertisement
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
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
define "slow" in terms of frames per second.

-me
1 fps
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.
Nicholas ChristopherArchitecture Software Developer, 3D Modelerhttp://www.arconovum.com
Also, what graphics card do you have? Anything current should be fine, just want to sanity check. =)

-me
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
.
.
.
Try updating your video card's driver; sounds almost like it's falling back to software... but it's fixed in fullscreen, so I'm not sure.
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

This topic is closed to new replies.

Advertisement