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 8216135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:01:38+00:00 2026-06-07T12:01:38+00:00

I am attempting to draw a quadrilateral (square) on the screen. I inserted this

  • 0

I am attempting to draw a quadrilateral (square) on the screen. I inserted this into a pre-existing program that drew a cylinder. This is in an orthographic modelview matrix, and I am almost positive the clipping volume is correct (It’s 200 in any direction from the origin). In the display function I’m using, I pushed a matrix, translated forward (0.0,0.0,-20.0), called quadriliteral, and then popped the matrix. Are the any common openGL settings people use that I’m unaware of that may make this not visible? Is there a way to get the current clipping volume and print it out in the console?

void quadrilateral() 
{
    glLoadIdentity();
    glColor3f(0.5f,0.0f,0.8f);
    glBegin(GL_QUADS);

    glVertex3f(-10.0f,-10.0f,0.0f);
    glVertex3f(-10.0f,10.0f,0.0f);
    glVertex3f(10.0f,10.0f,0.0f);
    glVertex3f(10.0f,-10.0f,0.0f);

    glEnd();
}


//This is called from a main function elsewhere
void draw(void)
{
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(500, 500); 
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Cylinder");
    glutReshapeFunc(CChangeSize);
    glutSpecialFunc(CSpecialKeys);
    glutKeyboardFunc(Ckeyboard);
    glutDisplayFunc(CRenderScene);
    CSetupRC();
    glPopMatrix();
}


void CSetupRC()
{
// Light values and coordinates
GLfloat  ambientLight[] = {0.4f, 0.4f, 0.4f, 1.0f };
GLfloat  diffuseLight[] = {0.7f, 0.7f, 0.7f, 1.0f };
GLfloat  specular[] = { 0.9f, 0.9f, 0.9f, 1.0f};
GLfloat  lightPos[] = { -50.0f, 200.0f, 200.0f, 1.0f };
GLfloat  specref[] =  { 0.6f, 0.6f, 0.6f, 1.0f };


glEnable(GL_DEPTH_TEST);    // Hidden surface removal
glEnable(GL_CULL_FACE);     // Do not calculate inside of solid object
glFrontFace(GL_CCW);

// Enable lighting
glEnable(GL_LIGHTING);

// Setup light 0
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambientLight);
glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_SPECULAR,specular);

// Position and turn on the light
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glEnable(GL_LIGHT0);

// Enable color tracking
glEnable(GL_COLOR_MATERIAL);

// Set Material properties to follow glColor values
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

// All materials hereafter have full specular reflectivity
// with a moderate shine
glMaterialfv(GL_FRONT, GL_SPECULAR,specref);
glMateriali(GL_FRONT,GL_SHININESS,64);

// Black background
glClearColor(0.0f, 0.0f, 0.0f, 0.0f );


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);

}


// Called to draw scene
void CRenderScene(void)
{
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Save the matrix state
glMatrixMode(GL_MODELVIEW);
glPushMatrix();

// Rotate about x and y axes
glRotatef(CxRot, 1.0f, 0.0f, 0.0f);
glRotatef(CyRot, 0.0f, 1.0f, 0.0f);

// Draw the cylinder
cylinder();

glPopMatrix();

// CylinderTwo
glMatrixMode(GL_MODELVIEW);
glPushMatrix();

// Rotate about x and y axes
glRotatef(CxRot, 1.0f, 0.0f, 0.0f);
glRotatef(CyRot, 0.0f, 1.0f, 0.0f);

// Draw the cylinder
glRotatef(120.0f, 1.0f, 1.0f, 1.0f);
cylinderTwo();

glPopMatrix();

// Random square
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(-30.0f,20.0f,10.0f);
quadrilateral();
glPopMatrix();

// Swap buffers
glutSwapBuffers();

}

  • 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-07T12:01:39+00:00Added an answer on June 7, 2026 at 12:01 pm

    It looks like your winding order is incorrect:

    glEnable(GL_CULL_FACE);
    

    this line means it will cull back faces.

    glFrontFace(GL_CCW);
    

    and this sets the front face to counter clockwise.

        glVertex3f(-10.0f,-10.0f,0.0f);
        glVertex3f(-10.0f,10.0f,0.0f);
        glVertex3f(10.0f,10.0f,0.0f);
        glVertex3f(10.0f,-10.0f,0.0f);
    

    Here you have clockwise ordering of your vertices meaning you are drawing with the back to camera. either disable culling:

        glDisable(GL_CULL_FACE);
    

    make the front face clockwise:

        glFrontFace(GL_CW);
    

    or change the order of your vertices to a counter clockwise order.

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

Sidebar

Related Questions

I'm attempting to draw to screen with a bunch of colors that I have
I'm attempting to draw this image on screen: This is the code: CALayer* dullLayer
Attempting to do SetData() on Texture2D that has been recently Draw()-n by SpriteBatch leads
My program is attempting to draw grammars in C# & WPF. I have: 1
I am attempting to draw a sidebar for a project that I am working
I am attempting to draw the medal overlaying the corner of the score screen
I am currently attempting to draw images on the screen at a regular rate
I'm attempting to draw text to the screen using GLUT in 2d. I want
I'm attempting to draw a text box on the screen. If I assign width
Here is my code. I'm attempting to draw a simple quadrilateral, and place a

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.