Original Post
Hey,
I have a problem in my tile editor in which the tex coords are always going back to 0. Even when I click on a tile (this changes the tex coords, and therefore the image on the tile), it always flash that images, then reverts back to tex coords of 0.
It is hard to explain this problem, so here is some of my code for you to look at it.
class cTile
{
public:
unsigned int ID;
int x,y;
float tex_x, tex_y; // values for tex coords (images has 4*10 textures)
bool walk;
bool item;
unsigned int data_id
void Draw();
};
tex_x = tex_x /4; //makes the tex coords align to the texture i want
tex_y = tex_y /10;
glInitNames();// used for picking the tiles
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, txBox.ID);
glPushName(this->ID);
glBegin(GL_QUADS);
glTexCoord2f(tex_x, tex_y);
glVertex3f(0.0f, 0.0f, 0.0f);
glTexCoord2f(tex_x + 0.25, tex_y);
glVertex3f( 1.0f, 0.0f, 0.0f);
glTexCoord2f(tex_x + 0.25, tex_y + 0.1);
glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2f(tex_x, tex_y + 0.1);
glVertex3f(0.0f, 1.0f, 0.0f);
glEnd();
glPopName();
glPopMatrix();
}
////////////////////////////////
case WM_LBUTTONDOWN:
{
POINT cursor_point;
GetCursorPos(&cursor_point);
ScreenToClient(hWnd, &cursor_point);
int objectID = RetrieveObjectID(cursor_point.x, cursor_point.y);
// Now we just do a switch on our object ID's to see if we hit one.
if(objectID > 0)
txStr = "over";
else
txStr = "hello";
if(objectID > 0)
{
Tile[objectID].tex_x = 3;
Tile[objectID].tex_y = 3;
}
}
If you see where I change the tex coords when a tile is clicked on, this is the problem. It flashes that new image (as if being scrolled, not a sudden movement) and then reverts back to the old one. Thannks for all you help
EDIT:
I perhaps havent explained myself more cleary, what I am trying to do is change the images of the tile, by using one texture with 4*10 smaller images that will go on the tiles. By the texcoords back to 0, I mean the first image is being displayed, rather than the one I want.
PS Sorry for how unclear this question is
Streamline.cjb.net - Flash and Opengl Country
[edited by - gresc on January 29, 2004 4:26:57 AM]