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

The Archive Base Latest Questions

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

How do I apply a repeating texture that always maintains its original scale (1

  • 0

How do I apply a repeating texture that always maintains its original scale (1 pixel in the texture = 1 pixel on screen), regardless of the vertex data it is applied with.

I realize this is not the most usual task, but is it possible to easily set opengl to do this, or do I need to apply some kind of mask to vertex data that respects its original appearance?

edit: in my specific case, I’m trying to draw 2D ellipses of different sizes, with the same pixel pattern. The ellipses are made of a triangle fan, and I’m having a hard time to draw a repeating texture of any kind on it. I was hoping there was some opengl configuration combination to do this easily. Also, now I realize it’s important to mention that I’m using opengles, for the iphone, so GLU is not available.

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

    Create the 3D object in question, without displaying it.

    You can get the bounds of the object as pixel locations by using gluProject (to get the pixels that represent the object’s edges. You can then use gluUnProject to map the intervening pixels to the object’s coordinates.

    Then, you start your draw over, and map a custom (on-the-fly) texture over the same object and display it.

    Not sure why you’d want to do this, but that should be a good starting point.

    Edit:

    What I mean by custom, is if the bounds of your object (in one dimension,) are -3.0 to 1.0, and the first pixel row is from -3.0 to -2.0, your texture map is going to indicate that 25% of your custom texture maps over that spot, and you create it all with the color of the pixel you want to show there.

    After thinking that through, I realized you could just draw a texture over the top of the projected screen coordinates (using the 2D drawing facilities.)

    I think that gets the gist of your idea across. I don’t think it would work well in an interactive 3D demo, if the ‘object’ comes closer and moves away, if the texture doesn’t seem to scale up and down. But you didn’t say what you were actually doing.

    Edit 2:

    OpenGL 2D Projection:

    CAUTION
    Careful with the function names, e.g., opengles 1.1 has glOrthox and glOrthof. Make sure you check what is available in your gl.h header file.

    const XSize = 640, YSize = 480 glMatrixMode (GL_PROJECTION) glLoadIdentity () glOrtho (0, XSize, YSize, 0, 0, 1) glMatrixMode (GL_MODELVIEW) glDisable(GL_DEPTH_TEST) glClear(GL_COLOR_BUFFER_BIT)  // Now draw with 2i or 2f vertices instead of the normal vertex3f functions. // And for ES, of course set up your data structures and call drawarrays ofr drawelements.  SwapBuffers() 

    This will allow you to draw 2D shapes in OpenGL (much more simply than using 3D projections.) To mix the two, e.g., draw in 3D then in 2D, follow the second link.

    Here’s an excellent tutorial on 2D drawing:
    http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL

    Here’s the basics on mixing the two:
    http://www.gamedev.net/community/forums/topic.asp?topic_id=96440

    I hope that is what you want. I get a sneaking suspicion from your post that you’re having trouble mapping your texture across triangle points to make it show up ‘straight’. You might want to review basic texture mapping on NeHe:
    http://www.gamedev.net/community/forums/topic.asp?topic_id=96440
    E.g., gltexcoord2f specifies the point (0.0-1.0) within the texture in terms of the percentage of width and height of the texture that maps to the next drawn vertex. With triangle fans, you can have some mathematical conniptions to figure out what % of width and height of the overall object you are specifying with the vertex.

    Take, for example, a sphere with a texture map (a mercator projection of the earth,) is best mapped by calculating the lines of latitude as a basis for your underlying triangle fan vertex values, as it eases calculation of the texture coordinates. Making your polygons approximate simple geometric shapes allows you to use trigonometry to more easily calculate texture coordinates.

    I hope this is helpful.

    Hehere, I’ll quit going on with desktop examples you have to modifiy. Here’s an OpenGLES example that does proper 3D texture mapping. You can use what I said above, and this example, to do 2D texture mapping.
    http://www.zeuscmd.com/tutorials/opengles/17-TextureMapping.php

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

Sidebar

Ask A Question

Stats

  • Questions 213k
  • Answers 213k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As has been pointed, you have an if wrong if… May 12, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer The MATLAB fft2 reference documentation is explicit on its requirement… May 12, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer You can get these values on Solaris by using kstat.… May 12, 2026 at 10:37 pm

Related Questions

I have a set of linq to sql classes and serialized them into JSON
I have the following scenario: Entities are loaded from the database. One of them
I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred
I have an app that has a tabBar Controller and a navBar Controller. It

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.