Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:50:43+00:00 2026-06-13T12:50:43+00:00

I am trying to simply draw a triangle in a window. I’ve drawn shapes

  • 0

I am trying to simply draw a triangle in a window. I’ve drawn shapes before in previous code, and have looked up common issues such as failure to flush or not clearing the color buffer.

No matter what I seem to try though, I can’t get anything to draw on screen, even after I’ve simplified my code to basically look exactly like my previous (working!) code. All I have is a main and a render:

// Declarations //
void Render(void); //Call the drawing functions

int main(int argc, char *argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500, 500);
    glutInitWindowPosition(20,20);
    glutCreateWindow("Triangle Test");

    //prepare for drawing
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);

    //now draw
    glutDisplayFunc(Render);

    glutMainLoop();
}


// ---- Render Function ----
void Render(void)
{

    // Draw a triangle
    glColor3f(1.0f, 1.0f, 1.0f);

    glBegin(GL_LINE_STRIP);

    glVertex2f(100.0f, 20.0f);
    glVertex2f(0.0f, 20.0f);
    glVertex2f(20.0f, 50.0f);

    glEnd();
    glFlush();
}

On run, it draws a window with the background color I set (in this case black) and nothing else. I’m completely stumped. All of the other questions on stack seem to be resolved by things I have in here (i.e. glFlush) and its virtually identical to my old code, which draws fine. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:50:44+00:00Added an answer on June 13, 2026 at 12:50 pm

    You’re drawing a line strip that’s bigger than your window. You need to either set your matrices so you see a larger area, draw a smaller polygon, or draw a filled polygon by drawing a triangle instead of a line strip.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to simply draw some text with a stroke and then apply a
I am simply trying to draw a rectangle inside of a panel using flex4.
I'm trying to draw a square in XNA and simply move it around with
I have a simple OpenGL program and trying to draw an instanced array that
I'm trying to show textures by openGL. In following code I want to draw
I'm simply trying to I’m simply trying to draw a circle in the same
This is probably a simple thing. I'm trying to draw my first shapes in
I have a simply Box2d body with a triangular polygon shape and I'm trying
Currently I'm trying to do what I thought would be a simple task: Draw
I am trying to draw a simple 256x256 pixel RGBA square using python's png

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.