Commit 9136b843 authored by hybrid's avatar hybrid

Fix missing free on error. Reindentation.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1712 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0831ad93
...@@ -49,6 +49,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, ...@@ -49,6 +49,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize,
bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
HWND window, u32 bits, bool vsync, bool stencilBuffer) HWND window, u32 bits, bool vsync, bool stencilBuffer)
{ {
// Set up ixel format descriptor with desired parameters
PIXELFORMATDESCRIPTOR pfd = { PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number 1, // Version Number
...@@ -70,6 +71,8 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -70,6 +71,8 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
0, 0, 0 // Layer Masks Ignored 0, 0, 0 // Layer Masks Ignored
}; };
GLuint PixelFormat;
// get hdc // get hdc
if (!(HDc=GetDC(window))) if (!(HDc=GetDC(window)))
{ {
...@@ -77,8 +80,6 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -77,8 +80,6 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
return false; return false;
} }
GLuint PixelFormat;
for (u32 i=0; i<5; ++i) for (u32 i=0; i<5; ++i)
{ {
if (i == 1) if (i == 1)
...@@ -116,45 +117,46 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -116,45 +117,46 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
break; break;
else else
os::Printer::log("Cannot find a suitable pixelformat.", ELL_ERROR); os::Printer::log("Cannot find a suitable pixelformat.", ELL_ERROR);
} }
// set pixel format // set pixel format
if(!SetPixelFormat(HDc, PixelFormat, &pfd)) if(!SetPixelFormat(HDc, PixelFormat, &pfd))
{ {
os::Printer::log("Cannot set the pixel format.", ELL_ERROR); os::Printer::log("Cannot set the pixel format.", ELL_ERROR);
return false; return false;
} }
// create rendering context // create rendering context
if (!(HRc=wglCreateContext(HDc))) if (!(HRc=wglCreateContext(HDc)))
{ {
os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR); os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR);
return false; return false;
} }
// activate rendering context // activate rendering context
if(!wglMakeCurrent(HDc, HRc)) if(!wglMakeCurrent(HDc, HRc))
{ {
os::Printer::log("Cannot activate GL rendering context", ELL_ERROR); os::Printer::log("Cannot activate GL rendering context", ELL_ERROR);
wglDeleteContext(HRc);
return false; return false;
} }
int pf = GetPixelFormat(HDc); int pf = GetPixelFormat(HDc);
DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd); DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.cAlphaBits != 0) if (pfd.cAlphaBits != 0)
{ {
if (pfd.cRedBits == 8) if (pfd.cRedBits == 8)
ColorFormat = ECF_A8R8G8B8; ColorFormat = ECF_A8R8G8B8;
else
ColorFormat = ECF_A1R5G5B5;
}
else else
{ ColorFormat = ECF_A1R5G5B5;
if (pfd.cRedBits == 8) }
ColorFormat = ECF_R8G8B8; else
else {
ColorFormat = ECF_R5G6B5; if (pfd.cRedBits == 8)
} ColorFormat = ECF_R8G8B8;
else
ColorFormat = ECF_R5G6B5;
}
genericDriverInit(screenSize, stencilBuffer); genericDriverInit(screenSize, stencilBuffer);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#if defined(_IRR_WINDOWS_API_) #if defined(_IRR_WINDOWS_API_)
#include <GL/gl.h> #include <GL/gl.h>
#include "glext.h" #include "glext.h"
#include "wglext.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "OpenGL32.lib") #pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "GLu32.lib") #pragma comment(lib, "GLu32.lib")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment