Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Point drawed over texture doesn't get the desired colour

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2014
    Posts
    11

    Question Point drawed over texture doesn't get the desired colour

    Hi!

    I was tasked with modifying some existing OpenGL 1.x code (a panoramic picture viewer, where the panorama is split into the six faces of a cube) so we're able to draw lines/points on top of the loaded textures, where the points are the mouse coordinates unprojected to object coordinates.

    I wrote a test program with a coloured cube just to try the line painting on top of it:

    Click image for larger version. 

Name:	opengl_PointColor3.jpg 
Views:	184 
Size:	8.8 KB 
ID:	1629

    I got this with the code pushing the GL_DEPTH_BUFFER_BIT attribute to the stack, disabling it before painting the points and poping the stack attribute after I have done with the painting.

    I tried to use that same approach in the existing application, but I got these results (here, I'm trying only to paint a point):

    Click image for larger version. 

Name:	opengl_PointColor2.jpg 
Views:	212 
Size:	20.6 KB 
ID:	1630

    I specified red as the color for the point but, as you can see, it doesn't have the desired one. I thought it might be due to blending and that it might be mixing its color with the underlying texture, so I pushed the GL_BLEND attribute to the stack as well and disabled it before painting, but the point isn't getting the desired color anyway.

    What is happening here? Is there a way to "force" the pipeline to paint the point red?

    Cheers,
    Andrés.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2013
    Posts
    172
    Have you disabled textures before drawing the point? Otherwise you will try to sample texcoords from the texture, even when drawing a point or a line.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2014
    Posts
    11
    WOW!!! Thanks!

    I tried disabling a lot of things, even some textures, but your comment made me check all over again. I forgot to disable one type of texture. Now it works as I wanted!

    Now, a question about your great answer:

    you will try to sample texcoords from the texture
    it's like if I change the matrix mode to PROJECTION, do my work and then forget to change it back to MODELVIEW right? I mean, all my future changes will operate under the PROJECTION view.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Sep 2013
    Posts
    172
    No.
    You use the fixed functionality pipeline. In the fixed function pipeline you will always take the fragment color from the highest enabled texture when rendering. The texcoords will be the last texcoords you have uploaded no matter what kind of draw mode you used.

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2014
    Posts
    11
    Aha! Thanks for your explanation!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •