hi @all
i play around with openGL since a few days
and now i want to create
an 50x50grid for example (base for landscapes)
i play around with the examples from redbook
but how can i add here texturecoordinates and normals to
the code here?
google/nehe/codesampler/etc offers me no real tutorial "in one piece"
to learn about drawelements, only little pieces i am not able to complete
so i took that way to pick sample of rebook that works
and learn by modifying that
but my question is:
how can i add my textures and normal coordinates to that 'v' thing
and how use the texture in draw call then ?
and p.s.: if you can tell me where to activate z buffer ;)
#define NFACE 6
#define NVERT 8
void drawCube(GLdouble x0, GLdouble x1, GLdouble y0,
GLdouble y1, GLdouble z0, GLdouble z1)
{
static GLfloat v[8][3];
static GLfloat c[8][4] = {
{0.0, 0.0, 0.0, 1.0}, {1.0, 0.0, 0.0, 1.0},
{0.0, 1.0, 0.0, 1.0}, {1.0, 1.0, 0.0, 1.0},
{0.0, 0.0, 1.0, 1.0}, {1.0, 0.0, 1.0, 1.0},
{0.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}
};
/* indices of front, top, left, bottom, right, back faces */
static GLubyte indices[NFACE][4] = {
{4, 5, 6, 7}, {2, 3, 7, 6}, {0, 4, 7, 3},
{0, 1, 5, 4}, {1, 5, 6, 2}, {0, 3, 2, 1}
};
....
// Vertices Positions
v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0;
v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1;
v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0;
v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1;
v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0;
v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1;
//Normal Positions
// ????
// Texture Positions
// ????
//drawing example
glEnable (GL_DEPTH_TEST); // Z buffer is not working
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_textureID[0]);
glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_COLOR_ARRAY);
glVertexPointer (3, GL_FLOAT, 0, v);
glColorPointer (4, GL_FLOAT, 0, c);
** ?!?! glNORMALPointer (3, GL_FLOAT, 0, v);
** ?!?! glTEXTUREPointer (2, GL_FLOAT, 0, v);
glDrawElements(GL_QUADS, NFACE*4, GL_UNSIGNED_BYTE, indices);
glDisableClientState (GL_VERTEX_ARRAY);
glDisableClientState (GL_COLOR_ARRAY);
can you help me?
much thx for all answers :)
p.s.: i hate google