Why aren't my textures being shown? (OpenGL)
I have looked over this program and compared it to other ones that had textures working but can't seem to find the problem. It basically draws different sized quads from triangles and they all have a raindrop texture applied to them, but it doesn't work. Did I miss something here. Here is the setup and rendering parts of my code.
Code:
void ParticleScene::setupView(int width, int height)
{
glViewport(0, 0, width,height);
float ratio = static_cast<float>(width)/static_cast<float>(height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(42, ratio, 0, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void ParticleScene::initialize()
{
glDisable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
//load the raindrop textures
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &rainTexture);
image.Load("Data/star.tga");
glBindTexture(GL_TEXTURE_2D, rainTexture);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.GetWidth(), image.GetHeight(),
GL_RGBA, GL_UNSIGNED_BYTE, image.GetImage());
image.Release();
/////
Code:
void ParticleScene::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0, 0, 80,
0, 0, -1,
0, 1, 0);
//just lines to indicate bundary of rainfall
glBegin(GL_LINES);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-40, STARTING_HEIGHT, 0);
glVertex3f(40, STARTING_HEIGHT, 0);
glColor3f(0.0, 1.0, 0.0);
glVertex3f(-40, ENDING_HEIGHT, 0);
glVertex3f(40, ENDING_HEIGHT, 0);
glEnd();
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
for(size_t i = 0; i < MAX_PARTICLES; ++i)
{
if(raindrops[i].alive == true)
{
float sz = raindrops[i].size;
float x = raindrops[i].xPos;
float y = raindrops[i].yPos;
float z = raindrops[i].zPos;
glBindTexture(GL_TEXTURE_2D, rainTexture);
glBegin(GL_TRIANGLE_STRIP);
glColor4f(0.0, 0.0, raindrops[i].blue, raindrops[i].alpha);
glTexCoord2i(1, 1); glVertex3f(x + sz, y + sz, z);
glTexCoord2i(0, 1); glVertex3f(x - sz, y + sz, z);
glTexCoord2i(1, 0); glVertex3f(x + sz, y - sz, z);
glTexCoord2i(0, 0); glVertex3f(x - sz, y - sz, z);
glEnd();
the "raindrops" show as blocks with the attributes in their structures but neither the alpha or the textures seem to be enabled