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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:45:42+00:00 2026-05-31T04:45:42+00:00

I want to modify the code snippet below in such a way, that I

  • 0

I want to modify the code snippet below in such a way, that I want to generate the geometry with a particular texture using for-loops. I want to input the vertex coordinates, and the amount of vertices and then generate texture planes using glVertex3f. Is this possible?

Edit: To clarify, I want to be able to give the information contained in

        glTexCoord2f(0.f, 0.f); glVertex3f(-1, -1, -1);
        glTexCoord2f(rep, 0.f); glVertex3f(-1, 1, -1);
        glTexCoord2f(rep, rep); glVertex3f(-1, 1, 1);
        glTexCoord2f(0.f, rep); glVertex3f(-1, -1, 1);

segment using a for-loop. It’s like I’d like to have a glVertex3f[n] array with the coordinates given by the user.

// Obstacle texture

// draw with different ppm file
obstProg->enable();
obstProg->bindTexture("tex", obstTex, GL_TEXTURE_2D, 0);
obstProg->bindTexture("shadowTex", renderer->getShadowTexture(), GL_TEXTURE_2D, 1);
obstProg->setUniformfv("lightPosEye", renderer->getLightPositionEyeSpace(), 3);
obstProg->setUniformfv("lightColor", lightColor, 3);

    // set shadow matrix as texture matrix
matrix4f shadowMatrix3 = renderer->getShadowMatrix();
glActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_TEXTURE);
glLoadMatrixf((GLfloat *) shadowMatrix3.get_value());

glColor3f(1.0, 1.0, 1.0);
glNormal3f(0.0, 1.0, 0.0);
glBegin(GL_QUADS);
{
    float rep = 10.f;
    glTexCoord2f(0.f, 0.f); glVertex3f(-1, -1, -1);
    glTexCoord2f(rep, 0.f); glVertex3f(-1, 1, -1);
    glTexCoord2f(rep, rep); glVertex3f(-1, 1, 1);
    glTexCoord2f(0.f, rep); glVertex3f(-1, -1, 1);

    glTexCoord2f(0.f, 0.f); glVertex3f(1, -1, -1);
    glTexCoord2f(rep, 0.f); glVertex3f(1, 1, -1);
    glTexCoord2f(rep, rep); glVertex3f(1, 1, 1);
    glTexCoord2f(0.f, rep); glVertex3f(1, -1, 1);

    glTexCoord2f(0.f, 0.f); glVertex3f(-1, -1, 1);
    glTexCoord2f(rep, 0.f); glVertex3f(-1, 1, 1);
    glTexCoord2f(rep, rep); glVertex3f(1, 1, 1);
    glTexCoord2f(0.f, rep); glVertex3f(1, -1, 1);

    glTexCoord2f(0.f, 0.f); glVertex3f(-1, -1, -1);
    glTexCoord2f(rep, 0.f); glVertex3f(-1, 1, -1);
    glTexCoord2f(rep, rep); glVertex3f(1, 1, -1);
    glTexCoord2f(0.f, rep); glVertex3f(1, -1, -1);

    glTexCoord2f(0.f, 0.f); glVertex3f(-1, 1, -1);
    glTexCoord2f(rep, 0.f); glVertex3f(1, 1, -1);
    glTexCoord2f(rep, rep); glVertex3f(1, 1, 1);
    glTexCoord2f(0.f, rep); glVertex3f(-1, 1, 1);

}
glEnd();
obstProg->disable();
  • 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-31T04:45:43+00:00Added an answer on May 31, 2026 at 4:45 am

    Since you already have the vertex data in a array it makes sense to send them to OpenGL directly, instead of manually looping over them and call immediate mode functions. Google for “Vertex Arrays”

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

Sidebar

Related Questions

I want to modify this code so that the value is a variable and
I want to modify the below code to read the nodes from a text
Is there a CPAN module or code snippet that I can use to modify
I want to modify some code in the Eclipse JDT itself (In the Debug
I want to modify a connection string that's hard-coded in a Java application (jar
I want to modify the registry of window OS using c. kindly guide me
I want to modify / change the way the floatformat works. By default it
I want to modify this code which works pretty good but (or I don't
I want to modify my query results with css styles. For example my code
Is it possible to modify NotifyIcon behavior to AlwaysShow in C#? A code snippet

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.