glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glTranslatef(-1.5f+transx,0.0f+transy,-6.0f); // Screen movement
glColor4f(1.0f,1.0f,1.0f, 1.0f);
glEnable(GL_TEXTURE_2D);
for (int j=0; j<MAP_HEIGHT; j++)
for (int i=0; i<MAP_WIDTH; i++)
{
glPushMatrix();
glTranslatef((i*8.0f),-(j*8.0f),0.0f);
glPushMatrix();
int text;
switch (GetTile(i,j)) {
case 1: text = 29; break;
case 4: text = 29; glRotatef(90.0f,0.0f,0.0f,1.0f); break;
case 3: text = 29; glRotatef(180 ,0.0f,0.0f,1.0f); break;
case 2: text = 29; glRotatef(270 ,0.0f,0.0f,1.0f); break;
case 7: text = 30; break;
case 6: text = 30; glRotatef(90 ,0.0f,0.0f,1.0f); break;
case 5: text = 30; glRotatef(180 ,0.0f,0.0f,1.0f); break;
case 8: text = 30; glRotatef(270 ,0.0f,0.0f,1.0f); break;
case 9: text = 31; break;
case 10:text = 31; glRotatef(90.0f,0.0f,0.0f,1.0f); break;
case 11:text = 32; break;
default: text = 27;
}
glBindTexture(GL_TEXTURE_2D, tiletexture[text].texID);
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f); glVertex2f( -4.0f,-4.0f);
glTexCoord2f(1.0f,0.0f); glVertex2f( 4.0f,-4.0f);
glTexCoord2f(1.0f,1.0f); glVertex2f( 4.0f, 4.0f);
glTexCoord2f(0.0f,1.0f); glVertex2f( -4.0f, 4.0f);
glEnd();
glPopMatrix();
glPopMatrix();
}
glDisable(GL_TEXTURE_2D);
glPopMatrix();
The Monkey is back !
[edited by - MonkeyInBlack on March 7, 2004 1:37:55 PM]
Weird lines
I've been trying to get a map-loader to work but no matter what i try i'm getting these strange lines (which appear/disappear as the screen moves) :
I have absolutely no clue what i'm doing wrong. Im using a matrix of textured quads. If there is anyone who can hint me to where i should look for a solution i'd greatly appreciate it
Source code using Nehe's simple base code : here
code for the drawglscene() :
it looks like you''re applying white polygons on a green surface, just baarrelly not big enough.
Could your texture coordinates be wrapping? This will happen if you render you map at fractional coordinates.
I changed my opening post : it now includes the source to drawglscene and the complete source code w images
I''m rendering to a black background. Dont think the texturing coordinates are wrong. The weird thing is that the lines arent always there - they appear/become larger when the screen is moved. Also as you can see the lines arent there every time - which seems weird too.
The Monkey is back !
I''m rendering to a black background. Dont think the texturing coordinates are wrong. The weird thing is that the lines arent always there - they appear/become larger when the screen is moved. Also as you can see the lines arent there every time - which seems weird too.
The Monkey is back !
quote:Original post by MonkeyInBlack
I changed my opening post : it now includes the source to drawglscene and the complete source code w images
I'm rendering to a black background. Dont think the texturing coordinates are wrong. The weird thing is that the lines arent always there - they appear/become larger when the screen is moved. Also as you can see the lines arent there every time - which seems weird too.
The Monkey is back !
Still looks like your texture coordinates are wrapping. Try clamping them..
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
(For each texture)
[edited by - willm on March 7, 2004 1:20:56 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement