本文整理汇总了C++中LOG::OutputError方法的典型用法代码示例。如果您正苦于以下问题:C++ LOG::OutputError方法的具体用法?C++ LOG::OutputError怎么用?C++ LOG::OutputError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LOG
的用法示例。
在下文中一共展示了LOG::OutputError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Shutdown
void WINDOW::Shutdown(void) //PROPERLY KILL WINDOW
{
//Delete font display lists
glDeleteLists(base, 96);
if (fullscreen)
{
ChangeDisplaySettings(NULL, 0); //restore desktop mode
ShowCursor(TRUE); //show mouse cursor
}
errorLog.OutputNewline();
if(hRC) //have a rendering context?
{
if(!wglMakeCurrent(NULL, NULL)) //try to release rend cont
{
errorLog.OutputError("Release of DC and RC Failed.");
}
else
errorLog.OutputSuccess("DC and RC released.");
if(!wglDeleteContext(hRC)) //try to delete RC
{
errorLog.OutputError("Release Rendering Context Failed.");
}
else
errorLog.OutputSuccess("Rendering Context Released.");
hRC=NULL; //set RC to NULL
}
if(hDC && !ReleaseDC(hWnd, hDC)) //Are we able to release DC?
{
errorLog.OutputError("Release of Device Context Failed.");
hDC=NULL;
}
else
errorLog.OutputSuccess("Device Context Released.");
if(hWnd && !DestroyWindow(hWnd)) //Can we destroy window?
{
errorLog.OutputError("Could not release hWnd");
hWnd=NULL;
}
else
errorLog.OutputSuccess("hWnd released.");
if (!UnregisterClass("OpenGL", hInstance)) //can we unreg. class?
{
errorLog.OutputError("Could Not Unregister Class.");
hInstance=NULL;
}
else
errorLog.OutputSuccess("Class unregistered.");
}
示例2: LoadVertices
///////////////////BSP::LoadVertices////////
////////////////////////////////////////////
bool BSP::LoadVertices(FILE * file)
{
//calculate number of vertices
numVertices=header.directoryEntries[bspVertices].length/sizeof(BSP_LOAD_VERTEX);
//Create space for this many BSP_LOAD_VERTICES
BSP_LOAD_VERTEX * loadVertices=new BSP_LOAD_VERTEX[numVertices];
if(!loadVertices)
{
errorLog.OutputError("Unable to allocate memory for %d BSP_LOAD_VERTEXes", numVertices);
return false;
}
//go to vertices in file
fseek(file, header.directoryEntries[bspVertices].offset, SEEK_SET);
//read in the vertices
fread(loadVertices, header.directoryEntries[bspVertices].length, 1, file);
//Convert to BSP_VERTEXes
vertices=new BSP_VERTEX[numVertices];
if(!vertices)
{
errorLog.OutputError("Unable to allocate memory for vertices");
return false;
}
for(int i=0; i<numVertices; ++i)
{
//swap y and z and negate z
vertices[i].position.x=loadVertices[i].position.x;
vertices[i].position.y=loadVertices[i].position.z;
vertices[i].position.z=-loadVertices[i].position.y;
//scale down
vertices[i].position/=64;
//Transfer texture coordinates (Invert t)
vertices[i].decalS=loadVertices[i].decalS;
vertices[i].decalT=-loadVertices[i].decalT;
//Transfer lightmap coordinates
vertices[i].lightmapS=loadVertices[i].lightmapS;
vertices[i].lightmapT=loadVertices[i].lightmapT;
}
if(loadVertices)
delete [] loadVertices;
loadVertices=NULL;
return true;
}
示例3: DemoInit
//Set up variables
bool DemoInit()
{
if(!window.Init("Project Template", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
return 0; //quit if not created
SetUpARB_multitexture();
SetUpEXT_texture3D();
SetUpEXT_texture_edge_clamp();
SetUpNV_register_combiners();
SetUpNV_texture_shader();
SetUpNV_vertex_program();
if( !EXT_texture_edge_clamp_supported || !ARB_multitexture_supported ||
!NV_vertex_program_supported || !NV_register_combiners_supported)
return false;
//Check we have at least 3 texture units
GLint maxTextureUnitsARB;
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnitsARB);
if(maxTextureUnitsARB<3)
{
errorLog.OutputError("I require at least 3 texture units");
return false;
}
//Set light colors
lightColors[0].Set(1.0f, 1.0f, 1.0f, 1.0f);
lightColors[1].Set((float)47/255, (float)206/255, (float)240/255, 1.0f);
lightColors[2].Set((float)254/255, (float)48/255, (float)18/255, 1.0f);
lightColors[3].Set((float)83/255, (float)243/255, (float)29/255, 1.0f);
//Load textures
//Decal image
decalImage.Load("decal.tga");
glGenTextures(1, &decalTexture);
glBindTexture(GL_TEXTURE_2D, decalTexture);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
//Create light textures
if(!InitLightTextures( atten1DTexture, atten2DTexture, atten3DTexture,
gaussian1DTexture, gaussian2DTexture))
return false;
camera.Init(VECTOR3D(0.0f, 0.0f, 3.5f));
//reset timer for start
timer.Reset();
return true;
}
示例4: Load
//Load - load a texture from a file
bool IMAGE::Load(char * filename)
{
//Clear the data if already used
if(data)
delete [] data;
data=NULL;
bpp=0;
width=0;
height=0;
format=0;
int filenameLength=strlen(filename);
if( strncmp((filename+filenameLength-3), "BMP", 3)==0 ||
strncmp((filename+filenameLength-3), "bmp", 3)==0)
return LoadBMP(filename);
if( strncmp((filename+filenameLength-3), "PCX", 3)==0 ||
strncmp((filename+filenameLength-3), "pcx", 3)==0)
return LoadPCX(filename);
if( strncmp((filename+filenameLength-3), "TGA", 3)==0 ||
strncmp((filename+filenameLength-3), "tga", 3)==0)
return LoadTGA(filename);
errorLog.OutputError("%s does not end in \".tga\", \".bmp\" or \"pcx\"", filename);
return false;
}
示例5: MakeCurrent
bool PBUFFER::MakeCurrent()
{
if(!wglMakeCurrent(hDC, hRC))
{
errorLog.OutputError("Unable to change current context");
return false;
}
return true;
}
示例6: LoadTGA
//Load a TGA texture
bool IMAGE::LoadTGA(char * filename)
{
unsigned char UncompressedTGAHeader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char CompressedTGAHeader[12]={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char Uncompressed8BitTGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
unsigned char TGAcompare[12]; //Used to compare TGA header
FILE * file = fopen(filename, "rb"); //Open the TGA file
if( file==NULL ) //Does the file exist?
{
errorLog.OutputError("%s does not exist", filename);
return false;
}
//read the header
fread(TGAcompare, 1, sizeof(TGAcompare), file);
fclose(file);
if(memcmp(UncompressedTGAHeader, TGAcompare, sizeof(UncompressedTGAHeader))==0)
{
return LoadUncompressedTrueColorTGA(filename);
}
else if(memcmp(CompressedTGAHeader, TGAcompare, sizeof(CompressedTGAHeader))==0)
{
return LoadCompressedTrueColorTGA(filename);
}
else if(memcmp(Uncompressed8BitTGAHeader, TGAcompare, sizeof(Uncompressed8BitTGAHeader))==0)
{
return LoadUncompressed8BitTGA(filename);
}
else
{
errorLog.OutputError("%s is not a recognised type of TGA", filename);
return false;
}
return false;
}
示例7: LoadBMP
bool IMAGE::LoadBMP(char * filename)
{
FILE * file; //the texture file
BITMAPFILEHEADER fileHeader; //bitmap file header
BITMAPINFOHEADER infoHeader; //bitmap info header
//open file for reading
file=fopen(filename, "rb");
if(file==NULL)
{
errorLog.OutputError("Unable to open %s", filename);
return false;
}
//read the file header
fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
//check it's a bitmap
if(fileHeader.bfType != BITMAP_ID)
{
fclose(file);
errorLog.OutputError("%s is not a legal .BMP", filename);
return false;
}
//read in the information header
fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
//close the file
fclose(file);
//discover the bpp
if(infoHeader.biBitCount==24)
return Load24BitBMP(filename);
if(infoHeader.biBitCount==8)
return Load8BitBMP(filename);
errorLog.OutputError("%s has an unknown bpp", filename);
return false;
}
示例8: WinMain
//ENTRY POINT FOR APPLICATION
//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
int WINAPI WinMain( HINSTANCE hInstance, //instance
HINSTANCE hPrevInstance, //Previous Instance
LPSTR lpCmdLine, //command line parameters
int nCmdShow) //Window show state
{
//Initiation
errorLog.Init("Error Log.txt");
//init variables etc, then GL
if(!DemoInit())
{
errorLog.OutputError("Demo Initiation failed");
return 0;
}
else
errorLog.OutputSuccess("Demo Initiation Successful");
if(!GLInit())
{
errorLog.OutputError("OpenGL Initiation failed");
return 0;
}
else
errorLog.OutputSuccess("OpenGL Initiation Successful");
//Main Loop
for(;;)
{
if(!(window.HandleMessages())) break;//handle windows messages, quit if returns false
UpdateFrame();
RenderFrame();
}
DemoShutdown();
errorLog.OutputSuccess("Exiting...");
return (window.msg.wParam); //Exit The Program
}
示例9: Shutdown
void PBUFFER::Shutdown(void)
{
if(hRC) //have a rendering context?
{
if(!wglDeleteContext(hRC)) //try to delete RC
{
errorLog.OutputError("Release of Pbuffer Rendering Context Failed.");
}
hRC=NULL; //set RC to NULL
}
if(hDC && !wglReleasePbufferDCARB(hBuffer, hDC)) //Are we able to release DC?
{
errorLog.OutputError("Release of Pbuffer Device Context Failed.");
hDC=NULL;
}
if(!wglDestroyPbufferARB(hBuffer))
{
errorLog.OutputError("Unable to destroy pbuffer");
}
}
示例10: LoadNV_vertex_program
bool LoadNV_vertex_program(char * filename, GLuint programID)
{
//load from file
std::ifstream vpFile(filename, std::ios::in | std::ios::binary);
if(vpFile.fail())
{
printf("Unable to open vertex program\n");
return false;
}
//calculate the size of the file
vpFile.seekg(0, std::ios::end);
int vpSize=vpFile.tellg();
vpFile.seekg(0, std::ios::beg);
//allocate memory
unsigned char * vpText=new unsigned char[vpSize];
if(!vpText)
{
printf("Unable to allocate space for vertex program text\n");
return false;
}
//read file
vpFile.read(reinterpret_cast<char *>(vpText), vpSize);
vpFile.close();
//load program
glLoadProgramNV(GL_VERTEX_PROGRAM_NV, programID, vpSize, vpText);
if(vpText)
delete [] vpText;
vpText=NULL;
//Output if there was an error
int errorPos;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_NV, &errorPos);
if(errorPos!=-1)
{
errorLog.OutputError("Program error at position %d in %s\n", errorPos, filename);
return false;
}
else
errorLog.OutputSuccess("%s loaded correctly", filename);
return true;
}
示例11: SetUpEXT_texture_edge_clamp
bool SetUpEXT_texture_edge_clamp()
{
//Check for support
char * extensionString=(char *)glGetString(GL_EXTENSIONS);
char * extensionName="GL_EXT_texture_edge_clamp";
char * endOfString; //store pointer to end of string
unsigned int distanceToSpace; //distance to next space
endOfString=extensionString+strlen(extensionString);
//loop through string
while(extensionString<endOfString)
{
//find distance to next space
distanceToSpace=strcspn(extensionString, " ");
//see if we have found extensionName
if((strlen(extensionName)==distanceToSpace) &&
(strncmp(extensionName, extensionString, distanceToSpace)==0))
{
EXT_texture_edge_clamp_supported=true;
}
//if not, move on
extensionString+=distanceToSpace+1;
}
if(!EXT_texture_edge_clamp_supported)
{
errorLog.OutputError("EXT_texture_edge_clamp unsupported!");
return false;
}
errorLog.OutputSuccess("EXT_texture_edge_clamp supported!");
//get function pointers
//none specified
return true;
}
示例12: FlipVertically
void IMAGE::FlipVertically()
{
//dont flip zero or 1 height images
if(height==0 || height==1)
return;
int rowsToSwap=0;
//see how many rows to swap
if(height%2==1)
rowsToSwap=(height-1)/2;
else
rowsToSwap=height/2;
//create space for a temporary row
GLubyte * tempRow=new GLubyte[width*bpp/8];
if(!tempRow)
{
errorLog.OutputError("Unable to flip image, unable to create space for temporary row");
return;
}
//loop through rows to swap
for(int i=0; i<rowsToSwap; ++i)
{
//copy row i into temp
memcpy(tempRow, &data[i*width*bpp/8], width*bpp/8);
//copy row height-i-1 to row i
memcpy(&data[i*width*bpp/8], &data[(height-i-1)*width*bpp/8], width*bpp/8);
//copy temp into row height-i-1
memcpy(&data[(height-i-1)*width*bpp/8], tempRow, width*bpp/8);
}
//free tempRow
if(tempRow)
delete [] tempRow;
tempRow=NULL;
}
示例13: LoadAlphaTGA
//load in an 8 bit greyscale TGA as an alpha channel
bool IMAGE::LoadAlphaTGA(char * filename)
{
unsigned char TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
unsigned char TGAcompare[12]; //Used to compare TGA header
unsigned char header[6]; //First 6 useful bytes of the header
errorLog.OutputSuccess("Loading %s in LoadAlphaTGA()", filename);
if(!(format==GL_RGB || format==GL_RGBA))
{
errorLog.OutputError("Can only load an alpha channel to RGB / RGBA format images. %s caused error", filename);
return false;
}
FILE * file = fopen(filename, "rb"); //Open the TGA file
if(file == NULL) //Does the file exist?
{
errorLog.OutputError("%s does not exist.", filename);
return false;
}
if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
memcmp(TGAHeader, TGAcompare, sizeof(TGAHeader))!=0 || //Is the header correct?
fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
{
fclose(file); //If anything else failed, close the file
errorLog.OutputError("Could not load %s correctly, general failure.", filename);
return false;
}
//save data into class member variables
unsigned int alphaWidth= header[1]*256+header[0]; //determine the image width
unsigned int alphaHeight= header[3]*256+header[2]; //determine image height
int alphaBpp= header[4];
if( alphaWidth<=0 || //if width <=0
alphaHeight<=0 || //or height<=0
alphaBpp!=8) //bpp not 8
{
fclose(file); //close the file
errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 8 bpp.", filename);
return false;
}
//check it is the same size as the image
if(alphaWidth!=width || alphaHeight!=height)
{
errorLog.OutputError("%s is not the same size as the color texture", filename);
return false;
}
//make space for palette
unsigned char * palette=new unsigned char[256*3];
if(!palette)
{
errorLog.OutputError("Unable to allocate memory for palette");
return false;
}
//load the palette
fread(palette, 256*3, 1, file);
//we dont use the palette
delete [] palette;
palette=NULL;
//allocate space for alpha values
unsigned char * values=new unsigned char[width*height];
if(!values)
{
errorLog.OutputError("Unable to allocate memory for alpha values");
return false;
}
//load indices
fread(values, 1, alphaWidth*alphaHeight, file);
//close the file
fclose(file);
//now put in the alpha data
if(format==GL_RGBA)
{
for(unsigned int i=0; i<width*height; i++)
{
data[i*4+3]=values[i];
}
}
else if(format==GL_RGB)
{
unsigned char * tempData=new unsigned char[width*height*4];
if(!tempData)
{
errorLog.OutputError("Unable to allocate memory for Temporary Data");
return false;
}
for(unsigned int i=0; i<width*height; i++)
//.........这里部分代码省略.........
示例14: LoadCompressedTrueColorTGA
//load a compressed TGA texture (24 or 32 bpp)
bool IMAGE::LoadCompressedTrueColorTGA(char * filename)
{
unsigned char TGAheader[12]={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Compressed TGA header
unsigned char TGAcompare[12]; //Used to compare TGA header
unsigned char header[6]; //First 6 useful bytes of the header
unsigned int bytesPerPixel; //bytes per pixel
unsigned int imageSize; //Stores Image size when in RAM
errorLog.OutputSuccess("Loading %s in LoadCompressedTGA()", filename);
FILE * file = fopen(filename, "rb"); //Open the TGA file
if(file == NULL) //Does the file exist?
{
errorLog.OutputError("%s does not exist.", filename);
return false;
}
if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
memcmp(TGAheader, TGAcompare, sizeof(TGAheader))!=0 || //Is the header correct?
fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
{
fclose(file); //If anything else failed, close the file
errorLog.OutputError("Could not load %s correctly, general failure.", filename);
return false;
}
//save data into class member variables
width= header[1]*256+header[0]; //determine the image width
height= header[3]*256+header[2]; //determine image height
bpp= header[4];
if( width<=0 || //if width <=0
height<=0 || //or height<=0
bpp!=24 && bpp!=32) //bpp not 24 or 32
{
fclose(file); //close the file
errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 24 or 32 bpp.", filename);
return false;
}
//set format
if(bpp == 24)
format=GL_RGB;
else
format=GL_RGBA;
bytesPerPixel=bpp/8; //calc bytes per pixel
imageSize=width*height*bytesPerPixel; //calc memory required
data=new unsigned char[imageSize]; //reserve the memory for the data
if(!data) //Does the storage memory exist?
{
errorLog.OutputError("Unable to allocate memory for %s image", filename);
fclose(file);
return false;
}
//read in the image data
int pixelCount = height*width;
int currentPixel= 0;
int currentByte = 0;
unsigned char * colorBuffer=new unsigned char[bytesPerPixel];
do
{
unsigned char chunkHeader=0;
if(fread(&chunkHeader, sizeof(unsigned char), 1, file) == 0)
{
errorLog.OutputError("Could not read RLE chunk header");
if(file)
fclose(file);
if(data)
delete [] data;
return false;
}
if(chunkHeader<128) //Read raw color values
{
chunkHeader++;
for(short counter=0; counter<chunkHeader; counter++)
{
if(fread(colorBuffer, 1, bytesPerPixel, file) != bytesPerPixel)
{
errorLog.OutputError("Unable to read %s image data", filename);
if(file)
fclose(file);
if(colorBuffer)
delete [] colorBuffer;
if(data)
delete [] data;
return false;
}
//.........这里部分代码省略.........
示例15: LoadUncompressedTrueColorTGA
//load an uncompressed TGA texture (24 or 32 bpp)
bool IMAGE::LoadUncompressedTrueColorTGA(char * filename)
{
unsigned char TGAheader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //Uncompressed TGA header
unsigned char TGAcompare[12]; //Used to compare TGA header
unsigned char header[6]; //First 6 useful bytes of the header
unsigned int bytesPerPixel; //bytes per pixel
unsigned int imageSize; //Stores Image size when in RAM
errorLog.OutputSuccess("Loading %s in LoadUncompressedTGA()", filename);
FILE * file = fopen(filename, "rb"); //Open the TGA file
if(file == NULL) //Does the file exist?
{
errorLog.OutputError("%s does not exist.", filename);
return false;
}
if( fread(TGAcompare, 1, sizeof(TGAcompare), file)!=sizeof(TGAcompare)|| //Are there 12 bytes to read?
memcmp(TGAheader, TGAcompare, sizeof(TGAheader))!=0 || //Is the header correct?
fread(header, 1, sizeof(header), file)!=sizeof(header)) //Read next 6 bytes
{
fclose(file); //If anything else failed, close the file
errorLog.OutputError("Could not load %s correctly, general failure.", filename);
return false;
}
//save data into class member variables
width= header[1]*256+header[0]; //determine the image width
height= header[3]*256+header[2]; //determine image height
bpp= header[4];
if( width<=0 || //if width <=0
height<=0 || //or height<=0
bpp!=24 && bpp!=32) //bpp not 24 or 32
{
fclose(file); //close the file
errorLog.OutputError("%s's height or width is less than zero, or the TGA is not 24 or 32 bpp.", filename);
return false;
}
//set format
if(bpp == 24)
format=GL_RGB;
else
format=GL_RGBA;
bytesPerPixel=bpp/8; //calc bytes per pixel
imageSize=width*height*bytesPerPixel; //calc memory required
data=new unsigned char[imageSize]; //reserve the memory for the data
if( data==NULL) //Does the storage memory exist?
{
errorLog.OutputError("Unable to allocate memory for %s image", filename);
fclose(file);
return false;
}
//read in the image data
if(fread(data, 1, imageSize, file)!=imageSize) //Does the image size match the required?
{ //If not
if(data) //If data loaded
delete [] data; //free memory
errorLog.OutputError("Could not read %s image data", filename);
fclose(file); //close file
return false;
}
fclose(file);
//data is in BGR format
//swap b and r
for(int i=0; i<(int)imageSize; i+=bytesPerPixel)
{
//repeated XOR to swap bytes 0 and 2
data[i] ^= data[i+2] ^= data[i] ^= data[i+2];
}
errorLog.OutputSuccess("Loaded %s correctly.", filename);
return true;
}