1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
GLuint LoadTexture(string pic, int width, int height)
{
GLuint Texture;
BYTE * data;
FILE * picfile;
char ppic[8];
for (int i = 0; i < pic.length(); i++) // For when I actually use a different texture than "boom.bmp" (Look at line 13 and 34).
{
ppic[i] = pic[i];
}
picfile = fopen("boom.bmp", "rb");
if (picfile == NULL)
return 0;
data = (BYTE *)malloc(width * height * 3);
fread(data, width * height, 3, picfile);
fclose(picfile);
glGenTextures( 1, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
return Texture;
}
void Games()
{
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
GLuint myTex;
myTex = LoadTexture("boom.bmp", 75, 75);
glBindTexture(GL_TEXTURE_2D, myTex);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glTexCoord2f(37.5, 37.5); glVertex3f(37.5, 37.5, 0.0);
glTexCoord2f(-37.5, 37.5); glVertex3f(-37.5, 37.5, 0.0);
glTexCoord2f(-37.5, -37.5); glVertex3f(-37.5, -37.5, 0.0);
glTexCoord2f(37.5, -37.5); glVertex3f(37.5, -37.5, 0.0);
glEnd();
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINE_STRIP); // Outline the texture so I can see where it is suppose to be.
glVertex3f(38.0, 38.0, 0.0);
glVertex3f(-38.0, 38.0, 0.0);
glVertex3f(-38.0, -38.0, 0.0);
glVertex3f(38.0, -38.0, 0.0);
glVertex3f(38.0, 38.0, 0.0);
glEnd();
glDisable(GL_TEXTURE_2D);
}
|