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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:03:50+00:00 2026-05-22T21:03:50+00:00

EDIT Ok I added some changes to my texture rendering, and I’m now at

  • 0

EDIT

Ok I added some changes to my texture rendering, and I’m now at a point that it doesn’t look how I want it but before I try to change anything I just want to be sure I’m on the right path. The problem I’m trying to fix is: I have 180000 vertices. Each of them can be from one of 190 “classes”. Each class can have a different color assigned at a different time. So I’m trying to create a texture with 190 colors, and for each of the 180000 vertexes have a textureCoord to the coresponding class. So for some code:

    self.bufferTextureIndex = glGenBuffersARB(1)
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferTextureIndex)
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(textureIndexes), ADT.voidDataPointer(textureIndexes), GL_STATIC_DRAW_ARB)               

    self.texture = glGenTextures(1)
    glBindTexture(GL_TEXTURE_1D, self.texture)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 190, 0, GL_RGB , GL_FLOAT, textureArray)

So textureIndexes is an array of floats from [0..1]. len(textureIndexes) is the number of vertices I’m using (180000). For the texture, textureArray contains 190 * 3 floats coresponding to the RBG of the colors I want for each class.

The drawing part:

    glEnableClientState(GL_TEXTURE_COORD_ARRAY)
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferTextureIndex)
    glTexCoordPointer(1, GL_FLOAT, 0, None);
    glBindTexture(GL_TEXTURE_1D, self.texture)
    glEnable(GL_TEXTURE_1D)       
    if type == GL_POINTS:
        glDrawArrays( GL_POINTS, 0, len(self.vertices) / 3 ); 
    else: 
        glDrawElements(GL_TRIANGLES, len(self.triangles) , GL_UNSIGNED_SHORT, ADT.voidDataPointer(self.triangles))

So does this approach seem right ? The result isn’t what I’m expecting but that might be for the color codification I chose and I cam further look on that if the main approach is a good one. I think that most likely the indexes are build wrong. To build them I have a file with a number between 0 and 190 corresponding to the class for each index. So my index building so far was just read index then index / 190 for each vertex to get a number in [0..1]

EDIT2
So I took your advice, did the index + 0.5 / 190 to generate my indexes. I’m printing the length and values of the indice array. It’s 60000 and all are numbers between 0 and 1 , mostly between 0.3 and 0.95. But still all my vertices are of the same color. So the only thing I haven’t checked is the 1D Texture generation. Maybe here is where I got it wrong:

    i = 0
    while i < 30:
        textureArray.append([1,0,0])
        i = i + 1
    while i < 60:
        textureArray.append([1,1,0])
        i = i + 1
    while i < 90:
        textureArray.append([1,1,1])
        i = i + 1
    while i < 120:
        textureArray.append([0,1,1])
        i = i + 1
    while i < 150:
        textureArray.append([0,0,1])
        i = i + 1
    while i < 190:
        i = i + 1 
        textureArray.append([0,0,0])

This is how I generate my texture array. This will not be the actual solution but for testing reasons. So my texture should be 1/6 red – 1/6 … . The texture generation as above:

    self.texture = glGenTextures(1)
    glBindTexture(GL_TEXTURE_1D, self.texture)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEAT)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_REPEAT)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 190, 0, GL_RGB , GL_FLOAT, textureArray)

Is this texture generating correct ? Because even though my indices range is like I mentioned before, all my vertices have the color of the very first color from the texture. Funny thing is that if I “omit” the glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferTextureIndex) form the drawing and let the normals take the place of the texture indices I do get some different colors, but textureIndexes seem to all point to the very first color from my texture. I’ve uploaded two sample files with the actual values of textureIndices and normals. No ideea why the first one doesn’t work but the second seems to work(can’t really verify if they are the correct colors but at least they are different).
http://www.megafileupload.com/en/file/315895/textureIndices-txt.html
http://www.megafileupload.com/en/file/315894/normalsTest-txt.html

EDIT3

So now my indices seems to work. Here is a sample image:

https://i.stack.imgur.com/yvlV3.png

However the odd part is that as you can see the borders are not defined properly. Could this be influenced in any way by some of the parameters I pass to the texture or should I triple check my textureIndex creation ?

  • 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-22T21:03:51+00:00Added an answer on May 22, 2026 at 9:03 pm
    1. At the moment you use your normals as texture coordinates, because self.bufferNormals was bound when calling glTexCoordPointer. 1D textures aren’t just per vertex colors. they are accessed by per-vertex texture coordinates, like 2D textures, otherwise they would be a useless substitute for per-vertex colors. Read some introductory material on OpenGL texturing or texturing in general if you don’t uderstand that.

    2. As said above, definitely not.

    EDIT: According to you newest question (the one with the screenshot), keep in mind, that when the vertices of a single triangle have different texture coordinates (in your case they would belong to different classes, which I suppose shouldn’t happen), the texCoords are interpolated accross the triangle and then used to get the texture color. So you have to make sure all vertices of a triangle have the same texCoord if you don’t want this to happen (which I suppose). So you have to duplicate vertices along the “material class” borders. Perhaps you could get a quick and dirty solution by just setting glShadeModel(GL_FLAT), but that would also flatten lighting and it is not determined to which class a border triangle belongs then.

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

Sidebar

Related Questions

I created and switched to a new branch and made some changes that haven't
EDIT: I have added Slug column to address performance issues on specific record selection.
EDIT: Modified title and added update. UPDATE : We no longer believe this is
in C# I'd like to invoke the label edit of a newly added item
Edit: From another question I provided an answer that has links to a lot
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
My application should have some changes after some time (in hours or days) and
I have some code that has a purely sequential flow, without transaction. I sandwich
I've added the html-button to TinyMCE on an EZ Publish site so that the
Edit: This question was written in 2008, which was like 3 internet ages ago.

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.