Substituting glaux on lesson6 by IPicture or glaux replacement
I arrived in lesson 6 where glaux is needed to load a bitmap, and I think that Dev C++ don''t have a necessary lib to use the glaux reader, so I am thinking on putting the Nehe''s glaux replacement code in the lesson 6, or perhaps the IPicture code in place of glaux. My question is: In what place of the code I should put glaux replacement code or IPicture code? Or greater changes are needed?
Thanks for any help.
NeHe has replacement code for glaux. Go to the his main index page, on the left side there will be links with titles eg: NeHe, OpenGL Tutorials, More Tutorials, Articles, NeHe Misc, and so on. Under NeHe Misc you will find a link called Glaux Replacement which should accomplish what you need.
If you still need glaux to run other apps or somewhat then here is a link: glaux
Scroll a little ways down and you will find it.
If you need the library I can e-mail it to you.
Hope that helps.
If you still need glaux to run other apps or somewhat then here is a link: glaux
Scroll a little ways down and you will find it.
If you need the library I can e-mail it to you.
Hope that helps.
Yeah, I know that, but I don't know where in lesson 6 I should put the glaux's replacement code to compile the lesson6, or if I have to do some alteration in the code of lesson6 besides put the glaux replacement code there
[edited by - tromak on December 31, 2003 11:40:32 PM]
[edited by - tromak on December 31, 2003 11:40:32 PM]
This should clear things up:
Declare prototype and definition of loading function:
Implementation, excerpt from tut 6 with obsolete code commented out
This is for 24-bit bitmaps only.
Declare prototype and definition of loading function:
bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) // Creates Texture From A Bitmap File{ HBITMAP hBMP; // Handle Of The Bitmap BITMAP BMP; // Bitmap Structure glGenTextures(1, &texid); // Create The Texture hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE ); if (!hBMP) // Does The Bitmap Exist? return FALSE; // If Not Return False GetObject(hBMP, sizeof(BMP), &BMP); // Get The Object // hBMP: Handle To Graphics Object // sizeof(BMP): Size Of Buffer For Object Information // &BMP: Buffer For Object Information glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // Pixel Storage Mode (Word Alignment / 4 Bytes) // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits); DeleteObject(hBMP); // Delete The Object return TRUE; // Loading Was Successful}
Implementation, excerpt from tut 6 with obsolete code commented out
.../*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[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 (NeHeLoadBitmap("Data/NeHe.bmp",texture[0])) { 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);*/ } else { Status=FALSE; } 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}...
This is for 24-bit bitmaps only.
I made the changes that you wrote, but it still generates many of the errors when I compile the code. I suppressed this part of the code that generated many of the errors and it was not in the code that you wrote previously:
BOOL Initialize (GL_Window* window, Keys* keys) // Any GL Init Code & User Initialiazation Goes Here
{
g_window = window;
g_keys = keys;
This way I eliminate some of the erros that appears on the compiling, but the following erros still appears:
D:\Arquivos Temporários\Werg\lesson6.cpp
[Warning] In function `bool NeHeLoadBitmap(TCHAR*, GLuint&)'':
53 D:\Arquivos Temporários\Werg\lesson6.cpp
`GL_BGR_EXT'' undeclared (first use this function)
(Each undeclared identifier is reported only once for each
lesson6.cpp D:\Arquivos Temporários\Werg\lesson6.cpp
At global scope:
63 D:\Arquivos Temporários\Werg\lesson6.cpp
parse error before `if''
D:\Arquivos Temporários\Werg\lesson6.cpp
[Warning] In function `int LoadGLTextures()'':
70 D:\Arquivos Temporários\Werg\lesson6.cpp
`TextureImage'' undeclared (first use this function)
D:\Arquivos Temporários\Werg\Makefile.win
[Build Error] [lesson6.o] Error 1
Here the code to help to discover the errors:
#include <stdlib.h>
#include <windows.h> // Header File For Windows
#include <stdio.h> // Header File For Standard Input/Output
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
GLfloat xrot; // X Rotation ( NEW )
GLfloat yrot; // Y Rotation ( NEW )
GLfloat zrot; // Z Rotation ( NEW )
GLuint texture[1]; // Storage For One Texture ( NEW )
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) // Creates Texture From A Bitmap File
{
HBITMAP hBMP; // Handle Of The Bitmap
BITMAP BMP; // Bitmap Structure
glGenTextures(1, &texid); // Create The Texture
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
if (!hBMP) // Does The Bitmap Exist?
return FALSE; // If Not Return False
GetObject(hBMP, sizeof(BMP), &BMP); // Get The Object
// hBMP: Handle To Graphics Object
// sizeof(BMP): Size Of Buffer For Object Information
// &BMP: Buffer For Object Information
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // Pixel Storage Mode (Word Alignment / 4 Bytes)
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
DeleteObject(hBMP); // Delete The Object
return TRUE; // Loading Was Successful
}
// Start Of User Initialization
if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0])) // Load The Bitmap
return FALSE;
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit
if (NeHeLoadBitmap("Data/NeHe.bmp",texture[0]))
{
Status=TRUE; // Set The Status To TRUE
}
else
{
Status=FALSE;
}
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
}
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0)
BOOL Initialize (GL_Window* window, Keys* keys) // Any GL Init Code & User Initialiazation Goes Here
{
g_window = window;
g_keys = keys;
This way I eliminate some of the erros that appears on the compiling, but the following erros still appears:
D:\Arquivos Temporários\Werg\lesson6.cpp
[Warning] In function `bool NeHeLoadBitmap(TCHAR*, GLuint&)'':
53 D:\Arquivos Temporários\Werg\lesson6.cpp
`GL_BGR_EXT'' undeclared (first use this function)
(Each undeclared identifier is reported only once for each
lesson6.cpp D:\Arquivos Temporários\Werg\lesson6.cpp
At global scope:
63 D:\Arquivos Temporários\Werg\lesson6.cpp
parse error before `if''
D:\Arquivos Temporários\Werg\lesson6.cpp
[Warning] In function `int LoadGLTextures()'':
70 D:\Arquivos Temporários\Werg\lesson6.cpp
`TextureImage'' undeclared (first use this function)
D:\Arquivos Temporários\Werg\Makefile.win
[Build Error] [lesson6.o] Error 1
Here the code to help to discover the errors:
#include <stdlib.h>
#include <windows.h> // Header File For Windows
#include <stdio.h> // Header File For Standard Input/Output
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
GLfloat xrot; // X Rotation ( NEW )
GLfloat yrot; // Y Rotation ( NEW )
GLfloat zrot; // Z Rotation ( NEW )
GLuint texture[1]; // Storage For One Texture ( NEW )
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
bool NeHeLoadBitmap(LPTSTR szFileName, GLuint &texid) // Creates Texture From A Bitmap File
{
HBITMAP hBMP; // Handle Of The Bitmap
BITMAP BMP; // Bitmap Structure
glGenTextures(1, &texid); // Create The Texture
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
if (!hBMP) // Does The Bitmap Exist?
return FALSE; // If Not Return False
GetObject(hBMP, sizeof(BMP), &BMP); // Get The Object
// hBMP: Handle To Graphics Object
// sizeof(BMP): Size Of Buffer For Object Information
// &BMP: Buffer For Object Information
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // Pixel Storage Mode (Word Alignment / 4 Bytes)
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Min Filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Mag Filter
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
DeleteObject(hBMP); // Delete The Object
return TRUE; // Loading Was Successful
}
// Start Of User Initialization
if (!NeHeLoadBitmap("Data/NeHe.bmp", texture[0])) // Load The Bitmap
return FALSE;
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit
if (NeHeLoadBitmap("Data/NeHe.bmp",texture[0]))
{
Status=TRUE; // Set The Status To TRUE
}
else
{
Status=FALSE;
}
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
}
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0)
Nehe''s lesson 33 teaches you how to load tga files, if you are interested you could take a look at that too.
I implemented the code like you said, and it compiles fine. But when I run the program all I get is a white cube. I''ve checked my TexCoords and they match those on tut 6.
I left out the TextureImage variable because the type was glaux dependent. Is there a new way to implement that?
I left out the TextureImage variable because the type was glaux dependent. Is there a new way to implement that?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement