Home » U++ Library support » U++ Library : Other (not classified elsewhere) » opengl & tekstures
opengl & tekstures [message #1853] |
Thu, 23 March 2006 13:21  |
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
help me please - what i'm dooing wrong????
|
|
|
 |
|
opengl & tekstures
By: barpas on Thu, 23 March 2006 13:21
|
 |
|
Re: opengl & tekstures
By: unodgs on Fri, 24 March 2006 08:45
|
 |
|
Re: opengl & tekstures
By: fudadmin on Fri, 24 March 2006 22:53
|
 |
|
Re: opengl & tekstures
By: fudadmin on Fri, 24 March 2006 23:01
|
 |
|
Re: opengl & tekstures
By: mirek on Fri, 24 March 2006 23:19
|
 |
|
Re: opengl & tekstures
By: barpas on Sat, 25 March 2006 01:22
|
 |
|
Re: opengl & tekstures
|
 |
|
Re: opengl & tekstures
By: barpas on Wed, 12 April 2006 16:36
|
 |
|
Re: opengl & tekstures
By: fudadmin on Wed, 12 April 2006 16:55
|
 |
|
Re: opengl & tekstures
By: fudadmin on Wed, 12 April 2006 17:02
|
 |
|
Re: opengl & tekstures
|
 |
|
Re: opengl & tekstures
By: mirek on Mon, 01 May 2006 10:07
|
 |
|
Re: opengl & tekstures
|
Goto Forum:
Current Time: Tue Apr 29 22:20:19 CEST 2025
Total time taken to generate the page: 0.01072 seconds
|