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,
bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
HWND window, u32 bits, bool vsync, bool stencilBuffer)
{
// Set up ixel format descriptor with desired parameters
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
......@@ -70,6 +71,8 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
0, 0, 0 // Layer Masks Ignored
};
GLuint PixelFormat;
// get hdc
if (!(HDc=GetDC(window)))
{
......@@ -77,8 +80,6 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
return false;
}
GLuint PixelFormat;
for (u32 i=0; i<5; ++i)
{
if (i == 1)
......@@ -116,45 +117,46 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
break;
else
os::Printer::log("Cannot find a suitable pixelformat.", ELL_ERROR);
}
}
// set pixel format
if(!SetPixelFormat(HDc, PixelFormat, &pfd))
{
os::Printer::log("Cannot set the pixel format.", ELL_ERROR);
// set pixel format
if(!SetPixelFormat(HDc, PixelFormat, &pfd))
{
os::Printer::log("Cannot set the pixel format.", ELL_ERROR);
return false;
}
}
// create rendering context
if (!(HRc=wglCreateContext(HDc)))
{
os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR);
// create rendering context
if (!(HRc=wglCreateContext(HDc)))
{
os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR);
return false;
}
}
// activate rendering context
if(!wglMakeCurrent(HDc, HRc))
{
os::Printer::log("Cannot activate GL rendering context", ELL_ERROR);
// activate rendering context
if(!wglMakeCurrent(HDc, HRc))
{
os::Printer::log("Cannot activate GL rendering context", ELL_ERROR);
wglDeleteContext(HRc);
return false;
}
}
int pf = GetPixelFormat(HDc);
DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.cAlphaBits != 0)
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_A8R8G8B8;
else
ColorFormat = ECF_A1R5G5B5;
}
int pf = GetPixelFormat(HDc);
DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.cAlphaBits != 0)
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_A8R8G8B8;
else
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_R8G8B8;
else
ColorFormat = ECF_R5G6B5;
}
ColorFormat = ECF_A1R5G5B5;
}
else
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_R8G8B8;
else
ColorFormat = ECF_R5G6B5;
}
genericDriverInit(screenSize, stencilBuffer);
......
......@@ -25,6 +25,7 @@
#if defined(_IRR_WINDOWS_API_)
#include <GL/gl.h>
#include "glext.h"
#include "wglext.h"
#ifdef _MSC_VER
#pragma comment(lib, "OpenGL32.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