This is my code:
#include "player.h"
#include <gl/gl.h>
#include "SOIL.h"
//Physical Variables
GLint x=0;
GLint y=0;
GLint z=0;
GLint x_origin=32;
GLint y_origin=32;
GLdouble angle=0;
int i;
//Sprite Variables
GLint width[0];
GLint height[0];
GLint miplevel = 0;
int image_index;
GLint player_image[0];
GLint player_animation[0];
bool loadPlayerImages(const char* dir)
{
player_image[0] = SOIL_load_OGL_texture
(
dir,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
glGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_WIDTH, &width[0]);
glGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_HEIGHT, &height[0]);
}
void player::create(int type)
{
loadPlayerImages("img/0.bmp");
//width[0]=64;
//height[0]=64;
}
void player::step()
{
image_index=0;
//x+=1;
}
void player::draw()
{
//glRotated(angle,0,0,32);
//glColor3i(1,1,1);
glBindTexture(GL_TEXTURE_2D, player_image[0]);
glBegin(GL_QUADS); //begin the four sided shape
glTexCoord2i(0,0); glVertex2i(x, y); //first corner at -0.5, -0.5
glTexCoord2i(0,height[image_index]); glVertex2i(x, y+height[image_index]); //second corner at -0.5, 0.5
glTexCoord2i(width[image_index],height[image_index]); glVertex2i(x+width[image_index], y+height[image_index]); //third corner at 0.5, 0.5
glTexCoord2i(width[image_index],0); glVertex2i(x+width[image_index], y); //fourth corner at 0.5, -0.5
glEnd();
}
Its a class for a player object thats supposed to load a image using SOIL, but I can’t get it to draw the textured quad. Instead it draws a single colored block.
Can anyone help me?
~Justin123