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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:49:33+00:00 2026-06-08T18:49:33+00:00

I’m having a problem trying to get my texture showing correctly on some geometry.

  • 0

I’m having a problem trying to get my texture showing correctly on some geometry. Basically, I have some triangles which which describe the shape of a person’s face, and then have a png which I have to load with opencv.
I have the following code

void Geometry::loadTex(const char* fileName){

    RenderUtils * u = new RenderUtils();

    IplImage* img = u->getImg(fileName);

    GLuint texture;


    // allocate a texture name
    glGenTextures( 1, &texture );

    // select our current texture
    glBindTexture( GL_TEXTURE_2D, texture );

    // select modulate to mix texture with color for shading
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->imageData);

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

    //delete [] t;
}



IplImage* RenderUtils::getImg(const char *fileName){
    IplImage* img = 0;
    img = cvLoadImage(fileName, CV_LOAD_IMAGE_COLOR);
    if(!img) cout << "Couldn't load image " << fileName << endl;
    return img;
}



void Geometry::display(){


    glPushMatrix();
    glTranslatef(20.0f, 20.0f, -40.f);
    glRotatef(180.f, 0.0, 0.0, 1.0);
    for(int i = 0; i < numTris; i+=3){
        glBegin(GL_TRIANGLES);
        glTexCoord3f(mean[tri[i]] / texWidth, ((mean[meanLength/2 + tri[i]] - maximumMu) * -1) / texHeight, 0 ); 
        glVertex3f(mean[tri[i]], (mean[meanLength/2 + tri[i]] - maximumMu) * -1, 0);
        glTexCoord3f(mean[tri[i+1]] / texWidth, ((mean[meanLength/2 + tri[i+1]] - maximumMu) * -1) / texHeight, 0 );
        glVertex3f(mean[tri[i+1]], (mean[meanLength/2 + tri[i+1]] - maximumMu) * -1, 0);
        glTexCoord3f(mean[tri[i+2]] / texWidth, ((mean[meanLength/2 + tri[i+2]] - maximumMu) * -1) / texHeight, 0 );
        glVertex3f(mean[tri[i+2]], (mean[meanLength/2 + tri[i+2]] - maximumMu) * -1, 0);
        glEnd();
    }


    glPopMatrix();
    glutSwapBuffers();
    glFlush();

}

So loadTex is called first, which calls load getImg, and then the display method is called from Glut.

  • 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-08T18:49:35+00:00Added an answer on June 8, 2026 at 6:49 pm

    You might want to take a look at this. It does exactly what you want.

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

Sidebar

Related Questions

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 am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to select an H1 element which is the second-child in its group
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
For some reason, after submitting a string like this Jack’s Spindle from a text

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.