Skip to main content
GameDev.net gamedev.net
🔒 Locked

Indexed Vertex array + texturing = fail?

Started by Captian Goatse Aug 24, 2003 at 1:06 PM 6 replies 450+ views
Original Post
Captian Goatse
Captian Goatse
I have a texture that contains all the colors of the map. I haven't done much texturing before, but figured out that it shouldn't be that hard, and since I use indexed vertex arrays they should work the same. Because I want some memory efficiency, I have only as many sets of indices as I have levels of detail(clod) here is how I render a patch:
void Renderer::renderPatch(CLodPatch& patch, int offset) {
    glVertexPointer(3, GL_FLOAT, sizeof(Vector3f), pTer->vertices + offset);
    glTexCoordPointer(2, GL_FLOAT, 0, pTer->texture + offset);
    //glColorPointer(3, GL_FLOAT, sizeof(Vector3f), pTer->colors + offset);

    glDrawElements(GL_TRIANGLE_STRIP, pTer->numIndices[patch.curLod], GL_UNSIGNED_SHORT, pTer->indices[patch.curLod]);
    fillgaps(patch.error);
}
Now as I read up, it occurs that I can't do this since the texture will only draw the texture taking place at the indices and the offset is somehow perverted. No, I don't want that. And I will not make as many indice arrays as I have patches. Now is my only bet to transform the indice array or is there some extension that works the same way as vertex pointer? The way this works is pretty retarded. [edited by - Captian Goatse on August 24, 2003 2:07:00 PM]
Captian Goatse
Captian Goatse
Am I now being clear here? I read that VBOs could be the sollution, anyone?

or am I not being coherent?
BGCJR
BGCJR
you use a offset for vertex and the texture coords?
Game Core
Captian Goatse
Captian Goatse
Yes, I use offset for vertices coords because the texture patch I want to draw is just a part of the texture I want to draw.


A quick question here:
Can I use glVertexPointer3f(....vertices + offset) with normals?
glnormalPointer3f(........normals+offset? or do I have to figure out something else?
MARS_999
MARS_999
Not sure what you''re trying to do but you need to specify glNormalPointer() with glVertexPoniter() and glTexCoordPointer() before you use glDrawElements. And you either need to have all that data stored somehow? e.g. structures or arrays. And if you are using VBO''s you need to use a BUFFER_OFFSET() like macro if you want with the gl*Pointer functions and glDrawElements function. The BUFFER_OFFSET() is actual memory size. e.g. float = 4bytes * however many data types you have.
e.g. 3 floats would = sizeof(float) * 3

Not sure if that is helping??
jamessharpe
jamessharpe
Are you enabling GL_TEXTURE_COORD_ARRAY, GL_TEXTURE_2D and GL_VERTEX_ARRAY, before making these calls?

EDIT: this code should work without glNormalPointer set if you haven't enabled the normal array.

[edited by - jamessharpe on August 31, 2003 11:10:40 AM]
Captian Goatse
Captian Goatse
I''m not using VBOs, yet.

What I want to do is to adjust the offset of the texture array to make the coloring, BUT with single list of indices. This way I can aboid the use of color pointer and use my favourite paint program to make the terrain look "cool". However, when I try to do this, the I just get one part of the texture looped over and over and over again, looking like the offset has failed.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.