Results 1 to 2 of 2

Thread: Weird issue with OpenGl drawing

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2016
    Posts
    18

    Weird issue with OpenGl drawing

    Hello all,

    I am experiencing an interesting issue.

    When I click on the mouse button (left mouse button), I am suppose to draw a blue rectangle with a white rectangle on top of it. In the program, this represents a block label.

    The issue is this, when the block label is drawn on the canvas, it is a block node and not a blue node (yes, I have the glColor set correctly, this was the first thing that I checked).

    Now, I also know that it is being "drawn correctly" because I noticed that when I rapid clicked on the mouse while moving it around, I was able to get some nodes to be drawn as blue and others black.

    I would love to post some code here but I am not entirely sure what code to post that would be relevent to the discussion.

    For now, I am posting my draw code for the block label. Please let me know if you need anymore code posted.

    I should also mention that the block label object inherits from another object called node. I will also be posting the draw code, too.

    Also, I have noticed that when I draw a new node or block label, a black rectangle is drawn ontop of the nore or block label. I am thinking that these two issues are related to each other; however, after looking through the draw code many times, I am not sure where the issue lies. Perhaps another pair of eyes will be able to help me determine the best fix:

    Code :
    void draw()
        {
    // The draw code for the block label
            glPointSize(6.0);
     
            if(isSelected)
                glColor3d(1.0, 0.0, 0.0);
            else
                glColor3d(0.0, 0.0, 1.0);
     
            glBegin(GL_POINTS);
                glVertex2d(xCenterCoordinate, yCenterCoordinate);
            glEnd();
     
            glColor3d(1.0, 1.0, 1.0);
            glPointSize(4.25);
     
            glBegin(GL_POINTS);
                glVertex2d(xCenterCoordinate, yCenterCoordinate);
            glEnd();
        }

    Code :
    //! The draw code for the node
    	virtual void draw()
        {
            if(isSelected)
                glColor3d(1.0, 0.0, 0.0);
            else
                glColor3d(0.0, 0.0, 0.0);
     
            glPointSize(6.0);
     
            glBegin(GL_POINTS);
                glVertex2d(xCenterCoordinate, yCenterCoordinate);
            glEnd();
     
            glColor3d(1.0, 1.0, 1.0);
            glPointSize(4.25);
     
            glBegin(GL_POINTS);
                glVertex2d(xCenterCoordinate, yCenterCoordinate);
            glEnd();
        }

    Code :
    /* This function gets called everytime a draw routine is needed */
    void modelDefinition::onPaintCanvas(wxPaintEvent &event)
    {
        wxGLCanvas::SetCurrent(*_geometryContext);// This will make sure the the openGL commands are routed to the wxGLCanvas object
    	wxPaintDC dc(this);// This is required for drawing
     
        glMatrixMode(GL_MODELVIEW);
        glClear(GL_COLOR_BUFFER_BIT);
     
        updateProjection();
        drawGrid();
        glMatrixMode(GL_MODELVIEW);
     
     
        if(_editor.getLineList()->size() > 0)
        {
            for(std::vector<edgeLineShape>::iterator lineIterator = _editor.getLineList()->begin(); lineIterator != _editor.getLineList()->end(); ++lineIterator)
            {
                lineIterator->draw();
            }
        }
     
        if(_editor.getArcList()->size() > 0)
        {
            for(std::vector<arcShape>::iterator arcIterator = _editor.getArcList()->begin(); arcIterator != _editor.getArcList()->end(); ++arcIterator)
            {
                arcIterator->draw();
            }
        }
     
        if(_editor.getBlockLabelList()->size() > 0)
        {
            for(std::vector<blockLabel>::iterator blockIterator = _editor.getBlockLabelList()->begin(); blockIterator != _editor.getBlockLabelList()->end(); ++blockIterator)
            {
                blockIterator->draw();
            }
        }
     
        if(_editor.getNodeList()->size() > 0)
        {
            for(std::vector<node>::iterator nodeIterator = _editor.getNodeList()->begin(); nodeIterator != _editor.getNodeList()->end(); ++nodeIterator)
            {
                nodeIterator->draw();
            }
        }
     
        SwapBuffers();// This outputs everything to the screen
    }

    Please let me know if you need more source code posted. This issue has been plagueing me for a few days now! I am also attaching a picture of what I was describing above

    Ok, So I seem to be having some difficulty attaching the image. Instead, I will be posting a link.

    https://postimg.org/image/o7rwlpprd/

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2016
    Posts
    18
    Hello all,

    I apologize for wasting people's time. I actually found the error that I was experiencing and it turns out that there was an error with the logic of my code.

Similar Threads

  1. Weird Terrain Depth Issue with new OpenGL Versions
    By Wolff in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-06-2016, 12:31 PM
  2. using gl_InstanceID weird issue
    By Nowhere-01 in forum OpenGL: GLSL
    Replies: 4
    Last Post: 04-17-2013, 10:49 AM
  3. Weird GLSL Issue
    By toneburst in forum OpenGL: GLSL
    Replies: 17
    Last Post: 04-05-2008, 04:46 PM
  4. drawing resizing issue(vc++ with opengl)
    By imported_opengl_newbie in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-29-2006, 03:52 PM
  5. Weird issue with SwapBuffers()
    By LordArthur in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-23-2002, 05:32 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