Re: [Dev-C++] Strange compilation unit errors
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Scott S. <ssi...@sp...> - 2004-11-02 13:41:05
|
Here it is:
TGALOADER.H
#ifndef TGALOADER_H
#define TGALOADER_H
#include <gl/gl.h>
#include <string>
using std::string;
class TGAImage
{
public:
bool LoadTGA( TGAImage* texture, string filename, GLuint texType );
private:
GLubyte* imageData_;
GLuint bpp_;
GLuint width_;
GLuint height_;
GLuint texID_;
};
#endif
TGALOADER.CPP
#include "tgaloader.h"
#include <gl/gl.h>
#include <string>
#include <cstdio>
using std::string;
TGAImage::LoadTGA( TGAImage* texture, string filename, GLuint texType )
{
GLubyte tgaHeader[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
GLubyte imgHeader[12]; //The files header, to be compared with the
above header
GLubyte header[6]; //Width, height, and bpp info
GLuint bpp;
GLuint imageSize;
GLuint swap;
GLuint type = GL_RGBA;
FILE* image = fopen( filename.c_str(), "rb" );
if( NULL == image ||
fread( imgHeader, 1, sizeof(imgHeader), image ) !=
sizeof(imgHeader) ||
memcmp( tgaHeader, imgHeader, sizeof(tgaHeader) ) != 0 ||
fread( header, 1, sizeof(header), image ) != sizeof(header) )
{
if( NULL == image )
{
return false;
}
else
{
fclose( image );
return false;
}
}
texture->width_ = header[1] * 256 + header[0];
texture->height_ = header[3] * 256 + header[2];
if( texture->width_ <= 0 ||
texture->height <= 0 ||
( header[4] != 24 && header[4] != 32 ) )
{
fclose( image );
return false;
}
texture->bpp_ = header[4];
bpp = texture->bpp_ / 8; //Get the bytes per pixel from the bits
per pixel
imageSize = texture->width_ * texture->height_ * bpp;
texture->imageData_ = (GLubyte*)malloc( imageSize );
if( NULL == texture->imageData_ ||
fread( texture->imageData_, 1, imageSize, image ) != imageSize )
{
if( texture->imageData_ != NULL )
{
free( texture->imageData_ );
}
fclose( image );
return false;
}
for( int i = 0; i < int(imageSize); i+= bpp )
{
swap = texture->imageData_[i];
texture->imageData_[i] = texture->imageData_[i + 2];
texture->imageData_[i + 2] = swap;
}
fclose( image );
glGenTextures( 1, &texture[0]->texID_ );
glBindTexture( GL_TEXTURE_2D, &texture[0]->texID_ );
if( 0 == texType )
{
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST );
}
if( 1 == texType )
{
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
}
if( 24 == texture[0].bpp_ )
{
type = GL_RGB;
}
glTexImage2D( GL_TEXTURE_2D, 0, type, texture[0].width_,
texture[0]->height_, 0, GL_UNSIGNED_BYTE, texture[0]->imageData_ );
return true;
}
--Scott Simontis--
Per Westermark wrote:
> It is nice that you have posted your error messages. However, since we
> can't see your code, we can't say what you are doing wrong.
>
> /Per W
>
> On Mon, 1 Nov 2004, Scott Simontis wrote:
>
>
>>I am working on a TGA file loader for OpenGL. I keep getting lots of
>>errors. It looks like the header file for the TGA loader isn't being
>>seen, so the definition cannot be found. Does anyone know why it isn't
>>working? Its about 130 lines of code or so, and is at
>>http://home.comcast.net/~ageofscott/tgacode.zip
>>compilation errors are below:
>>
>>
>>Compiler: Default compiler
>>Building Makefile: "C:\Code\scifair\Makefile.win"
>>Executing make...
>>mingw32-make.exe -f "C:\Code\scifair\Makefile.win" all
>>g++.exe -c tgaloader.cpp -o tgaloader.o -I"C:/Dev-Cpp/include/c++/3.3.1"
>> -I"C:/Dev-Cpp/include/c++/3.3.1/mingw32"
>>-I"C:/Dev-Cpp/include/c++/3.3.1/backward"
>>-I"C:/Dev-Cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/Dev-Cpp/include"
>> -I"C:/Dev-Cpp/include/GL" -I"C:/Dev-Cpp/include/SDL"
>>-I"C:/Dev-Cpp/include/allegro" -I"C:/Dev-Cpp/allegro/include"
>>-I"C:/wx/include" -I"C:/Code"
>>
>>tgaloader.cpp:29: error: ISO C++ forbids declaration of `LoadTGA' with
>>no type
>>
>>tgaloader.cpp:29: error: prototype for `int TGAImage::LoadTGA(TGAImage*,
>>std::string, GLuint)' does not match any in class `TGAImage'
>>tgaloader.h:18: error: candidate is: bool TGAImage::LoadTGA(TGAImage*,
>>std::string, GLuint)
>>tgaloader.cpp:29: error: `int TGAImage::LoadTGA(TGAImage*, std::string,
>>GLuint)' and `bool TGAImage::LoadTGA(TGAImage*, std::string, GLuint)'
>>cannot be overloaded
>>
>>tgaloader.cpp: In member function `int TGAImage::LoadTGA(TGAImage*,
>>std::string, GLuint)':
>>tgaloader.cpp:60: error: 'class TGAImage' has no member named 'height'
>>tgaloader.cpp:91: error: base operand of `->' has non-pointer type
>>`TGAImage'
>>tgaloader.cpp:92: error: base operand of `->' has non-pointer type
>>`TGAImage'
>>tgaloader.cpp:111: error: base operand of `->' has non-pointer type
>>`TGAImage'
>>tgaloader.cpp:111: error: base operand of `->' has non-pointer type
>>`TGAImage'
>>
>>mingw32-make.exe: *** [tgaloader.o] Error 1
>>
>>Execution terminated
>>
>>Thanks in advanced for any help.
>>--
>>--Scott Simontis--
>>
>>
>>-------------------------------------------------------
>>This SF.Net email is sponsored by:
>>Sybase ASE Linux Express Edition - download now for FREE
>>LinuxWorld Reader's Choice Award Winner for best database on Linux.
>>http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
>>_______________________________________________
>>Dev-cpp-users mailing list
>>Dev...@li...
>>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>>
>
>
>
|