Newbie: Colors overlapping

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 03:03:39



Hi,

I have seem to have some problem with my triangles.
I have two triangles, A & B

- A : in front of the B (on the z-axis).

When I use GL_SMOOTH, and I end up seeing the color of the back triangle
overlapping the front triangle.

I'm very sure that they are placed correctly, as I rotate the two
triangles,
I can see that A is infront of B.

What is wrong? Is it some depth problem? Did I miss some gl keywords?

Thanks,
Rach

 
 
 

Newbie: Colors overlapping

Post by fungu » Wed, 24 Apr 2002 02:27:23



> Hi,

> I have seem to have some problem with my triangles.
> I have two triangles, A & B

> - A : in front of the B (on the z-axis).

> When I use GL_SMOOTH, and I end up seeing the color of the back triangle
> overlapping the front triangle.

Did you read the friendly manual?

Mine says:

glEnable(GL_POLYGON_SMOOTH);

... For correct anti-aliased polygons, an alpha buffer
is needed and the polygons must de sorted front to back.

--
<\___/>
/ O O \
\_____/  FTB.

 
 
 

Newbie: Colors overlapping

Post by Folker Schame » Wed, 24 Apr 2002 02:38:42


Is z-buffering enabled?


Quote:> Hi,

> I have seem to have some problem with my triangles.
> I have two triangles, A & B

> - A : in front of the B (on the z-axis).

> When I use GL_SMOOTH, and I end up seeing the color of the back triangle
> overlapping the front triangle.

> I'm very sure that they are placed correctly, as I rotate the two
> triangles,
> I can see that A is infront of B.

> What is wrong? Is it some depth problem? Did I miss some gl keywords?

> Thanks,
> Rach

 
 
 

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 03:50:58


Thanks fungus and Folker,

Yes, I have the following:

  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glEnable(GL_DEPTH_TEST);

and also    

  glDepthRange(0.0, 0.5);

