many changes and refactoring

This commit is contained in:
Eduardo Bart
2011-07-13 18:12:36 -03:00
parent 6c05ee0e82
commit 8ef1b28546
120 changed files with 1545 additions and 1273 deletions

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <core/platform.h>
#include <core/engine.h>
@@ -211,7 +211,7 @@ void Platform::init(const char *appName)
wc.lpszClassName = win32.appName.c_str(); // Set The Class Name
if(!RegisterClassA(&wc))
logFatal("FATAL ERROR: Failed to register the window class.");
fatal("FATAL ERROR: Failed to register the window class.");
// force first tick
Platform::getTicks();
@@ -226,7 +226,7 @@ void Platform::terminate()
if(win32.instance) {
if(!UnregisterClassA(win32.appName.c_str(), win32.instance))
logError("ERROR: Unregister class failed.");
error("ERROR: Unregister class failed.");
win32.instance = NULL;
}
@@ -286,7 +286,7 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
if(!win32.window) {
terminate();
logFatal("FATAL ERROR: Window creation error.");
fatal("FATAL ERROR: Window creation error.");
return false;
}
@@ -315,31 +315,31 @@ bool Platform::createWindow(int x, int y, int width, int height, int minWidth, i
if(!(win32.hdc = GetDC(win32.window))) {
terminate();
logFatal("FATAL ERROR: Can't Create A GL Device Context.");
fatal("FATAL ERROR: Can't Create A GL Device Context.");
return false;
}
if(!(pixelFormat = ChoosePixelFormat(win32.hdc, &pfd))) {
terminate();
logFatal("FATAL ERROR: Can't Find A Suitable PixelFormat.");
fatal("FATAL ERROR: Can't Find A Suitable PixelFormat.");
return false;
}
if(!SetPixelFormat(win32.hdc, pixelFormat, &pfd)) {
terminate();
logFatal("FATAL ERROR: Can't Set The PixelFormat.");
fatal("FATAL ERROR: Can't Set The PixelFormat.");
return false;
}
if(!(win32.hrc = wglCreateContext(win32.hdc))) {
terminate();
logFatal("FATAL ERROR: Can't Create A GL Rendering Context.");
fatal("FATAL ERROR: Can't Create A GL Rendering Context.");
return false;
}
if(!wglMakeCurrent(win32.hdc, win32.hrc)) {
terminate();
logFatal("FATAL ERROR: Can't Activate The GL Rendering Context.");
fatal("FATAL ERROR: Can't Activate The GL Rendering Context.");
return false;
}
@@ -350,24 +350,24 @@ void Platform::destroyWindow()
{
if(win32.hrc) {
if(!wglMakeCurrent(NULL, NULL))
logError("ERROR: Release Of DC And RC Failed.");
error("ERROR: Release Of DC And RC Failed.");
if(!wglDeleteContext(win32.hrc))
logError("ERROR: Release Rendering Context Failed.");
error("ERROR: Release Rendering Context Failed.");
win32.hrc = NULL;
}
if(win32.hdc) {
if(!ReleaseDC(win32.window, win32.hdc))
logError("ERROR: Release Device Context Failed.");
error("ERROR: Release Device Context Failed.");
win32.hdc = NULL;
}
if(win32.window) {
if(!DestroyWindow(win32.window))
logError("ERROR: Destroy window failed.");
error("ERROR: Destroy window failed.");
win32.window = NULL;
}
@@ -502,7 +502,7 @@ std::string Platform::getAppUserDir()
std::stringstream sdir;
sdir << PHYSFS_getUserDir() << "/." << win32.appName << "/";
if((mkdir(sdir.str().c_str()) != 0) && (errno != EEXIST))
flogError("ERROR: Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
ferror("ERROR: Couldn't create directory for saving configuration file. (%s)", sdir.str().c_str());
return sdir.str();
}