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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:42:39+00:00 2026-06-14T01:42:39+00:00

I’m trying to create a simple cell shader effect, and it involves back and

  • 0

I’m trying to create a simple cell shader effect, and it involves back and front face culling. But so far, my culling results are rather odd.

Setup OpenGL source code:

// init matrices
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, 800 / 600, 0.01f, 150);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// enable opengl caps
glEnable(GL_NORMALIZE);
glEnable(GL_CULL_FACE);
// cell shading effects
glLineWidth(3.5f);
// setup display list
pDList = glGenLists(1);
glNewList(pDList, GL_COMPILE);
    glBegin(GL_QUADS);
        // front
        glNormal3f(0, 0, 1);
        glVertex3f(-0.25f, -0.5f, -3);
        glVertex3f(0.25f, -0.5f, -3);
        glVertex3f(0.25f, -1, -3);
        glVertex3f(-0.25f, -1, -3);
        // back
        glNormal3f(0, 0, -1);
        glVertex3f(-0.25f, -0.5f, -3.5f);
        glVertex3f(0.25f, -0.5f, -3.5f);
        glVertex3f(0.25f, -1, -3.5f);
        glVertex3f(-0.25f, -1, -3.5f);
        // top 
        glNormal3f(0, 1, 0);
        glVertex3f(-0.25f, -0.5f, -3.5f);
        glVertex3f(0.25f, -0.5f, -3.5f);
        glVertex3f(0.25f, -0.5f, -3);
        glVertex3f(-0.25f, -0.5f, -3);
        // bottom
        glNormal3f(0, -1, 0);
        glVertex3f(-0.25f, -1, -3.5f);
        glVertex3f(0.25f, -1, -3.5f);
        glVertex3f(0.25f, -1, -3);
        glVertex3f(-0.25f, -1, -3);
        // right
        glNormal3f(1, 0, 0);
        glVertex3f(0.25f, -0.5f, -3);
        glVertex3f(0.25f, -0.5f, -3.5f);
        glVertex3f(0.25f, -1, -3.5f);
        glVertex3f(0.25f, -1, -3);
        // left
        glNormal3f(-1, 0, 0);
        glVertex3f(-0.25f, -0.5f, -3);
        glVertex3f(-0.25f, -0.5f, -3.5f);
        glVertex3f(-0.25f, -1, -3.5f);
        glVertex3f(-0.25f, -1, -3);
    glEnd();
glEndList();

Render source code:

// clear
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.75f, 0.75f, 0.75f, 1);
// reset matrix
glLoadIdentity();
// draw cube
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glCullFace(GL_BACK);
glColor3i(0, 0, 0);
glCallList(pDList);

This is what I got:

enter image description here

For some reason it’s only drawing the right side of the cube. Weird.
I changed the glCullFace(GL_BACK); to glCullFace(GL_FRONT); in my render function.
I got this:

enter image description here

Now it’s drawing every side? It seems to think that the right side of the cube is both back and front facing, and the rest of the cube is facing back. I also get this same result shown in the picture above when i have culling disabled.

Any other relevant info I can think of is that I’m using SDL, and that I’m sure this isn’t a graphics card issue, as I’ve ran this on two different computers, each yielding the same result.

I just started to learn how to set normals for a primitive so chances are this is a big n00b mistake, or some dumb error. I’d be a millionaire if I got a penny every time I did the most thoughtless obvious mistake and have been stuck on it for hours.

So, in a nutshell, what have I done wrong, and how to I get the proper faced sides to cull or not cull in the proper way?

  • 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-14T01:42:40+00:00Added an answer on June 14, 2026 at 1:42 am

    If you look at each triangle from the vector of its minus-normal you can define the order in which your vertices are specified (it is called winding): clockwise or counterclockwise.

    You have to be consistent with it and specify all vertices in either CW or CCW winding to make the culling work correctly.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am doing a simple coin flipping experiment for class that involves flipping a
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to create an if statement in PHP that prevents a single post
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.