I'm not quite sure if I need glDepthRange, but one of the examples
placed it in.
I have inserted more triangles into my program. Some did not overlap,
some did :-(

Is it the problem with the depth range?

Thanks,
Rach

 
 
 

Newbie: Colors overlapping

Post by Jakob Bielin » Wed, 24 Apr 2002 03:06:48




Quote:> Thanks fungus and Folker,

> Yes, I have the following:

>   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
>   glEnable(GL_DEPTH_TEST);

> and also

>   glDepthRange(0.0, 0.5);

> I'm not quite sure if I need glDepthRange, but one of the examples
> placed it in.
> I have inserted more triangles into my program. Some did not
overlap,
> some did :-(

> Is it the problem with the depth range?

I'd suggest setting the depth-range from 0.0 to 1.0. Though this
probably won't solve your problem. Check if the z-coordinates of the
triangles are correct ... stupid hint, yes .. but you never know :)

--
jb

(replace y with x to reply)

 
 
 

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 04:29:51


Having read

http://www.opengl.org/developers/faqs/technical/depthbuffer.htm#0070

I have set:

gluPerspective( 80, 1.0, 1, 100.0) to gluPerspective( 80, 1.0, 10,
100.0)
to reduce the near and far, but still I see cuts over front and back
triangles.

I think the buffer is too small(?). I have around 10,000 triangles ;-(
The suggestion given in that website is to use the multipass technique!!
Oh dear!

Any pointers on where I can find examples or codes to implement
multipass?

Thanks,
Rach

 
 
 

Newbie: Colors overlapping

Post by Jakob Bielin » Wed, 24 Apr 2002 04:40:07




Quote:> Having read

> http://www.opengl.org/developers/faqs/technical/depthbuffer.htm#0070

> I have set:

> gluPerspective( 80, 1.0, 1, 100.0) to gluPerspective( 80, 1.0, 10,
> 100.0)
> to reduce the near and far, but still I see cuts over front and back
> triangles.

> I think the buffer is too small(?). I have around 10,000 triangles
;-(
> The suggestion given in that website is to use the multipass
technique!!
> Oh dear!

> Any pointers on where I can find examples or codes to implement
> multipass?

I don't think you have an "astronomically large scene". After all, 10K
triangles is not thaaat much. What did you set the glDepthFunc to?
Also, it might help uploading a screenshot to some website and then
posting the link here.

--
jb

(replace y with x to reply)

 
 
 

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 06:57:41


After a tough time printing screen, I have attached the
pictures of my program. Please visit it at:

http://www.dcs.warwick.ac.uk/~csvhl/triangles.html

I do not understand why the polygons seems to cut (overlap).
The triangles are displayed correctly.

thanks in advance,
Rachel

 
 
 

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 07:06:31


Hi,

glDepthFunc?? I miss that in my code. Could that be the problem?
What do I need to set it to? Is it just:

glDepthFunc (GL_LEQUAL);                    

Thanks,
Rach


> I don't think you have an "astronomically large scene". After all, 10K
> triangles is not thaaat much. What did you set the glDepthFunc to?
> Also, it might help uploading a screenshot to some website and then
> posting the link here.

> --
> jb

> (replace y with x to reply)

 
 
 

Newbie: Colors overlapping

Post by Kornelius Elstne » Wed, 24 Apr 2002 06:21:12


Hiya

Judging by the images it appears that the depth buffer isn't working yet,
try adding

glClearDepth(1.0f);

somewhere in your initialisation section.
At the beginning of your painting routine you should have a line along the
lines of:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

This will clear the screen & reset the depth buffer to the value that you
specified in glClearDepth().

hope this helps

cu|K

from the images it appears that your program fails to

After a tough time printing screen, I have attached the
pictures of my program. Please visit it at:

http://www.dcs.warwick.ac.uk/~csvhl/triangles.html

I do not understand why the polygons seems to cut (overlap).
The triangles are displayed correctly.

thanks in advance,
Rachel

 
 
 

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 07:50:41


Hi,

I've added glClearDepth, but still the same image. I have the following
in my code:

main()
{
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  init();
  showTriangles();

Quote:}

void init(void)
{
   glClearColor(0.0, 0.0, 0.0, 0.0);
   glEnable(GL_DEPTH_TEST);
   glShadeModel(GL_POLYGON_SMOOTH);
   glDepthRange(0, 1);
   glClearDepth(1.0f);        //added in, but still no effect :-(

Quote:}

showTriangles()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  //yes, I have a
glClear
  drawTriangles();
  drawMoreTriangles();
  glutSwapBuffers();

Quote:}

drawTriangles()
{
  glPushMatrix();
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glBegin(GL_POLYGON);
      //draw triangle
    glEnd();
  glPopMatrix();

Quote:}

drawMoreTriangles()
{
  //same as drawTriangles..

Quote:}

Do I need glFrontFace? or etc? I'm just drawing triangles though.

Thanks,
rach


> Hiya

> Judging by the images it appears that the depth buffer isn't working yet,
> try adding

> glClearDepth(1.0f);

> somewhere in your initialisation section.
> At the beginning of your painting routine you should have a line along the
> lines of:

> glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

> This will clear the screen & reset the depth buffer to the value that you
> specified in glClearDepth().

> hope this helps

> cu|K

 
 
 

Newbie: Colors overlapping

Post by Folker Schame » Wed, 24 Apr 2002 06:35:21


Quote:> glDepthFunc?? I miss that in my code. Could that be the problem?
> What do I need to set it to? Is it just:

> glDepthFunc (GL_LEQUAL);

Default value is GL_LESS, which should be fine...
 
 
 

Newbie: Colors overlapping

Post by Rach » Wed, 24 Apr 2002 08:20:15


Hi,

There is something very wrong with my z-buffer. Every triangles that
I create in the drawMoreTriangles subroutine seems to be on top of
drawTriangles, just because I call drawMoreTriangles later in the
program!

Why?!! What*up?

Rach


> Hi,

> I've added glClearDepth, but still the same image. I have the following
> in my code:

> main()
> {
>   glutInit(&argc,argv);
>   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
>   init();
>   showTriangles();
> }

> void init(void)
> {
>    glClearColor(0.0, 0.0, 0.0, 0.0);
>    glEnable(GL_DEPTH_TEST);
>    glShadeModel(GL_POLYGON_SMOOTH);
>    glDepthRange(0, 1);
>    glClearDepth(1.0f);        //added in, but still no effect :-(
> }

> showTriangles()
> {
>   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  //yes, I have a
> glClear
>   drawTriangles();
>   drawMoreTriangles();
>   glutSwapBuffers();
> }

> drawTriangles()
> {
>   glPushMatrix();
>     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
>     glBegin(GL_POLYGON);
>       //draw triangle
>     glEnd();
>   glPopMatrix();
> }

> drawMoreTriangles()
> {
>   //same as drawTriangles..
> }

> Do I need glFrontFace? or etc? I'm just drawing triangles though.

> Thanks,
> rach

 
 
 

Newbie: Colors overlapping

Post by Folker Schame » Wed, 24 Apr 2002 07:49:25


looks all correct...


> Hi,

> There is something very wrong with my z-buffer. Every triangles that
> I create in the drawMoreTriangles subroutine seems to be on top of
> drawTriangles, just because I call drawMoreTriangles later in the
> program!

> Why?!! What*up?

> Rach


> > Hi,

> > I've added glClearDepth, but still the same image. I have the following
> > in my code:

> > main()
> > {
> >   glutInit(&argc,argv);
> >   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
> >   init();
> >   showTriangles();
> > }

> > void init(void)
> > {
> >    glClearColor(0.0, 0.0, 0.0, 0.0);
> >    glEnable(GL_DEPTH_TEST);
> >    glShadeModel(GL_POLYGON_SMOOTH);
> >    glDepthRange(0, 1);
> >    glClearDepth(1.0f);        file://added in, but still no effect :-(
> > }

> > showTriangles()
> > {
> >   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  file://yes, I have a
> > glClear
> >   drawTriangles();
> >   drawMoreTriangles();
> >   glutSwapBuffers();
> > }

> > drawTriangles()
> > {
> >   glPushMatrix();
> >     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
> >     glBegin(GL_POLYGON);
> >       file://draw triangle
> >     glEnd();
> >   glPopMatrix();
> > }

> > drawMoreTriangles()
> > {
> >   file://same as drawTriangles..
> > }

> > Do I need glFrontFace? or etc? I'm just drawing triangles though.

> > Thanks,
> > rach

 
 
 

Newbie: Colors overlapping

Post by Jakob Bielin » Wed, 24 Apr 2002 14:19:02





Quote:> > Hi,

> > There is something very wrong with my z-buffer. Every triangles
that
> > I create in the drawMoreTriangles subroutine seems to be on top of
> > drawTriangles, just because I call drawMoreTriangles later in the
> > program!

> > Why?!! What*up?
> looks all correct...

Well, I don't see a call to glDepthFunc ... Maybe set that to GL_LESS.

--
jb

(replace y with x to reply)

 
 
 

1. Newbie: Check overlapping squares

Hi,

I want want to check if several given squares do not overlap. These squares
are given as xmin, xmax, ymin and ymax. The sqaures can be of different
size, but form an even larger square.

(view widt a unscalable font)
^   +-------------+-----+--------------+
|   |             |     |              |
Y   +---------+---+-----+----+---------+
    |         |              |         |
    +---------+              +---------+
    |         |              |         |
    +-----+---+------+-------+         |
    |     |          |       |         |
    +-----+----------+       |         |
    |     |          |       |         |
    +-----+----------+-------+---------+

                                    X ->

Any suggestions what algorithm I could use?

2. Where can I get 8-bit monochrome images

3. Newbie: Efficient overlapping windows

4. Cloud simulation

5. Newbie question re: overlapping 2D graphics

6. 6451200 and World (Sammi) Coordinates?

7. problems with overlap colors on O2

8. how to convert GKS metafiles into something userfull?

9. Changing color for overlapping areas?

10. Overlap BW and BW image in other color

11. Text color chabge on overlap

12. problems with overlap colors on O2

13. <newbie> Mirror color on the screen