PDA

View Full Version : PROBLEM



zadeh79
08-03-2006, 05:12 PM
LOOK AT THIS.. WHy the hell is the bottom of of the figure look like that?

http://www.geocities.com/zadeh1979/gameprob.JPG


HERE'S THE CODE:


#include <OpenGLSB.h>
#include <GLTools.h>
#include "glbmp.h"


GLfloat a = 0.0;
GLfloat s = 0.0;
GLfloat x = 0.0;
GLfloat y = 0.0;
GLfloat anisosize;


void init(void)
{

glEnable(GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);


}


void RenderScene(void)
{


GLuint texture = 0;

glbmp_t bitmap;

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glbmp_LoadBitmap("grass.bmp", 1, &bitmap);

//generate and bind the OpenGL texture
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);


//copy data from bitmap into texture
glTexImage2D(GL_TEXTURE_2D, 0, 3, bitmap.width, bitmap.height,
0, GL_RGB, GL_UNSIGNED_BYTE, bitmap.rgb_data);


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);



glViewport(0, 0, 1024, 768);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(50.0, 1.0, -5.0, 0.0);


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt(s + 0.0, a + 0.0, -3.0, s + 0.0 ,a + 0.0, 0.0, 0.0, 10.0, 0.0);


glClear(GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);


glShadeModel(GL_SMOOTH);



glFrontFace(GL_CW);
//glEnable(GL_CULL_FACE);


glBegin(GL_QUAD_STRIP);

glTexCoord2f(1.0, 0.0);
glVertex3f(1.0f, 0.0f, 0.0f);

glTexCoord2f(1.0, 1.0);
glVertex3f(1.0f, 1.0f, 0.0f);

glTexCoord2f(0.0, 1.0);
glVertex3f(0.0f, 1.0f, 0.0f);

glTexCoord2f(0.0, 0.0);
glVertex3f(0.0f, 0.0f, 0.0f);

glEnd();


glDeleteTextures(1, &texture);
glbmp_FreeBitmap(&bitmap);


glutSwapBuffers();


}


void TimerFunction(int value)
{

glutTimerFunc(1, TimerFunction, 1);

glutPostRedisplay();
}


void SpecialKeys(int key, int x, int y)
{
if (key == GLUT_KEY_RIGHT)
s = s - .1;

if (key == GLUT_KEY_LEFT)
s = s + .1;

if (key == GLUT_KEY_UP)
a = a + .1;

if (key == GLUT_KEY_DOWN)
a = a - .1;


glutPostRedisplay();
}


int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);
glutInitWindowSize(1024, 768);
glutCreateWindow("STONES OF");
glutDisplayFunc(RenderScene);
glutSpecialFunc(SpecialKeys);
glutTimerFunc(1, TimerFunction, 1);
init();

glutMainLoop();

return 0;
}

k_szczech
08-03-2006, 06:11 PM
change:
glBegin(GL_QUAD_STRIP);
to:
glBegin(GL_QUADS);