Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glDrawPixels() help

  1. #1
    Newbie Newbie
    Join Date
    Oct 2012

    glDrawPixels() help

    So, I am trying to use glDrawPixels() to draw points on the screen but can't get it to work properly. Right now it draws the points I want, but then repeats the points in the same position on the y-axis but translated over a few pixels on the x-axis repeatedly.

    I am creating a pixel buffer like so:

    Code :
    struct RGBType {	
    	float r;	
    	float g;	
    	float b;
    RGBType *pixel_buffer = new RGBType[800 * 1200];

    Then filling in the rgb components I want to show up on the screen
    Code :
    pixel_buffer[800*y + x].r=0.5;		
    pixel_buffer[800*y + x].g=0.5;		
    pixel_buffer[800*y + x].b=0.5;

    and then calling drawpixels and swapping the buffers
    Code :
    glDrawPixels(window_width, window_height, GL_RGB, GL_FLOAT, pixel_buffer);
    delete[] pixel_buffer;

    All my other code is simply setting up a window with glut.

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Montreal, Canada
    Maybe you are using some other function that is causing the raster position to change. Call glRasterPos before calling glDrawPixels.
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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