Results 1 to 5 of 5

Thread: Drawing a pixel

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    4

    Drawing a pixel

    I just wanted to draw pixels in window coordinates, but it doesn't seem to work (i get nothing on screen). What did I do wrong? Thanks.

    GLubyte pixel[4];

    void setPixel(int posx,int posy) {
    glRasterPos2i(posx,posy);
    glDrawPixels(1,1,GL_RGBA,GL_UNSIGNED_BYTE,pixel);
    };

    void setColor(GLubyte r,GLubyte g,GLubyte b,GLubyte a) {
    pixel[0]=r;
    pixel[1]=g;
    pixel[2]=b;
    pixel[3]=a;
    };

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Drawing a pixel

    Did you set the modelview and projection matrix correct so the raster position is actually mapped to window coordinates?

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    4

    Re: Drawing a pixel

    Thanks, you're right,
    I left them be default (loadIdentity()). But is there a way to draw a pixel on a specific window position (in colorbuffer) regardless of modelview / projection matrices?

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Drawing a pixel

    There's an extension called ARB_window_pos you can use. It's in the core of OpenGL 1.4 in case it's not in your extension list.

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    4

    Re: Drawing a pixel

    Thanks,
    I'll try it.

Similar Threads

  1. Pixel-perfect drawing
    By halo in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 02-27-2005, 05:52 PM
  2. pixel-by-pixel drawing of objects
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-04-2003, 04:57 PM
  3. Drawing pixel rectangle
    By Belgrad in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 10-06-2002, 01:42 AM
  4. 2d pixel drawing...
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-02-2002, 05:31 PM
  5. Drawing pixel per pixel
    By in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-30-2000, 07:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean