Results 1 to 4 of 4

Thread: glDrawPixels and data "stretching"

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011

    glDrawPixels and data "stretching"

    Ok-I give up. I've been combing the web for weeks and have read most of the redbook and a lot of the blue book and have downloaded lots of example code, but I still haven't found the answer to my problem. Keep in mind I am a newbie when it comes to OpenGL. I am rewriting my old legacy code which takes real time radar data and draws it to the screen. My legacy code was written using xView and Xlib. The piece of that code that I am working on takes a beam and displays it on the right hand side of the window. The y axis is range and the x axis is beam number, so this is only a two dimensional image. As each new beam comes in on the right hand side, the older beams move over one pixel to the left. I have rgba data for every pixel in the xy plane. What I am seeing is that when the data is first displayed the 500 pixels are not my 500 pixels but are the first 10 (or so) range values stretched out. As each new beam comes in more ranges are displayed. My 500 pixels in the y direction are never all displayed (although over 300 of them are by the time I get to the left hand side of the window). Once the window is filled, the new beams start on the right hand side again and the 3 or so ranges will take up about 25% of the 500 pixels (duplicated by openGL) and then the data will compact slowly again with each new beam. (I am on a linux system with Nvidia hardware and running OpenGL 1.4). In case any of this makes sense, I will include the structure of the openGL calls below:


    glutInit (&argC, argV);

    glutInitDisplayMode (GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE);
    glutInitWindowPosition (100, 100);
    createGraphics ();
    glEnable (GL_DEPTH_TEST);
    glClearColor (0., 0., 0., 1.);
    glutMainLoop ();


    width = 700;
    height = 600;

    glutInitWindowSize (width, height);
    glutCreateWindow ("TITLE");
    glClearColor (0, 0., 0., 1.);
    glutDisplayFunc (drawBeams);
    glutReshapeFunc (changeSize);
    glutPostRedisplay ();
    glutTimerFunc (0, check_for_data, 0);


    glMatrixMode (GL_PROJECTION);
    glPushMatrix ();
    gluOrtho2D (0., width, 0., height);

    glViewport (0, 100, width - 100, height - 100);
    glutSwapBuffers ();

    glViewport (0, 0, (GLsizei) w, (GLsizei) h);

    int widthLocal = 599 - currentBeam;

    glRasterPos2i (widthLocal, 150);
    glDrawPixels (currentBeam, 500, GL_RGBA, GL_FLOAT, da);
    glFlush ();
    glutSwapBuffers ();

    gets data from shared memory
    converts data into rgba array called da
    calls drawArray

    glutTimerFunc (10, check_for_data, 0);

    I would appreciate it if anyone can tell me what I am doing wrong, as I obviously don't have a grasp on openGL yet. Any advice I can get from you OpenGL gurus out there is greatly appreciated. Thanks in advance for your time and patience!

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Mar 2009
    Karachi, Pakistan

    Re: glDrawPixels and data "stretching"

    One thing I could suggest is that u recheck the data in your array may be you are missing some data. Disable the timer and just use the keyboard right/left arrow keys to move the points and see if ur data is fine.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2011

    Re: glDrawPixels and data "stretching"

    Thank you. I have verified that the last few ranges of the first few beams do exist. In fact each time they get redrawn a few more y values show up. I'll try disabling the timer tomorrow and maybe slowing down the data flow. I'll let you know if I figure anything out. Thanks again!

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2011

    Re: glDrawPixels and data "stretching"

    I want to thank you for your suggestions. I did as you said and was finally able to figure out that I was putting the data into the image array incorrectly. Thank you so much for your time and willingness to help. I have more questions, but should post them separately. Thanks again!

Similar Threads

  1. Replies: 1
    Last Post: 09-24-2013, 03:23 AM
  2. egl gles2 "function is no-op" "Mesa: User error"
    By unixmania in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-17-2013, 05:30 AM
  3. Replies: 1
    Last Post: 10-26-2012, 02:19 AM
  4. glDrawPixels seems to "wrap" around viewport
    By lihom in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-16-2010, 03:00 AM
  5. "best" linux dist for a "Gelato" render farm?
    By ArtificialArtOfficial in forum OpenGL: Linux
    Replies: 10
    Last Post: 12-23-2007, 01:02 PM

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