Advertisement

translation problem

Started by December 29, 2003 09:01 PM
5 comments, last by coda_x 21 years, 2 months ago
I drew a 3D rect of length -x to x. On top of this rect in the middle, i drew another smaller rect from -(x-w)/2 to (x-w)/2 where w is < or equal to x. I want to translate this smaller rect to the left till it reach the edge whereby the edges of both rect are aligned so i translate by: glTranslatef (-(x+w)/2,0.0f,0.0f); but when w=x, by right there should be no more smaller rect showing but i get one of its faces at the edge. How do i eliminate this? For other values of w, it worked ok.
Make a special case: if w == r, don''t draw the smaller rectangle.





"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
okie that can be done but was wondering why it doesn''t work when w=x
To be honest, I don''t understand your problem 100%, but my first guess would be shearing, which just a fancy name for inpropriately drawn overlapping polygons, or, in your case, lines. It could also be that you''re suffering a floating point error, which means that, while programmatically w should equal x, w actually is just a teeny weeny little bit off as a result of numerous floating point additions and, since you''re probably drawing the larger rect first and the smaller after that, the smaller rect''s sides are what you''re seeing. Or I could be totally wrong because I''m totally misinterpreting your post...





"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Perhaps you''re having some z-buffer glitches? i.e. you''re drawing both polygons at the same exact depth, and even though you''d expect the smaller rectangle to disappear, due to floating point errors and such, an edge of it may be poking through.

To test it, try

DrawSmallPolygon();
// Disable depth (z) buffer writes
glDepthMask(GL_FALSE);
DrawBigPolygon();
glDepthMask(GL_TRUE);


I think that might work!
I realized a half day later that what I said above wouldn''t work. That''s just disabling writes to the depth buffer, but depth testing is on still, duh. Instead try:

DrawSmallPolygon();
glDisable(GL_DEPTH_TEST);
DrawBigPolygon();
glEnable(GL_DEPTH_TEST);

This allows all rasterized points to overwrite the current pixel in the frame buffer, regardless of the depth.
Advertisement
yup thanx for all ur advice!

This topic is closed to new replies.

Advertisement