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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:30:29+00:00 2026-05-27T23:30:29+00:00

asked a question on my project earlier but it seems im learning more about

  • 0

asked a question on my project earlier but it seems im learning more about how little i know of openGL than how much i do at the moment, but ever answer i get is feeding my knowledge so thanks in advance!

Ok so currently my car shape is drawn using GL_LINE_LOOP and looks like this.
car shape

The image i want to map onto the body of the car looks like this.
car picture

I know my shape the picture isnt perfect but im attempting to put that picture within my lines so that it gives at least some impression of the car im modelling. i have attempted this using the following code:

void drawBody(int textureindex)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureLib[textureindex]);

glBegin(GL_POLYGON);

glTexCoord2f(0.0F, 0.0F);
glVertex2f(-1.0f, 0.0f);
glTexCoord2f(-0.97, 0.0);
glVertex2f(-1.97f, 0.0f);
//wheel arch begin.
glTexCoord2f(-0.93, 0.3);
glVertex2f(-1.93f, 0.3f);
glTexCoord2f(-0.95, 0.4);
glVertex2f(-1.95f, 0.4f);
glTexCoord2f(-1.2, 0.6);
glVertex2f(-2.2f, 0.6f);
glTexCoord2f(-1.6, 0.6);
glVertex2f(-2.6f, 0.6f);
glTexCoord2f(-1.82, 0.4);
glVertex2f(-2.82f, 0.4f);
glTexCoord2f(-1.8, 0.3);
glVertex2f(-2.8f, 0.3f);
glTexCoord2f(-1.78, 0.0);
glVertex2f(-2.78f, 0.0f);
//end wheel arch.
//Front of car.
glTexCoord2f(-2.8, 0.0);
glVertex2f(-3.8f, 0.0f);
glTexCoord2f(-2.7, 0.2);
glVertex2f(-3.7f, 0.2f);
glTexCoord2f(-2.8, 0.4);
glVertex2f(-3.8f, 0.4f);
glTexCoord2f(-1.8, 0.7);
glVertex2f(-2.8f, 0.7f);
glTexCoord2f(-1.4, 0.7);
glVertex2f(-2.4f, 0.7f);
//Windscreen.
glTexCoord2f(0.0, 1.0);
glVertex2f(-1.0f, 1.0f);
glTexCoord2f(1.5, 1.05);
glVertex2f(0.5f, 1.05f);
glTexCoord2f(3.3, 0.8);
glVertex2f(2.3f, 0.8f);
//rear bumper.
glTexCoord2f(3.15, 0.5);
glVertex2f(2.15f, 0.5f);
glTexCoord2f(3.15, 0.3);
glVertex2f(2.15f, 0.3f);
glTexCoord2f(3.35, 0.3);
glVertex2f(2.35f, 0.3f);
glTexCoord2f(3.0, 0.0);
glVertex2f(2.0f, 0.0f);
glTexCoord2f(2.83, 0.0);
glVertex2f(1.83f, 0.0f);
//wheel arch begin.
glTexCoord2f(2.85, 0.3);
glVertex2f(1.85f, 0.3f);
glTexCoord2f(2.86, 0.4);
glVertex2f(1.86f, 0.4f);
glTexCoord2f(2.6, 0.6);
glVertex2f(1.6f, 0.6f);
glTexCoord2f(2.2, 0.6);
glVertex2f(1.2f, 0.6f);
glTexCoord2f(2.0, 0.4);
glVertex2f(1.0f, 0.4f);
glTexCoord2f(2.0, 0.3);
glVertex2f(1.0f, 0.3f);
glTexCoord2f(2.05, 0.0);
glVertex2f(1.05f, 0.0f);
//end wheel arch.
glEnd();
glDisable(GL_TEXTURE_2D);
}

Which results in this awfullness

awful car

