Archived

This topic is now archived and is closed to further replies.

Tiling Problem!

This topic is 5655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HI guys i have been working on getting tiling working but when i run my progam know texture shows up! here is the code for tiling
  
int DrawGLScene(GLvoid)									// Here''s Where We Do All The Drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer

	glLoadIdentity();
	glDisable(GL_DEPTH_TEST);
	glTranslatef(-5.0f, -5.0f, -20.0f);
	draw_tiles();

	return TRUE;										// Everything Went OK

}

int draw_tiles(GLvoid)
{  
	int tile; 
	
	for (int y = 0; y < MAP_SIZEY; y++)  
	{    
		for (int x = 0; x < MAP_SIZEX; x++)    
		{	
			tile = map[y][x];	
			
			glBindTexture(GL_TEXTURE_2D, texture[tile]);		
			
			glBegin(GL_QUADS);		
			glTexCoord2f(0.0f, 0.0f); glVertex3f(float(x), float(y), 0.0f);		
			glTexCoord2f(1.0f, 0.0f); glVertex3f(float(x + 1), float(y), 0.0f);		
			glTexCoord2f(1.0f, 1.0f); glVertex3f(float(x + 1), float(y + 1), 0.0f);		
			glTexCoord2f(0.0f, 1.0f); glVertex3f(float(x), float(y + 1), 0.0f);		
			glEnd();    
		}  
	}  
	
	return (1);
}  
  
and here is the code for texturing
  
AUX_RGBImageRec *LoadBMP(char *Filename)                // Loads A Bitmap Image

{
        FILE *File=NULL;                                // File Handle

        if (!Filename)                                  // Make Sure A Filename Was Given

        {
                return NULL;                            // If Not Return NULL

        }
        File=fopen(Filename,"r");                       // Check To See If The File Exists

        if (File)                                       // Does The File Exist?

        {
                fclose(File);                           // Close The Handle

                return auxDIBImageLoad(Filename);       // Load The Bitmap And Return A Pointer

        }
        return NULL;                                    // If Load Failed Return NULL

}

int LoadGLTextures()                                    // Load Bitmaps And Convert To Textures

{
        int Status=FALSE;                               // Status Indicator

        AUX_RGBImageRec *TextureImage[2];               // Create Storage Space For The Textures

        memset(TextureImage,0,sizeof(void *)*1);        // Set The Pointer To NULL


        if ((TextureImage[0]=LoadBMP("face.bmp")) &&	// Logo Texture

			(TextureImage[1]=LoadBMP("land.bmp")))	// First Mask

        {
                Status=TRUE;                            // Set The Status To TRUE

                glGenTextures(2, &texture[0]);          // Create Five Textures


				for (loop=0; loop<2; loop++)			// Loop Through All 5 Textures

				{
					glBindTexture(GL_TEXTURE_2D, texture[loop]);
					glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
					glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
					gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
				}
		}
		for (loop=0; loop<2; loop++)						// Loop Through All 5 Textures

		{
	        if (TextureImage[loop])							// If Texture Exists

		    {
			        if (TextureImage[loop]->data)			// If Texture Image Exists

				    {
					        free(TextureImage[loop]->data);	// Free The Texture Image Memory

					}
					free(TextureImage[loop]);				// Free The Image Structure

			}
		}
        return Status;                                  // Return The Status

}
  
any ideas? Thanks in advance Sir Darkan Fireblade -"I Feel like im playing Poker i dont know who''s bluffing!"-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This must be said about 1,000,000 times a day. Are your textures'' dimensions powers of 2?

Share this post


Link to post
Share on other sites
I''m not sure of the dimensions of your FOV, but it always helps to confirm if anything is happening by having your textured surface(s) translated to the origin of all axes.

Regards,
Mathematix.

Share this post


Link to post
Share on other sites