PDA

View Full Version : bmp not loading onto quad



kevthecelt
03-11-2004, 04:24 AM
hey,
right, the problem is that my bitmap isnt being mapped onto the square at all, its just white, ive tried using a different variety of bmps but to no avail, its a project that me and me friend are doing and the annoying thing is the mapping worked b4 hand on the old code here:

void movingRowAliens()
{

static float alienStart = 2.7f;
double xLeft = -4;

if (alienStart >= -2.7)
{
for (double d = xLeft; d < 0-xLeft; d++)
{

float xCoord = (float)d;
glBindTexture(GL_TEXTURE_2D,g_Texture[0]);
glColor3ub(255,255,255);
glBegin (GL_QUADS);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(-.1+xCoord,alienStart,0);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-.1+xCoord,-.3+alienStart,0);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(.3+xCoord,-.3+alienStart,0);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(.3+xCoord,alienStart,0);


glEnd();

}

}

else alienStart = 2.7f;

alienStart -= .01f;


}



and here is the new revised code

void alienAttack(VectorList *alienList)
{
Vector* vect = alienList->getCurrent();

glBindTexture(GL_TEXTURE_2D,g_Texture[0]);
glColor3ub(255,255,255);
glBegin (GL_QUADS);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(-.1+vect->x,vect->y,0);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-.1+vect->x,-.3+vect->y,0);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(.3+vect->x,-.3+vect->y,0);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(.3+vect->x,vect->y,0);
glEnd();


//This moves the alien(s) accross the sceen as they move down
if (!xDirectionTest) // 0 = Moving Right, 1 = MovingLeft
{
if(alienXposition < 1)
{
alienXposition+=.01f;
}

else
{
xDirectionTest = 1;
}
}
else //xDirectionTest=1, => moveing left.
{
if (alienXposition > -1)
{
alienXposition-=.01f;
}
else
{
xDirectionTest = 0;
}
}


vect->y -= .01f;
vect->x = alienXposition;
}


im using the sample code from gametutorials.com so i doubt theres anything wrong with my CreateTexture function etc

CreateTexture(g_Texture,"aliengood.bmp", 0);
thats the declaration of it, any help would be greatly appreciated because ive been at this for days :p

Aeluned
03-11-2004, 04:50 AM
two things:
the first and most obvious is to ensure that you've actually enabled texture mapping:
glEnable(GL_TEXTURE_2D);

the other is that your texture has to have dimensions of powers of two.

kevthecelt
03-11-2004, 05:36 AM
great that worked fine, thanks, its always somethin small when you have a prob like that http://www.opengl.org/discussion_boards/ubb/smile.gif but now when i map different bmps onto the square the other shapes on the screen change strange and darker colors, especially if the backround color of the bmp is black, any ideas,

chowe6685
03-11-2004, 07:37 AM
just because you don't supply texture coordinates doesn't mean opengl won't use them
Its just applying the last texture coordinate to every vertex, so things look a bit strange. Disable texture mapping before drawing non texture mapped polygons