PDA

View Full Version : glScale and reflections



MButchers
09-20-2001, 11:46 PM
hi there,

im currently putting reflections into my
game engine but am having problems with
the call to glScale in that it doesnt do
anything

I thought that if i rendered a primitive
then called glScale(1,-1,1) and re-rendered
the primitive it would be flipped around
the y plane however i only ever get the one
primitive rendered.

im only using glScale for testing purposes as i intend to have reflective surfaces in
any plane and will therefore transform my
vertices by a matrix before the second pass
however it is a bit strange.

Any ideas??

Thanks

Mark

DaViper
09-21-2001, 01:08 AM
give some more code pls

MButchers
09-21-2001, 01:55 AM
hi there,

this is not the exact code for rendering
as i have removed the code for stenciling
while sorting out this problem

//*****************************************

//Render all opaque primitives ( This works )
Engine.Materials.Render(False);

//render reflections
glPushMatrix;
glScale(1,-1,1);

//re render opaque reflected primitives
Engine.Materials.Render(False);
//render alpha blended reflected primitives
Engine.Materials.Render(True);

glPopMatrix;

//render alpha blended reflected primitive correctly
Engine.Materials.Render(True);

//*****************************************
Mark

Korval
09-21-2001, 10:33 AM
When you do reflections this way, you will have to reverse the backface-frontface culling, because scaling it like this will reverse the facing on all of the polygons.

MButchers
09-21-2001, 02:11 PM
Thanks for all the help

Ive found the problem

if Assigned(glDrawArrays) then
begin
glColorPointer(4,GL_FLOAT,0,FColors);
glTexCoordPointer(2,GL_FLOAT,0,FTexCoords);
glVertexPointer(3,GL_FLOAT,0,FVertices);
glDrawArrays(GL_QUADS,0,FQuadCount * 4);
end else begin
glBegin(GL_QUADS);
for I := 0 to (FQuadCount*4)-1 do
begin
glColor4fv(@FColors[I]);
glTexCoord2fv(@FTexCoords[I]);
glVertex3fv(@FVertices[I]);
end;
glEnd;
end;

//this is it!!
FQuadCount := 0;

I was setting quadcount = 0 so in the
next pass it was rendering nothing!!

Hey ho. Some sleep might help!

Mark