Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » opengl & tekstures
opengl & tekstures [message #1853] Thu, 23 March 2006 13:21 Go to previous message
barpas is currently offline  barpas
Messages: 13
Registered: March 2006
Location: Poland
Promising Member
has anybody working upp code with opengl using textrue ???
i tray to do it many times eg with nehe tutorials but it's not working ...

eg. i tray convert to upp 6 lesson for neht tutorial - everything semms to by ok file is open textrure is done but qube is white (non textured)

i don't understend

i use functions likie that:

AUX_RGBImageRec* OpenGL::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 OpenGL::LoadGLTextures()									// Load Bitmaps And Convert To Textures
{
	int Status=FALSE;									// Status Indicator

	AUX_RGBImageRec *TextureImage[1];					// Create Storage Space For The Texture

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

	// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
	if (TextureImage[0]=LoadBMP("data/to.bmp"))
	{
		Status=TRUE;									// Set The Status To TRUE

		glGenTextures(1, &texture[0]);					// Create The Texture

		// Typical Texture Generation Using Data From The Bitmap
		glBindTexture(GL_TEXTURE_2D, texture[0]);
		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	}

	if (TextureImage[0])									// If Texture Exists
	{
		if (TextureImage[0]->data)							// If Texture Image Exists
		{
			free(TextureImage[0]->data);					// Free The Texture Image Memory
		}

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

	return Status;										// Return The Status
}





in GLPaint() metod:



void OpenGL::GLPaint()
{
	StdView();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();									// Reset The View
//	glRotatef(lookupdown,0.0f,0,0);
//glRotatef(sceneroty,0,1.0f,0);
glBindTexture(GL_TEXTURE_2D, texture[0]);
	glBegin(GL_QUADS);									// Draw A Quad
	//	glColor3f(0.0f,1.0f,0.0f);						// Set The Color To Green
	glNormal3f( 0.0f, 0.0f, 1.0f); 
		glTexCoord2f(1.0f, 0.0f);glVertex3f( szerokosc/2, -1.0f,-dlugosc/2);					// Top Right Of The Quad (Top)
		glTexCoord2f(1.0f, 0.0f);glVertex3f(-szerokosc/2, -1.0f,-dlugosc/2);					// Top Left Of The Quad (Top)
		glTexCoord2f(1.0f, 0.0f);glVertex3f(-szerokosc/2, -1.0f, dlugosc/2);					// Bottom Left Of The Quad (Top)
		glTexCoord2f(1.0f, 0.0f);glVertex3f( szerokosc/2, -1.0f, dlugosc/2);					// Bottom Right Of The Quad (Top)
...
	glEnd();
	
};



of course i use
#include <GL/glaux.h>


help me please - what i'm dooing wrong????


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: uvs wishes
Next Topic: namespace upp
Goto Forum:
  


Current Time: Mon May 13 13:26:00 CEST 2024

Total time taken to generate the page: 0.01949 seconds