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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:37:54+00:00 2026-05-23T03:37:54+00:00

The tutorial has an example called the Flatten Shader, which displays the GLUT teapot

  • 0

The tutorial has an example called the Flatten Shader, which displays the GLUT teapot as a flatten teapot. Here is the link to the Flatten Shader.

I have done everything exactly like the steps mentioned in the tutorial, but my teapot is not flat like how the teapot in the tutorial looks like. It just looks like a normal teapot.

Here is the code for the vertex shader:

  void main()
  {
     vec4 v = vec4(gl_Vertex);
     v.z = 0.0;
     gl_Position = gl_ModelViewProjectionMatrix * v;
  }

Here is my fragment shader:

 void main()
 {
    gl_FragColor = gl_Color;
 }

And here is how I draw the Teapot:

 void display ( void )
{   
    glClearDepth(1.0);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode( GL_MODELVIEW );

    glLoadIdentity();

    gluLookAt( 0.0, 0.0, 2.0,
           0.0, 0.0, 0.0,
           0.0, 1.0, 0.0
             );

    glMultMatrixd(trackball->getRotation());

    const GLfloat diffuseIntensity[] = { 0.8, 0.4, 0.4, 1.0 };
    const GLfloat specularIntensity[] = { 0.5, 0.5, 0.5, 1.0 };

    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, diffuseIntensity);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularIntensity);
    glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, 5.0 );

    glutSolidTeapot(1.0);

    glutSwapBuffers();
}

While it is supposed to be “Flat”, the Teapot that gets displayed is like a normal teapot. If you think that I missed some initial configurations / setup steps, then don’t because I already did them:

GLuint createShader ( const GLchar* const source, GLenum type )
{
     GLuint shader = glCreateShader( type );
     glShaderSource( shader, 1, const_cast<const GLchar**>(&source), 0 );
     glCompileShader( shader );

     return shader;
}

and:

GLuint createProgram ( const GLuint shader )
{
     GLuint program = glCreateProgram();
     glAttachShader(program, shader);
     glLinkProgram(program);

     return program;
}

And here is where everything gets together:

    GLuint vertexShader = createShader(vertexShaderSource, GL_VERTEX_SHADER);
    GLuint fragmentShader = createShader(fragmentShaderSource, GL_FRAGMENT_SHADER);

    GLuint vertexShaderProgram = createProgram(vertexShader);
    GLuint fragmentShaderProgram = createProgram(fragmentShader);

    glUseProgram(vertexShaderProgram);
    glUseProgram(fragmentShaderProgram);

Where am I going wrong?

  • 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-05-23T03:37:55+00:00Added an answer on May 23, 2026 at 3:37 am

    A few things:

    1. You are not binding your shaders correctly. Your createProgram function needs to bind both the fragment shader and the vertex shader together. You should replace it with code that looks like this:

      GLuint createProgram ( const GLuint fshader, const GLuint vshader )
      {
           GLuint program = glCreateProgram();
           glAttachShader(program, fshader);
           glAttachShader(program, vshader);       
           glLinkProgram(program);
           return program;
      

      }

    2. And correspondingly, you should modify your last snippet to look like this:

      GLuint vertexShader = createShader(vertexShaderSource, GL_VERTEX_SHADER);
      GLuint fragmentShader = createShader(fragmentShaderSource, GL_FRAGMENT_SHADER);
      GLuint shaderProgram = createProgram(fragmentShader, vertexShader);
      glUseProgram(shaderProgram);
      
    3. Also, there could be other issues. You should use glGet(Shader|Program)InfoLog to help debug your shaders, and also make calls to glGetError to help diagnose where your program failed.

    4. Finally, I can’t vouch for the credibility of this stack exchange answer, but apparently on some older ATi implementations gl_Color is a vec3, not a vec4, and so you need to cast it before assigning. See the following discussion: GLSL fragment shader syntax error

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

Sidebar

Related Questions

I'm working through an iPhone tutorial ( link text and it has me put
I have seen a tutorial that has the following JSON: { books:[{title:frankenstein},{title:Moby Dick}] }
here is part of tutorial in oracle page : Consider the following example: List
I am trying to teach myself Smalltalk. A tutorial has this example of a
Has anyone used Pear: Spreadsheet_Excel_Writer ? The Formatting Tutorial lists a script similar to
I have a course object. The course object has a set of tutorials and
A tutorial I have on Regex in python explains how to use the re
I'm using this tutorial on AsyncTask with a task and a notification: https://eliasbland.wordpress.com/2011/03/11/an-example-of-how-to-run-a-background-task-and-report-progress-in-the-status-bar-using-asynctask-on-android/ What
I have a book called Statistics for Computer Scientists as well as my engineering
Am following the tutorial here on creating a simple todo list app: http://www.mydroid.apnafundaz.com/2010/07/todolist-application-in-android-step-by-step-guide-with-screen-shots/ Have

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.