Two problems. one is cleary my coords for texturing are really wrong and secondly i dont know how to stop the polygon mode from getting rid of the wheel arches :/ help on these two fronts would be greatly appreciated 🙂

  • 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-27T23:30:30+00:00Added an answer on May 27, 2026 at 11:30 pm

    Texture coordinates should be in the range [0, 1].

    The wheel arches problem is because OpenGL only renders convex polygons. Use the tessellation facilities to convert concave polygons into triangle meshes.

    P.S.: For OpenGL’s immediate mode, I suggest you adopt a different coding style that is vastly easier to read and maintain:

    void drawBody(int textureindex)
    {
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, textureLib[textureindex]);
    
        glBegin(GL_POLYGON);
    
        glTexCoord2f( 0.0 , 0.0 ); glVertex2f(-1.0 , 0.0 );
        glTexCoord2f(-0.97, 0.0 ); glVertex2f(-1.97, 0.0 );
    
        // Wheel arch
        glTexCoord2f(-0.93, 0.3 ); glVertex2f(-1.93, 0.3 );
        glTexCoord2f(-0.95, 0.4 ); glVertex2f(-1.95, 0.4 );
        glTexCoord2f(-1.2 , 0.6 ); glVertex2f(-2.2 , 0.6 );
        glTexCoord2f(-1.6 , 0.6 ); glVertex2f(-2.6 , 0.6 );
        glTexCoord2f(-1.82, 0.4 ); glVertex2f(-2.82, 0.4 );
        glTexCoord2f(-1.8 , 0.3 ); glVertex2f(-2.8 , 0.3 );
        glTexCoord2f(-1.78, 0.0 ); glVertex2f(-2.78, 0.0 );
    
        // Front of car
        glTexCoord2f(-2.8 , 0.0 ); glVertex2f(-3.8 , 0.0 );
        glTexCoord2f(-2.7 , 0.2 ); glVertex2f(-3.7 , 0.2 );
        glTexCoord2f(-2.8 , 0.4 ); glVertex2f(-3.8 , 0.4 );
        glTexCoord2f(-1.8 , 0.7 ); glVertex2f(-2.8 , 0.7 );
        glTexCoord2f(-1.4 , 0.7 ); glVertex2f(-2.4 , 0.7 );
    
        // Windscreen
        glTexCoord2f( 0.0 , 1.0 ); glVertex2f(-1.0 , 1.0 );
        glTexCoord2f( 1.5 , 1.05); glVertex2f( 0.5 , 1.05);
        glTexCoord2f( 3.3 , 0.8 ); glVertex2f( 2.3 , 0.8 );
    
        // Rear bumper
        glTexCoord2f( 3.15, 0.5 ); glVertex2f( 2.15, 0.5 );
        glTexCoord2f( 3.15, 0.3 ); glVertex2f( 2.15, 0.3 );
        glTexCoord2f( 3.35, 0.3 ); glVertex2f( 2.35, 0.3 );
        glTexCoord2f( 3.0 , 0.0 ); glVertex2f( 2.0 , 0.0 );
        glTexCoord2f( 2.83, 0.0 ); glVertex2f( 1.83, 0.0 );
    
        // Wheel arch
        glTexCoord2f( 2.85, 0.3 ); glVertex2f( 1.85, 0.3 );
        glTexCoord2f( 2.86, 0.4 ); glVertex2f( 1.86, 0.4 );
        glTexCoord2f( 2.6 , 0.6 ); glVertex2f( 1.6 , 0.6 );
        glTexCoord2f( 2.2 , 0.6 ); glVertex2f( 1.2 , 0.6 );
        glTexCoord2f( 2.0 , 0.4 ); glVertex2f( 1.0 , 0.4 );
        glTexCoord2f( 2.0 , 0.3 ); glVertex2f( 1.0 , 0.3 );
        glTexCoord2f( 2.05, 0.0 ); glVertex2f( 1.05, 0.0 );
    
        glEnd();
        glDisable(GL_TEXTURE_2D);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've asked about this earlier but the question itself and all the information in
Despite an earlier question ( asked here ), our project is constrained to using
I asked a question earlier about which language to use for an AI prototype.
I asked this question earlier but I was very vague and a lot of
I know I already asked related question but now it's a bit different situation.
I asked this question over on the asp.net forums, and nobody seems to know
I asked a question yesterday about a little app that I would like to
Refering to a previously asked question , I would like to know how to
This is probably a kinda commonly asked question but I could do with help
Another question asked about determining odd/evenness in C, and the idiomatic (x & 1)

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.