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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:28:11+00:00 2026-05-26T23:28:11+00:00

Am new to OpenGL. Is it possible to wrap a single image on a

  • 0

Am new to OpenGL. Is it possible to wrap a single image on a terrain?

The below code would generate image tile , but I want to add single tile on entire terrain.

glBindTexture(GL_TEXTURE_2D, land);
for (int z = 0; z < MAP_Z-1; z++)
{

    glBegin(GL_TRIANGLE_STRIP);

    for (int x = 0; x < MAP_X-1; x++)
    {

    glTexCoord2f(0.0f, 0.0f);
    glVertex3f(terrain[x][z][0], terrain[x][z][1], terrain[x][z][2]);

    glTexCoord2f(1.0f, 0.0f);
    glVertex3f(terrain[x+1][z][0], terrain[x+1][z][1], terrain[x+1][z][2]);

        glTexCoord2f(0.0f, 1.0f);
    glVertex3f(terrain[x][z+1][0], terrain[x][z+1][1], terrain[x][z+1][2]);

        glTexCoord2f(1.0f, 1.0f);
        glVertex3f(terrain[x+1][z+1][0], terrain[x+1][z+1][1], terrain[x+1][z+1][2]);

    }
    glEnd();
}
  • 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-26T23:28:11+00:00Added an answer on May 26, 2026 at 11:28 pm

    The problem is that you are currently mapping your texture to each square. You need to have your glTexCoord2f change as you go over the terrain. Just divide the x and z coordinates by the width and height of your terrain in the for loop.

    for (int z = 0; z < MAP_Z-1; z++)
    {
    
        glBegin(GL_TRIANGLE_STRIP);
    
        for (int x = 0; x < MAP_X-1; x++)
        {
    
            glTexCoord2f((float)x/(float)MAP_X, (float)z/(float)MAP_Z);
            ...
            ... // Other code with (x+1) and (z+1) in the glTexCoord2f
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so I'm kind of new with OpenGL, but I thought I should learn
Whenever I add a new .fsh or .vsh OpenGL ES 2.0 shader file to
Given this powershell code: $drivers = New-Object 'System.Collections.Generic.Dictionary[String,String]' $drivers.Add(nitrous,vx) $drivers.Add(directx,vd) $drivers.Add(openGL,vo) Is it possible
I am new to OpenGL. Wondering if there is any good Scenegraph API/framework for
I'm somewhat new to OpenGL. I've used it for extremely simple stuff like rendering
I'm new to OpenGL. I have written a programm before getting to know OpenGL
I am new to OpenGL ES 2.0, and cannot understand the following simplest shader:
I am new to OpenGL. I have to develop a simple 3D application. I
I am completely new to opengl and need some help in drawing a texture
I am new to the opengl so i am using guide of the android

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.