Results 1 to 3 of 3

Thread: Intermitent output

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2002

    Intermitent output

    Use: WinMe, visual C++6.
    Dear All,
    The program is supposed to display dots at mouse-click position within the created window.
    Instead: Initially no output at mouse-clicks(empty background) most of the time. Sometimes later they appear without mouse-clicks, and sometimes later the dots disappear, usually when shifting the window. Sometimes, it shows in the MS-DOS windows but it later disappear.

    The code:
    #include <windows.h>
    #include <gl/Gl.h>
    #include <gl/glut.h>
    #define screenHeight 480

    void myInit(void) {
    glColor3f(1.0f, 0.0f, 1.0f);
    gluOrtho2D(0.0, 640.0, 0.0, 480.0);

    void drawDot(GLint x, GLint y) {

    void myDisplay(void) {

    void myMouse(int button, int state, int x, int y) {
    if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
    drawDot(x, screenHeight - y);
    else if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)

    void main(int argc, char** argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("my first attempt");

    What cause the strange behavior? And how to solve it?

    Thanks in advance.


  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000

    Re: Intermitent output

    For delayed output: Commands in OpenGL can be buffered up, and may not be executed at the time you call them. What happens is when you draw a dot, it is placed in some sort of queue (how this actually work this is implementation dependent by the way, but this is the general idea) and is executed when the driver decides to do so. To force the queue to execute all it's commands, put a glFinish after you draw the point. A glFlush may work also.

    For dissapearing dots: When you resize the window, GLUT will first call the reshape callback and then the display callback. In the display callback you explicitly clear the color buffer, clearing the dots you you have drawn previously. If you want the points to remain, you will have to add each point drawn to some sort of list. In the display function, clear the display and redraw the points in the list.

  3. #3

    Re: Intermitent output

    Yep, thats exactly how I did it in my program. Although, since I'm just doing little programs at the moment I just created a screen array but a linked list would be better. When I mouseclick and get the x,y coordinates I place a marker in the x,y coordinate of the array. Later when the render routine is run I iterate through the array and draw the dots for each coordinate that has been marked. Seems to work okay so far. Slowly extending the program though.

    Learning OpenGL while working on sourceforge projects: and

Similar Threads

  1. Replies: 5
    Last Post: 06-14-2012, 08:38 PM
  2. Different output on GPU vs CPU
    By flyingtabmow in forum OpenCL
    Replies: 3
    Last Post: 07-13-2010, 07:06 PM
  3. Replies: 4
    Last Post: 06-06-2002, 10:52 PM
  4. YUV output
    By cix>foo in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 02-05-2002, 03:18 PM
  5. Output to PS or Tif
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-23-2000, 09:27 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