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

Textures

Started by injunjoe Nov 20, 2003 at 11:28 PM 1 replies 700+ views
Original Post
injunjoe
injunjoe
Hello all, I am having trouble mapping trextures correctly to triangles using a glDrawElements. Maybe I am not defining the texture array correctly. I am using just a standard array. TextArray[]={ 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0} I don''t know if opengl has support to define each text array parameter for each index triangle within my triangle array. Can anyone help. Thanks
Leyder Dylan
Leyder Dylan
Post your drawing function code. Perhaps that you''ve done some mistakes in the glDrawElements function.
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
injunjoe
injunjoe
sorry, here is an example


GLfloat pCorners[] = {GetBaseUnitX() * -0.25f, 0.0f, GetBaseUnitZ() * 0.5f, // 0 Boot
GetBaseUnitX() * -0.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * 0.5f, // 1
GetBaseUnitX() * 1.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * 0.5f, // 2
GetBaseUnitX() * 1.25f, 0.0f, GetBaseUnitZ() * 0.5f, // 3
GetBaseUnitX() * 1.5f, 0.0f, GetBaseUnitZ() * 0.25f, // 4
GetBaseUnitX() * 1.5f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * 0.25f, // 5
GetBaseUnitX() * 1.5f, 0.0f, GetBaseUnitZ() * -0.25f, // 6
GetBaseUnitX() * 1.5f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * -0.25f, // 7
GetBaseUnitX() * 1.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * -0.5f, // 8
GetBaseUnitX() * 1.25f, 0.0f, GetBaseUnitZ() * -0.5f, // 9
GetBaseUnitX() * -0.25f, 0.0f, GetBaseUnitZ() * -0.5f, // 10
GetBaseUnitX() * -0.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * -0.5f, // 11
GetBaseUnitX() * 1.25f, GetBaseUnitY() * 0.75f, GetBaseUnitZ() * -0.25f,// 12
GetBaseUnitX() * 1.25f, GetBaseUnitY() * 0.75f, GetBaseUnitZ() * 0.25f, // 13
GetBaseUnitX() * 0.75f, GetBaseUnitY() * 0.75f, GetBaseUnitZ() * -0.25f,// 14
GetBaseUnitX() * 0.75f, GetBaseUnitY() * 0.75f, GetBaseUnitZ() * 0.25f, // 15
GetBaseUnitX() * 0.5f, GetBaseUnitY(), GetBaseUnitZ() * -0.25f, // 16
GetBaseUnitX() * 0.5f, GetBaseUnitY(), GetBaseUnitZ() * 0.25f, // 17
GetBaseUnitX() * 0.5f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * 0.5f, // 18
GetBaseUnitX() * 0.5f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * -0.5f, // 19
GetBaseUnitX() * 0.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * 0.5f, // 20
GetBaseUnitX() * 0.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * -0.5f, // 21
GetBaseUnitX() * -0.25f, GetBaseUnitY() * 0.5f, GetBaseUnitZ() * 0.5f, // 22
GetBaseUnitX() * -0.25f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * 0.5f, // 23
GetBaseUnitX() * 0.25f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * 0.5f, // 24
GetBaseUnitX() * 0.5f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * 0.25f, // 25
GetBaseUnitX() * 0.5f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * -0.25f, // 26
GetBaseUnitX() * 0.25f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * -0.5f, // 27
GetBaseUnitX() * 0.25f, GetBaseUnitY() * 0.0f, GetBaseUnitZ() * -0.5f, // 28
GetBaseUnitX() * -0.25f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * -0.5f, // 29
GetBaseUnitX() * -0.25f, GetBaseUnitY() * 0.0f, GetBaseUnitZ() * -0.5f, // 30
GetBaseUnitX() * -0.5f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * -0.25f, // 31
GetBaseUnitX() * -0.5f, GetBaseUnitY() * 0.0f, GetBaseUnitZ() * -0.25f, // 32
GetBaseUnitX() * -0.5f, GetBaseUnitY() * 2.0f, GetBaseUnitZ() * 0.25f, // 33
GetBaseUnitX() * -0.5f, GetBaseUnitY() * 0.0f, GetBaseUnitZ() * 0.25f}; // 34

GLubyte pIndexes[] = {0, 3, 2, 1, // Right Bottom
3, 4, 5, 2, // Right Front Bottom
4, 6, 7, 5, // Front Bottom
6, 9, 8, 7, // Left Front Bottom
9, 10, 11, 8, // Left Bottom
5, 7, 12, 13, // Top Front Angle
13, 12, 14, 15, // Top
14, 16, 17, 15, // Top Back Angle
18, 2, 13, 15, // Right Angle
19, 14, 12, 8, // Left Angle
18, 15, 17, 20, // Right Angle Back
19, 14, 16, 21, // Left Angle Back
5, 13, 13, 2, // Right Angle Front
8, 12, 12, 7, // Left Angle Front
22, 20, 24, 23, // Heal Right Side
24, 20, 17, 25, // Heal Right Front Side
17, 16, 26, 25, // Heal Front Side
16, 28, 27, 26, // Heal Left Front Side
28, 30, 29, 27, // Heal Left Side
30, 32, 31, 29, // Heal Left Back Side
32, 34, 33, 31, // Heal Back Side
34, 0, 23, 33}; // Heal Right Back Side

GLfloat norm_coords[22][3];

GLfloat tex_coords[] = { 0.0, 0.0,
0.0, 1.0,
1.0, 1.0,
1.0, 0.0 };

GLfloat pv[3][3];
GLfloat ov[3];

for (int intN = 0; intN < 22; intN++)
{
pv[0][0] = pCorners[pIndexes[intN * 4] * 3];
pv[0][1] = pCorners[pIndexes[intN * 4] * 3 + 1];
pv[0][2] = pCorners[pIndexes[intN * 4] * 3 + 2];

pv[1][0] = pCorners[pIndexes[intN * 4 + 1] * 3];
pv[1][1] = pCorners[pIndexes[intN * 4 + 1] * 3 + 1];
pv[1][2] = pCorners[pIndexes[intN * 4 + 1] * 3 + 2];

pv[2][0] = pCorners[pIndexes[intN * 4 + 2] * 3];
pv[2][1] = pCorners[pIndexes[intN * 4 + 2] * 3 + 1];
pv[2][2] = pCorners[pIndexes[intN * 4 + 2] * 3 + 2];

calcNormal(pv,ov);

norm_coords[intN][0] = ov[0];
norm_coords[intN][1] = ov[1];
norm_coords[intN][2] = ov[2];
};

// Boot
glPushMatrix();

if (BuildSide == oRight)
{
glTranslatef(0.0f, GetBaseUnitY() * -8.0f, GetBaseUnitZ() * 1.0f);
}
else
{
glTranslatef(0.0f, GetBaseUnitY() * -8.0f, GetBaseUnitZ() * -1.0f);
}

glEnable(GL_TEXTURE_2D);

glColor3ub(150,100,150);

LoadTexture(BlackLeather);

glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer (2, GL_FLOAT, 0, tex_coords );

glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, norm_coords);

glEnableClientState ( GL_VERTEX_ARRAY );
glVertexPointer(3, GL_FLOAT, 0, pCorners);

glDrawElements(GL_QUADS, 88, GL_UNSIGNED_BYTE, pIndexes);

glPopMatrix();

Topic Locked

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

Sign in to reply to this topic.