- Added external context managers with support for WGL and GLX.(this feature was available in ogl-es branch before)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5199 dfc29bdd-3216-0410-991c-e03cc46cb475
master
nadro 2015-11-29 20:12:51 +00:00
parent f9f665e603
commit 48bf4009c7
26 changed files with 1379 additions and 1031 deletions

50
include/IContextManager.h Normal file
View File

@ -0,0 +1,50 @@
// Copyright (C) 2013-2015 Patryk Nadrowski
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_I_CONTEXT_MANAGER_H_INCLUDED__
#define __IRR_I_CONTEXT_MANAGER_H_INCLUDED__
#include "SExposedVideoData.h"
#include "SIrrCreationParameters.h"
namespace irr
{
namespace video
{
class IContextManager : public virtual IReferenceCounted
{
public:
//! Initialize manager with device creation parameters and device window (passed as exposed video data)
virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) =0;
//! Terminate manager, any cleanup that is left over. Manager needs a new initialize to be usable again
virtual void terminate() =0;
//! Create surface based on current window set
virtual bool generateSurface() =0;
//! Destroy current surface
virtual void destroySurface() =0;
//! Create context based on current surface
virtual bool generateContext() =0;
//! Destroy current context
virtual void destroyContext() =0;
//! Get current context
virtual const SExposedVideoData& getContext() const =0;
//! Change render context, disable old and activate new defined by videoData
virtual bool activateContext(const SExposedVideoData& videoData) =0;
//! Swap buffers.
virtual bool swapBuffers() =0;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -172,6 +172,12 @@ define out. */
#ifdef NO_IRR_COMPILE_WITH_OPENGL_
#undef _IRR_COMPILE_WITH_OPENGL_
#endif
#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) && !defined(NO_IRR_COMPILE_WITH_WGL_MANAGER_)
#define _IRR_COMPILE_WITH_WGL_MANAGER_
#endif
#if defined(_IRR_COMPILE_WITH_OPENGL_) && defined(_IRR_COMPILE_WITH_X11_DEVICE_) && !defined(NO_IRR_COMPILE_WITH_GLX_MANAGER_)
#define _IRR_COMPILE_WITH_GLX_MANAGER_
#endif
//! Define _IRR_COMPILE_WITH_SOFTWARE_ to compile the Irrlicht engine with software driver
/** If you do not need the software driver, or want to use Burning's Video instead,

View File

@ -34,6 +34,10 @@ namespace irr
class ISceneManager;
} // end namespace scene
namespace video {
class IContextManager;
} // end namespace video
//! The Irrlicht device. You can create it with createDevice() or createDeviceEx().
/** This is the most important class of the Irrlicht Engine. You can
access everything in the engine if you have a pointer to an instance of
@ -115,6 +119,9 @@ namespace irr
by the gfx adapter. */
virtual video::IVideoModeList* getVideoModeList() = 0;
//! Get context manager
virtual video::IContextManager* getContextManager() = 0;
//! Provides access to the operation system operator object.
/** The OS operator provides methods for
getting system specific informations and doing system

View File

@ -64,6 +64,7 @@
#include "IBillboardTextSceneNode.h"
#include "IBoneSceneNode.h"
#include "ICameraSceneNode.h"
#include "IContextManager.h"
#include "ICursorControl.h"
#include "IDummyTransformationSceneNode.h"
#include "IDynamicMeshBuffer.h"

View File

@ -0,0 +1,424 @@
// Copyright (C) 2013 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "CGLXManager.h"
#ifdef _IRR_COMPILE_WITH_GLX_MANAGER_
#include "os.h"
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#define GL_GLEXT_LEGACY 1
#define GLX_GLXEXT_LEGACY 1
#else
#define GL_GLEXT_PROTOTYPES 1
#define GLX_GLXEXT_PROTOTYPES 1
#endif
#include <GL/gl.h>
#include <GL/glx.h>
#if defined(_IRR_OPENGL_USE_EXTPOINTER_)
#include "glext.h"
#undef GLX_ARB_get_proc_address // avoid problems with local glxext.h
#include "glxext.h"
#endif
namespace irr
{
namespace video
{
CGLXManager::CGLXManager(const SIrrlichtCreationParameters& params, const SExposedVideoData& videodata, int screennr)
: Params(params), PrimaryContext(videodata), VisualInfo(0), glxFBConfig(0), GlxWin(0)
{
#ifdef _DEBUG
setDebugName("CGLXManager");
#endif
CurrentContext.OpenGLLinux.X11Display=PrimaryContext.OpenGLLinux.X11Display;
int major, minor;
Display* display = (Display*)PrimaryContext.OpenGLLinux.X11Display;
const bool isAvailableGLX=glXQueryExtension(display,&major,&minor);
if (isAvailableGLX && glXQueryVersion(display, &major, &minor))
{
#if defined(GLX_VERSION_1_3)
typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXChooseFBConfig"));
#else
PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig=glXChooseFBConfig;
#endif
if (major==1 && minor>2 && glxChooseFBConfig)
{
os::Printer::log("GLX >= 1.3", ELL_DEBUG);
// attribute array for the draw buffer
int visualAttrBuffer[] =
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, Params.WithAlphaChannel?1:0,
GLX_DEPTH_SIZE, Params.ZBufferBits, //10,11
GLX_DOUBLEBUFFER, Params.Doublebuffer?True:False,
GLX_STENCIL_SIZE, Params.Stencilbuffer?1:0,
#if defined(GLX_VERSION_1_4) && defined(GLX_SAMPLE_BUFFERS) // we need to check the extension string!
GLX_SAMPLE_BUFFERS, 1,
GLX_SAMPLES, Params.AntiAlias, // 18,19
#elif defined(GLX_ARB_multisample)
GLX_SAMPLE_BUFFERS_ARB, 1,
GLX_SAMPLES_ARB, Params.AntiAlias, // 18,19
#elif defined(GLX_SGIS_multisample)
GLX_SAMPLE_BUFFERS_SGIS, 1,
GLX_SAMPLES_SGIS, Params.AntiAlias, // 18,19
#endif
//#ifdef GL_ARB_framebuffer_sRGB
// GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, Params.HandleSRGB,
//#elif defined(GL_EXT_framebuffer_sRGB)
// GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, Params.HandleSRGB,
//#endif
GLX_STEREO, Params.Stereobuffer?True:False,
None
};
GLXFBConfig *configList=0;
int nitems=0;
if (Params.AntiAlias<2)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
}
// first round with unchanged values
{
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (!configList && Params.AntiAlias)
{
while (!configList && (visualAttrBuffer[19]>1))
{
visualAttrBuffer[19] -= 1;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
}
if (!configList)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (configList)
{
os::Printer::log("No FSAA available.", ELL_WARNING);
Params.AntiAlias=0;
}
else
{
//reenable multisampling
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = Params.AntiAlias;
}
}
}
}
// Next try with flipped stencil buffer value
// If the first round was with stencil flag it's now without
// Other way round also makes sense because some configs
// only have depth buffer combined with stencil buffer
if (!configList)
{
if (Params.Stencilbuffer)
os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING);
Params.Stencilbuffer = !Params.Stencilbuffer;
visualAttrBuffer[15]=Params.Stencilbuffer?1:0;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (!configList && Params.AntiAlias)
{
while (!configList && (visualAttrBuffer[19]>1))
{
visualAttrBuffer[19] -= 1;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
}
if (!configList)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (configList)
{
os::Printer::log("No FSAA available.", ELL_WARNING);
Params.AntiAlias=0;
}
else
{
//reenable multisampling
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = Params.AntiAlias;
}
}
}
}
// Next try without double buffer
if (!configList && Params.Doublebuffer)
{
os::Printer::log("No doublebuffering available.", ELL_WARNING);
Params.Doublebuffer=false;
visualAttrBuffer[13] = GLX_DONT_CARE;
Params.Stencilbuffer = false;
visualAttrBuffer[15]=0;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (!configList && Params.AntiAlias)
{
while (!configList && (visualAttrBuffer[19]>1))
{
visualAttrBuffer[19] -= 1;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
}
if (!configList)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glxChooseFBConfig(display, screennr, visualAttrBuffer,&nitems);
if (configList)
{
os::Printer::log("No FSAA available.", ELL_WARNING);
Params.AntiAlias=0;
}
else
{
//reenable multisampling
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = Params.AntiAlias;
}
}
}
}
if (configList)
{
glxFBConfig=configList[0];
XFree(configList);
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
PFNGLXGETVISUALFROMFBCONFIGPROC glxGetVisualFromFBConfig= (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXGetVisualFromFBConfig"));
if (glxGetVisualFromFBConfig)
VisualInfo = glxGetVisualFromFBConfig(display,(GLXFBConfig)glxFBConfig);
#else
VisualInfo = glXGetVisualFromFBConfig(display,(GLXFBConfig)glxFBConfig);
#endif
}
}
else
#endif
{
// attribute array for the draw buffer
int visualAttrBuffer[] =
{
GLX_RGBA, GLX_USE_GL,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, Params.WithAlphaChannel?1:0,
GLX_DEPTH_SIZE, Params.ZBufferBits,
GLX_STENCIL_SIZE, Params.Stencilbuffer?1:0, // 12,13
// The following attributes have no flags, but are
// either present or not. As a no-op we use
// GLX_USE_GL, which is silently ignored by glXChooseVisual
Params.Doublebuffer?GLX_DOUBLEBUFFER:GLX_USE_GL, // 14
Params.Stereobuffer?GLX_STEREO:GLX_USE_GL, // 15
//#ifdef GL_ARB_framebuffer_sRGB
// Params.HandleSRGB?GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB:GLX_USE_GL,
//#elif defined(GL_EXT_framebuffer_sRGB)
// Params.HandleSRGB?GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT:GLX_USE_GL,
//#endif
None
};
VisualInfo=glXChooseVisual(display, screennr, visualAttrBuffer);
if (!VisualInfo)
{
if (Params.Stencilbuffer)
os::Printer::log("No stencilbuffer available, disabling.", ELL_WARNING);
Params.Stencilbuffer = !Params.Stencilbuffer;
visualAttrBuffer[13]=Params.Stencilbuffer?1:0;
VisualInfo=glXChooseVisual(display, screennr, visualAttrBuffer);
if (!VisualInfo && Params.Doublebuffer)
{
os::Printer::log("No doublebuffering available.", ELL_WARNING);
Params.Doublebuffer=false;
visualAttrBuffer[14] = GLX_USE_GL;
VisualInfo=glXChooseVisual(display, screennr, visualAttrBuffer);
}
}
}
}
else
os::Printer::log("No GLX support available. OpenGL driver will not work.", ELL_WARNING);
}
CGLXManager::~CGLXManager()
{
}
bool CGLXManager::initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& videodata)
{
// store params
Params=params;
// set display
CurrentContext.OpenGLLinux.X11Display=videodata.OpenGLLinux.X11Display;
// now get new window
CurrentContext.OpenGLLinux.X11Window=videodata.OpenGLLinux.X11Window;
if (!PrimaryContext.OpenGLLinux.X11Window)
{
PrimaryContext.OpenGLLinux.X11Window=CurrentContext.OpenGLLinux.X11Window;
}
return true;
}
void CGLXManager::terminate()
{
memset(&CurrentContext, 0, sizeof(CurrentContext));
}
bool CGLXManager::generateSurface()
{
if (glxFBConfig)
{
GlxWin=glXCreateWindow((Display*)CurrentContext.OpenGLLinux.X11Display,(GLXFBConfig)glxFBConfig,CurrentContext.OpenGLLinux.X11Window,NULL);
if (!GlxWin)
{
os::Printer::log("Could not create GLX window.", ELL_WARNING);
return false;
}
CurrentContext.OpenGLLinux.X11Window=GlxWin;
}
return true;
}
void CGLXManager::destroySurface()
{
if (GlxWin)
glXDestroyWindow((Display*)CurrentContext.OpenGLLinux.X11Display, GlxWin);
}
bool CGLXManager::generateContext()
{
GLXContext context;
if (glxFBConfig)
{
if (GlxWin)
{
// create glx context
context = glXCreateNewContext((Display*)CurrentContext.OpenGLLinux.X11Display, (GLXFBConfig)glxFBConfig, GLX_RGBA_TYPE, NULL, True);
if (!context)
{
os::Printer::log("Could not create GLX rendering context.", ELL_WARNING);
return false;
}
}
else
{
os::Printer::log("GLX window was not properly created.", ELL_WARNING);
return false;
}
}
else
{
context = glXCreateContext((Display*)CurrentContext.OpenGLLinux.X11Display, VisualInfo, NULL, True);
if (!context)
{
os::Printer::log("Could not create GLX rendering context.", ELL_WARNING);
return false;
}
}
CurrentContext.OpenGLLinux.X11Context=context;
return true;
}
const SExposedVideoData& CGLXManager::getContext() const
{
return CurrentContext;
}
bool CGLXManager::activateContext(const SExposedVideoData& videoData)
{
if (videoData.OpenGLLinux.X11Window)
{
if (videoData.OpenGLLinux.X11Display && videoData.OpenGLLinux.X11Context)
{
if (!glXMakeCurrent((Display*)videoData.OpenGLLinux.X11Display, videoData.OpenGLLinux.X11Window, (GLXContext)videoData.OpenGLLinux.X11Context))
{
os::Printer::log("Context activation failed.");
return false;
}
else
{
CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window;
CurrentContext.OpenGLLinux.X11Display = videoData.OpenGLLinux.X11Display;
}
}
else
{
// in case we only got a window ID, try with the existing values for display and context
if (!glXMakeCurrent((Display*)PrimaryContext.OpenGLLinux.X11Display, videoData.OpenGLLinux.X11Window, (GLXContext)PrimaryContext.OpenGLLinux.X11Context))
{
os::Printer::log("Context activation failed.");
return false;
}
else
{
CurrentContext.OpenGLLinux.X11Window = videoData.OpenGLLinux.X11Window;
CurrentContext.OpenGLLinux.X11Display = PrimaryContext.OpenGLLinux.X11Display;
}
}
}
// set back to main context
else if (CurrentContext.OpenGLLinux.X11Display != PrimaryContext.OpenGLLinux.X11Display)
{
if (!glXMakeCurrent((Display*)PrimaryContext.OpenGLLinux.X11Display, PrimaryContext.OpenGLLinux.X11Window, (GLXContext)PrimaryContext.OpenGLLinux.X11Context))
{
os::Printer::log("Context activation failed.");
return false;
}
else
{
CurrentContext = PrimaryContext;
}
}
return true;
}
void CGLXManager::destroyContext()
{
if (CurrentContext.OpenGLLinux.X11Context)
{
if (GlxWin)
{
if (!glXMakeContextCurrent((Display*)CurrentContext.OpenGLLinux.X11Display, None, None, NULL))
os::Printer::log("Could not release glx context.", ELL_WARNING);
}
else
{
if (!glXMakeCurrent((Display*)CurrentContext.OpenGLLinux.X11Display, None, NULL))
os::Printer::log("Could not release glx context.", ELL_WARNING);
}
glXDestroyContext((Display*)CurrentContext.OpenGLLinux.X11Display, (GLXContext)CurrentContext.OpenGLLinux.X11Context);
}
}
bool CGLXManager::swapBuffers()
{
glXSwapBuffers((Display*)CurrentContext.OpenGLLinux.X11Display, CurrentContext.OpenGLLinux.X11Window);
return true;
}
}
}
#endif

View File

@ -0,0 +1,80 @@
// Copyright (C) 2013 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#ifndef __C_GLX_MANAGER_H_INCLUDED__
#define __C_GLX_MANAGER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GLX_MANAGER_
#include "SIrrCreationParameters.h"
#include "SExposedVideoData.h"
#include "IContextManager.h"
#include "SColor.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
// we can't include glx.h here, because gl.h has incompatible types with ogl es headers and it
// cause redefinition errors, thats why we use ugly trick with void* types and casts.
namespace irr
{
namespace video
{
// GLX manager.
class CGLXManager : public IContextManager
{
public:
//! Constructor.
CGLXManager(const SIrrlichtCreationParameters& params, const SExposedVideoData& videodata, int screennr);
//! Destructor
~CGLXManager();
// Initialize
bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);
// Terminate
void terminate();
// Create surface.
bool generateSurface();
// Destroy surface.
void destroySurface();
// Create context.
bool generateContext();
// Destroy context.
void destroyContext();
//! Get current context
const SExposedVideoData& getContext() const;
//! Change render context, disable old and activate new defined by videoData
bool activateContext(const SExposedVideoData& videoData);
// Swap buffers.
bool swapBuffers();
XVisualInfo* getVisual() const {return VisualInfo;} // return XVisualInfo
private:
SIrrlichtCreationParameters Params;
SExposedVideoData PrimaryContext;
SExposedVideoData CurrentContext;
XVisualInfo* VisualInfo;
void* glxFBConfig; // GLXFBConfig
XID GlxWin; // GLXWindow
ECOLOR_FORMAT ColorFormat;
};
}
}
#endif
#endif

View File

@ -25,6 +25,10 @@
#include <X11/XKBlib.h>
#include <X11/Xatom.h>
#if defined(_IRR_COMPILE_WITH_OPENGL_)
#include "CGLXManager.h"
#endif
#ifdef _IRR_LINUX_XCURSOR_
#include <X11/Xcursor/Xcursor.h>
#endif
@ -53,8 +57,9 @@ namespace irr
{
namespace video
{
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceLinux* device);
#ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
#endif
}
} // end namespace irr
@ -402,235 +407,21 @@ bool CIrrDeviceLinux::createWindow()
switchToFullscreen();
#ifdef _IRR_COMPILE_WITH_OPENGL_
GLXFBConfig glxFBConfig;
int major, minor;
bool isAvailableGLX=false;
if (CreationParams.DriverType==video::EDT_OPENGL)
{
isAvailableGLX=glXQueryExtension(XDisplay,&major,&minor);
if (isAvailableGLX && glXQueryVersion(XDisplay, &major, &minor))
{
#ifdef GLX_VERSION_1_3
typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXChooseFBConfig"));
#else
PFNGLXCHOOSEFBCONFIGPROC glxChooseFBConfig=glXChooseFBConfig;
#endif
if (major==1 && minor>2 && glxChooseFBConfig)
{
// attribute array for the draw buffer
int visualAttrBuffer[] =
{
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0,
GLX_DEPTH_SIZE, CreationParams.ZBufferBits, //10,11
GLX_DOUBLEBUFFER, CreationParams.Doublebuffer?True:False,
GLX_STENCIL_SIZE, CreationParams.Stencilbuffer?1:0,
#if defined(GLX_VERSION_1_4) && defined(GLX_SAMPLE_BUFFERS) // we need to check the extension string!
GLX_SAMPLE_BUFFERS, 1,
GLX_SAMPLES, CreationParams.AntiAlias, // 18,19
#elif defined(GLX_ARB_multisample)
GLX_SAMPLE_BUFFERS_ARB, 1,
GLX_SAMPLES_ARB, CreationParams.AntiAlias, // 18,19
#elif defined(GLX_SGIS_multisample)
GLX_SAMPLE_BUFFERS_SGIS, 1,
GLX_SAMPLES_SGIS, CreationParams.AntiAlias, // 18,19
#endif
//#ifdef GL_ARB_framebuffer_sRGB
// GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, CreationParams.HandleSRGB,
//#elif defined(GL_EXT_framebuffer_sRGB)
// GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, CreationParams.HandleSRGB,
//#endif
GLX_STEREO, CreationParams.Stereobuffer?True:False,
None
};
GLXFBConfig *configList=0;
int nitems=0;
if (CreationParams.AntiAlias<2)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
}
// first round with unchanged values
{
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
if (!configList && CreationParams.AntiAlias)
{
while (!configList && (visualAttrBuffer[19]>1))
{
visualAttrBuffer[19] -= 1;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
}
if (!configList)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
if (configList)
{
os::Printer::log("No FSAA available.", ELL_WARNING);
CreationParams.AntiAlias=0;
}
else
{
//reenable multisampling
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = CreationParams.AntiAlias;
}
}
}
}
// Next try with flipped stencil buffer value
// If the first round was with stencil flag it's now without
// Other way round also makes sense because some configs
// only have depth buffer combined with stencil buffer
if (!configList)
{
if (CreationParams.Stencilbuffer)
os::Printer::log("No stencilbuffer available, disabling stencil shadows.", ELL_WARNING);
CreationParams.Stencilbuffer = !CreationParams.Stencilbuffer;
visualAttrBuffer[15]=CreationParams.Stencilbuffer?1:0;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
if (!configList && CreationParams.AntiAlias)
{
while (!configList && (visualAttrBuffer[19]>1))
{
visualAttrBuffer[19] -= 1;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
}
if (!configList)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
if (configList)
{
os::Printer::log("No FSAA available.", ELL_WARNING);
CreationParams.AntiAlias=0;
}
else
{
//reenable multisampling
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = CreationParams.AntiAlias;
}
}
}
}
// Next try without double buffer
if (!configList && CreationParams.Doublebuffer)
{
os::Printer::log("No doublebuffering available.", ELL_WARNING);
CreationParams.Doublebuffer=false;
visualAttrBuffer[13] = GLX_DONT_CARE;
CreationParams.Stencilbuffer = false;
visualAttrBuffer[15]=0;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
if (!configList && CreationParams.AntiAlias)
{
while (!configList && (visualAttrBuffer[19]>1))
{
visualAttrBuffer[19] -= 1;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
}
if (!configList)
{
visualAttrBuffer[17] = 0;
visualAttrBuffer[19] = 0;
configList=glxChooseFBConfig(XDisplay, Screennr, visualAttrBuffer,&nitems);
if (configList)
{
os::Printer::log("No FSAA available.", ELL_WARNING);
CreationParams.AntiAlias=0;
}
else
{
//reenable multisampling
visualAttrBuffer[17] = 1;
visualAttrBuffer[19] = CreationParams.AntiAlias;
}
}
}
}
if (configList)
{
glxFBConfig=configList[0];
XFree(configList);
UseGLXWindow=true;
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
PFNGLXGETVISUALFROMFBCONFIGPROC glxGetVisualFromFBConfig= (PFNGLXGETVISUALFROMFBCONFIGPROC)glXGetProcAddress(reinterpret_cast<const GLubyte*>("glXGetVisualFromFBConfig"));
if (glxGetVisualFromFBConfig)
VisualInfo = glxGetVisualFromFBConfig(XDisplay,glxFBConfig);
#else
VisualInfo = glXGetVisualFromFBConfig(XDisplay,glxFBConfig);
#endif
}
}
else
#endif
{
// attribute array for the draw buffer
int visualAttrBuffer[] =
{
GLX_RGBA, GLX_USE_GL,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_ALPHA_SIZE, CreationParams.WithAlphaChannel?1:0,
GLX_DEPTH_SIZE, CreationParams.ZBufferBits,
GLX_STENCIL_SIZE, CreationParams.Stencilbuffer?1:0, // 12,13
// The following attributes have no flags, but are
// either present or not. As a no-op we use
// GLX_USE_GL, which is silently ignored by glXChooseVisual
CreationParams.Doublebuffer?GLX_DOUBLEBUFFER:GLX_USE_GL, // 14
CreationParams.Stereobuffer?GLX_STEREO:GLX_USE_GL, // 15
//#ifdef GL_ARB_framebuffer_sRGB
// CreationParams.HandleSRGB?GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB:GLX_USE_GL,
//#elif defined(GL_EXT_framebuffer_sRGB)
// CreationParams.HandleSRGB?GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT:GLX_USE_GL,
//#endif
None
};
VisualInfo=glXChooseVisual(XDisplay, Screennr, visualAttrBuffer);
if (!VisualInfo)
{
if (CreationParams.Stencilbuffer)
os::Printer::log("No stencilbuffer available, disabling.", ELL_WARNING);
CreationParams.Stencilbuffer = !CreationParams.Stencilbuffer;
visualAttrBuffer[13]=CreationParams.Stencilbuffer?1:0;
VisualInfo=glXChooseVisual(XDisplay, Screennr, visualAttrBuffer);
if (!VisualInfo && CreationParams.Doublebuffer)
{
os::Printer::log("No doublebuffering available.", ELL_WARNING);
CreationParams.Doublebuffer=false;
visualAttrBuffer[14] = GLX_USE_GL;
VisualInfo=glXChooseVisual(XDisplay, Screennr, visualAttrBuffer);
}
}
}
}
else
os::Printer::log("No GLX support available. OpenGL driver will not work.", ELL_WARNING);
}
#if defined(_IRR_COMPILE_WITH_OPENGL_)
// don't use the XVisual with OpenGL, because it ignores all requested
// properties of the CreationParams
else if (!VisualInfo)
#endif // _IRR_COMPILE_WITH_OPENGL_
// create visual with standard X methods
if (CreationParams.DriverType == video::EDT_OPENGL)
{
video::SExposedVideoData data;
data.OpenGLLinux.X11Display = XDisplay;
ContextManager = new video::CGLXManager(CreationParams, data, Screennr);
VisualInfo = ((video::CGLXManager*)ContextManager)->getVisual();
}
#endif
if (!VisualInfo)
{
// create visual with standard X methods
os::Printer::log("Using plain X visual");
XVisualInfo visTempl; //Template to hold requested values
int visNumber; // Return value of available visuals
@ -737,56 +528,6 @@ bool CIrrDeviceLinux::createWindow()
// Currently broken in X, see Bug ID 2795321
// XkbSetDetectableAutoRepeat(XDisplay, True, &AutorepeatSupport);
#ifdef _IRR_COMPILE_WITH_OPENGL_
// connect glx context to window
Context=0;
if (isAvailableGLX && CreationParams.DriverType==video::EDT_OPENGL)
{
if (UseGLXWindow)
{
GlxWin=glXCreateWindow(XDisplay,glxFBConfig,XWindow,NULL);
if (GlxWin)
{
// create glx context
Context = glXCreateNewContext(XDisplay, glxFBConfig, GLX_RGBA_TYPE, NULL, True);
if (Context)
{
if (!glXMakeContextCurrent(XDisplay, GlxWin, GlxWin, Context))
{
os::Printer::log("Could not make context current.", ELL_WARNING);
glXDestroyContext(XDisplay, Context);
}
}
else
{
os::Printer::log("Could not create GLX rendering context.", ELL_WARNING);
}
}
else
{
os::Printer::log("Could not create GLX window.", ELL_WARNING);
}
}
else
{
Context = glXCreateContext(XDisplay, VisualInfo, NULL, True);
if (Context)
{
if (!glXMakeCurrent(XDisplay, XWindow, Context))
{
os::Printer::log("Could not make context current.", ELL_WARNING);
glXDestroyContext(XDisplay, Context);
}
}
else
{
os::Printer::log("Could not create GLX rendering context.", ELL_WARNING);
}
}
}
#endif // _IRR_COMPILE_WITH_OPENGL_
Window tmp;
u32 borderWidth;
int x,y;
@ -834,42 +575,43 @@ void CIrrDeviceLinux::createDriver()
switch(CreationParams.DriverType)
{
#ifdef _IRR_COMPILE_WITH_X11_
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
#else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
#else
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
#endif
#endif
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
if (Context)
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif
break;
#ifdef _IRR_COMPILE_WITH_OPENGL_
{
video::SExposedVideoData data;
data.OpenGLLinux.X11Window = XWindow;
data.OpenGLLinux.X11Display = XDisplay;
ContextManager->initialize(CreationParams, data);
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager);
}
#else
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
#endif
break;
case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
case video::EDT_DIRECT3D9:
os::Printer::log("This driver is not available in Linux. Try OpenGL or Software renderer.",
ELL_ERROR);
break;
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;
default:
os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
break;
@ -1404,7 +1146,7 @@ bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
return false;
}
u8* srcdata = reinterpret_cast<u8*>(image->lock());
u8* srcdata = reinterpret_cast<u8*>(image->getData());
u8* destData = reinterpret_cast<u8*>(SoftwareImage->data);
const u32 destheight = SoftwareImage->height;
@ -1416,7 +1158,6 @@ bool CIrrDeviceLinux::present(video::IImage* image, void* windowId, core::rect<s
srcdata+=srcPitch;
destData+=destPitch;
}
image->unlock();
GC gc = DefaultGC(XDisplay, DefaultScreen(XDisplay));
Window myWindow=XWindow;

View File

@ -163,6 +163,11 @@ video::IVideoModeList* CIrrDeviceStub::getVideoModeList()
return VideoModeList;
}
//! return the context manager
video::IContextManager* CIrrDeviceStub::getContextManager()
{
return ContextManager;
}
//! checks version of sdk and prints warning if there might be a problem
bool CIrrDeviceStub::checkVersion(const char* version)

View File

@ -9,6 +9,7 @@
#include "IImagePresenter.h"
#include "SIrrCreationParameters.h"
#include "CVideoModeList.h"
#include "IContextManager.h"
namespace irr
{
@ -76,6 +77,9 @@ namespace irr
//! Returns a pointer to a list with all video modes supported by the gfx adapter.
virtual video::IVideoModeList* getVideoModeList() _IRR_OVERRIDE_;
//! return the context manager
virtual video::IContextManager* getContextManager() _IRR_OVERRIDE_;
//! Returns a pointer to the ITimer object. With it the current Time can be received.
virtual ITimer* getTimer() _IRR_OVERRIDE_;
@ -180,6 +184,7 @@ namespace irr
};
SMouseMultiClicks MouseMultiClicks;
video::CVideoModeList* VideoModeList;
video::IContextManager* ContextManager;
SIrrlichtCreationParameters CreationParams;
bool Close;
};

View File

@ -34,19 +34,21 @@
#endif
#endif
#if defined(_IRR_COMPILE_WITH_OPENGL_)
#include "CWGLManager.h"
#endif
namespace irr
{
namespace video
{
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceWin32* device);
#endif
#ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
#endif
}
} // end namespace irr
@ -1163,65 +1165,53 @@ void CIrrDeviceWin32::createDriver()
{
case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
os::Printer::log("DIRECT3D8 Driver is no longer supported in Irrlicht. Try another one.", ELL_ERROR);
break;
break;
case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd);
if (!VideoDriver)
{
os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR);
}
#else
#else
os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
#endif
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_
#ifdef _IRR_COMPILE_WITH_OPENGL_
switchToFullScreen();
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
ContextManager = new video::CWGLManager();
ContextManager->initialize(CreationParams, video::SExposedVideoData(HWnd));
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, ContextManager);
if (!VideoDriver)
{
os::Printer::log("Could not create OpenGL driver.", ELL_ERROR);
}
#else
#else
os::Printer::log("OpenGL driver was not compiled in.", ELL_ERROR);
#endif
#endif
break;
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
switchToFullScreen();
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
#else
os::Printer::log("Software driver was not compiled in.", ELL_ERROR);
#endif
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
switchToFullScreen();
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
#else
os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);
#endif
#endif
break;
case video::EDT_NULL:
// create null driver
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;
default:
os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
break;

View File

@ -4,6 +4,7 @@
#include "COpenGLDriver.h"
#include "CNullDriver.h"
#include "IContextManager.h"
#ifdef _IRR_COMPILE_WITH_OPENGL_
@ -43,562 +44,56 @@ namespace video
// Statics variables
const u16 COpenGLDriver::Quad2DIndices[4] = { 0, 1, 2, 3 };
// -----------------------------------------------------------------------
// WINDOWS CONSTRUCTOR
// -----------------------------------------------------------------------
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
//! Windows constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
Params(params), HDc(0), Window(static_cast<HWND>(params.WindowId)), Win32Device(device),
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE), Params(params),
ContextManager(contextManager),
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
DeviceType(EIDT_WIN32)
{
#ifdef _DEBUG
setDebugName("COpenGLDriver");
#endif
}
bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceWin32* device)
{
if (videoData.OpenGLWin32.HWnd && videoData.OpenGLWin32.HDc && videoData.OpenGLWin32.HRc)
{
if (!wglMakeCurrent((HDC)videoData.OpenGLWin32.HDc, (HGLRC)videoData.OpenGLWin32.HRc))
{
os::Printer::log("Render Context switch failed.");
return false;
}
else
{
HDc = (HDC)videoData.OpenGLWin32.HDc;
}
}
// set back to main context
else if (HDc != ExposedData.OpenGLWin32.HDc)
{
if (!wglMakeCurrent((HDC)ExposedData.OpenGLWin32.HDc, (HGLRC)ExposedData.OpenGLWin32.HRc))
{
os::Printer::log("Render Context switch failed.");
return false;
}
else
{
HDc = (HDC)ExposedData.OpenGLWin32.HDc;
}
}
return true;
}
//! inits the open gl driver
bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
{
// Create a window to test antialiasing support
const fschar_t* ClassName = __TEXT("GLCIrrDeviceWin32");
HINSTANCE lhInstance = GetModuleHandle(0);
// Register Class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)DefWindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = lhInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = ClassName;
wcex.hIconSm = 0;
wcex.hIcon = 0;
RegisterClassEx(&wcex);
RECT clientSize;
clientSize.top = 0;
clientSize.left = 0;
clientSize.right = Params.WindowSize.Width;
clientSize.bottom = Params.WindowSize.Height;
DWORD style = WS_POPUP;
if (!Params.Fullscreen)
style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
AdjustWindowRect(&clientSize, style, FALSE);
const s32 realWidth = clientSize.right - clientSize.left;
const s32 realHeight = clientSize.bottom - clientSize.top;
const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
HWND temporary_wnd=CreateWindow(ClassName, __TEXT(""), style, windowLeft,
windowTop, realWidth, realHeight, NULL, NULL, lhInstance, NULL);
if (!temporary_wnd)
{
os::Printer::log("Cannot create a temporary window.", ELL_ERROR);
UnregisterClass(ClassName, lhInstance);
return false;
}
HDc = GetDC(temporary_wnd);
// Set up pixel format descriptor with desired parameters
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
(DWORD)(PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
(Params.Doublebuffer?PFD_DOUBLEBUFFER:0) | // Must Support Double Buffering
(Params.Stereobuffer?PFD_STEREO:0)), // Must Support Stereo Buffer
PFD_TYPE_RGBA, // Request An RGBA Format
Params.Bits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
Params.ZBufferBits, // Z-Buffer (Depth Buffer)
BYTE(Params.Stencilbuffer ? 1 : 0), // Stencil Buffer Depth
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
GLuint PixelFormat;
for (u32 i=0; i<6; ++i)
{
if (i == 1)
{
if (Params.Stencilbuffer)
{
os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING);
Params.Stencilbuffer = false;
pfd.cStencilBits = 0;
}
else
continue;
}
else
if (i == 2)
{
pfd.cDepthBits = 24;
}
else
if (i == 3)
{
if (Params.Bits!=16)
pfd.cDepthBits = 16;
else
continue;
}
else
if (i == 4)
{
// try single buffer
if (Params.Doublebuffer)
pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
else
continue;
}
else
if (i == 5)
{
os::Printer::log("Cannot create a GL device context", "No suitable format for temporary window.", ELL_ERROR);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
return false;
}
// choose pixelformat
PixelFormat = ChoosePixelFormat(HDc, &pfd);
if (PixelFormat)
break;
}
SetPixelFormat(HDc, PixelFormat, &pfd);
HGLRC hrc=wglCreateContext(HDc);
if (!hrc)
{
os::Printer::log("Cannot create a temporary GL rendering context.", ELL_ERROR);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
return false;
}
SExposedVideoData data;
data.OpenGLWin32.HDc = HDc;
data.OpenGLWin32.HRc = hrc;
data.OpenGLWin32.HWnd = temporary_wnd;
if (!changeRenderContext(data, device))
{
os::Printer::log("Cannot activate a temporary GL rendering context.", ELL_ERROR);
wglDeleteContext(hrc);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
return false;
}
core::stringc wglExtensions;
#ifdef WGL_ARB_extensions_string
PFNWGLGETEXTENSIONSSTRINGARBPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (irrGetExtensionsString)
wglExtensions = irrGetExtensionsString(HDc);
#elif defined(WGL_EXT_extensions_string)
PFNWGLGETEXTENSIONSSTRINGEXTPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
if (irrGetExtensionsString)
wglExtensions = irrGetExtensionsString(HDc);
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
DeviceType(EIDT_X11)
#else
DeviceType(EIDT_OSX)
#endif
const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1);
const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) ||
(wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1) );
{
#ifdef _DEBUG
os::Printer::log("WGL_extensions", wglExtensions);
#endif
#ifdef WGL_ARB_pixel_format
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
if (pixel_format_supported && wglChoosePixelFormat_ARB)
{
// This value determines the number of samples used for antialiasing
// My experience is that 8 does not show a big
// improvement over 4, but 4 shows a big improvement
// over 2.
if(AntiAlias > 32)
AntiAlias = 32;
f32 fAttributes[] = {0.0, 0.0};
s32 iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB,1,
WGL_SUPPORT_OPENGL_ARB,1,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB,(Params.Bits==32) ? 24 : 15,
WGL_ALPHA_BITS_ARB,(Params.Bits==32) ? 8 : 1,
WGL_DEPTH_BITS_ARB,Params.ZBufferBits, // 10,11
WGL_STENCIL_BITS_ARB,Params.Stencilbuffer ? 1 : 0,
WGL_DOUBLE_BUFFER_ARB,Params.Doublebuffer ? 1 : 0,
WGL_STEREO_ARB,Params.Stereobuffer ? 1 : 0,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
#ifdef WGL_ARB_multisample
WGL_SAMPLES_ARB,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_ARB, 1,
#elif defined(WGL_EXT_multisample)
WGL_SAMPLES_EXT,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_EXT, 1,
#elif defined(WGL_3DFX_multisample)
WGL_SAMPLES_3DFX,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_3DFX, 1,
#endif
#ifdef WGL_ARB_framebuffer_sRGB
WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, Params.HandleSRGB ? 1:0,
#elif defined(WGL_EXT_framebuffer_sRGB)
WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, Params.HandleSRGB ? 1:0,
#endif
// WGL_DEPTH_FLOAT_EXT, 1,
0,0,0,0
};
int iAttrSize = sizeof(iAttributes)/sizeof(int);
const bool framebuffer_srgb_supported = ((wglExtensions.find("WGL_ARB_framebuffer_sRGB") != -1) ||
(wglExtensions.find("WGL_EXT_framebuffer_sRGB") != -1));
if (!framebuffer_srgb_supported)
{
memmove(&iAttributes[24],&iAttributes[26],sizeof(int)*(iAttrSize-26));
iAttrSize -= 2;
}
if (!multi_sample_supported)
{
memmove(&iAttributes[20],&iAttributes[24],sizeof(int)*(iAttrSize-24));
iAttrSize -= 4;
}
s32 rv=0;
// Try to get an acceptable pixel format
do
{
int pixelFormat=0;
UINT numFormats=0;
const BOOL valid = wglChoosePixelFormat_ARB(HDc,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
if (valid && numFormats)
rv = pixelFormat;
else
iAttributes[21] -= 1;
}
while(rv==0 && iAttributes[21]>1);
if (rv)
{
PixelFormat=rv;
AntiAlias=iAttributes[21];
}
}
else
#endif
AntiAlias=0;
wglMakeCurrent(HDc, NULL);
wglDeleteContext(hrc);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
// get hdc
HDc=GetDC(Window);
if (!HDc)
{
os::Printer::log("Cannot create a GL device context.", ELL_ERROR);
return false;
}
// search for pixel format the simple way
if (PixelFormat==0 || (!SetPixelFormat(HDc, PixelFormat, &pfd)))
{
for (u32 i=0; i<5; ++i)
{
if (i == 1)
{
if (Params.Stencilbuffer)
{
os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING);
Params.Stencilbuffer = false;
pfd.cStencilBits = 0;
}
else
continue;
}
else
if (i == 2)
{
pfd.cDepthBits = 24;
}
if (i == 3)
{
if (Params.Bits!=16)
pfd.cDepthBits = 16;
else
continue;
}
else
if (i == 4)
{
os::Printer::log("Cannot create a GL device context", "No suitable format.", ELL_ERROR);
return false;
}
// choose pixelformat
PixelFormat = ChoosePixelFormat(HDc, &pfd);
if (PixelFormat)
break;
}
// set pixel format
if (!SetPixelFormat(HDc, PixelFormat, &pfd))
{
os::Printer::log("Cannot set the pixel format.", ELL_ERROR);
return false;
}
}
os::Printer::log("Pixel Format", core::stringc(PixelFormat).c_str(), ELL_DEBUG);
// create rendering context
#ifdef WGL_ARB_create_context
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
if (wglCreateContextAttribs_ARB)
{
int iAttribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
0
};
hrc=wglCreateContextAttribs_ARB(HDc, 0, iAttribs);
}
else
#endif
hrc=wglCreateContext(HDc);
if (!hrc)
{
os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR);
return false;
}
// set exposed data
ExposedData.OpenGLWin32.HDc = HDc;
ExposedData.OpenGLWin32.HRc = hrc;
ExposedData.OpenGLWin32.HWnd = Window;
// activate rendering context
if (!changeRenderContext(ExposedData, device))
{
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;
}
else
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_R8G8B8;
else
ColorFormat = ECF_R5G6B5;
}
genericDriverInit();
extGlSwapInterval(Params.Vsync ? 1 : 0);
return true;
}
#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
// -----------------------------------------------------------------------
// MacOSX CONSTRUCTOR
// -----------------------------------------------------------------------
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
//! OSX constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceMacOSX *device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
Params(params), OSXDevice(device), DeviceType(EIDT_OSX)
{
#ifdef _DEBUG
setDebugName("COpenGLDriver");
#endif
genericDriverInit();
#endif
}
#endif
// -----------------------------------------------------------------------
// LINUX CONSTRUCTOR
// -----------------------------------------------------------------------
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
//! Linux constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceLinux* device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
Params(params), X11Device(device), DeviceType(EIDT_X11)
{
#ifdef _DEBUG
setDebugName("COpenGLDriver");
#endif
}
bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceLinux* device)
{
if (videoData.OpenGLLinux.X11Window)
{
if (videoData.OpenGLLinux.X11Display && videoData.OpenGLLinux.X11Context)
{
if (!glXMakeCurrent((Display*)videoData.OpenGLLinux.X11Display, videoData.OpenGLLinux.X11Window, (GLXContext)videoData.OpenGLLinux.X11Context))
{
os::Printer::log("Render Context switch failed.");
return false;
}
else
{
Drawable = videoData.OpenGLLinux.X11Window;
X11Display = (Display*)videoData.OpenGLLinux.X11Display;
}
}
else
{
// in case we only got a window ID, try with the existing values for display and context
if (!glXMakeCurrent((Display*)ExposedData.OpenGLLinux.X11Display, videoData.OpenGLLinux.X11Window, (GLXContext)ExposedData.OpenGLLinux.X11Context))
{
os::Printer::log("Render Context switch failed.");
return false;
}
else
{
Drawable = videoData.OpenGLLinux.X11Window;
X11Display = (Display*)ExposedData.OpenGLLinux.X11Display;
}
}
}
// set back to main context
else if (X11Display != ExposedData.OpenGLLinux.X11Display)
{
if (!glXMakeCurrent((Display*)ExposedData.OpenGLLinux.X11Display, ExposedData.OpenGLLinux.X11Window, (GLXContext)ExposedData.OpenGLLinux.X11Context))
{
os::Printer::log("Render Context switch failed.");
return false;
}
else
{
Drawable = ExposedData.OpenGLLinux.X11Window;
X11Display = (Display*)ExposedData.OpenGLLinux.X11Display;
}
}
return true;
}
//! inits the open gl driver
bool COpenGLDriver::initDriver(CIrrDeviceLinux* device)
{
ExposedData.OpenGLLinux.X11Context = glXGetCurrentContext();
ExposedData.OpenGLLinux.X11Display = glXGetCurrentDisplay();
ExposedData.OpenGLLinux.X11Window = (unsigned long)Params.WindowId;
Drawable = glXGetCurrentDrawable();
X11Display = (Display*)ExposedData.OpenGLLinux.X11Display;
genericDriverInit();
// set vsync
extGlSwapInterval(Params.Vsync ? 1 : 0);
return true;
}
#endif // _IRR_COMPILE_WITH_X11_DEVICE_
// -----------------------------------------------------------------------
// SDL CONSTRUCTOR
// -----------------------------------------------------------------------
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
//! SDL constructor and init code
COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device)
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE),
Params(params), SDLDevice(device), DeviceType(EIDT_SDL)
{
#ifdef _DEBUG
#ifdef _DEBUG
setDebugName("COpenGLDriver");
#endif
#endif
genericDriverInit();
}
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
#endif
bool COpenGLDriver::initDriver()
{
ContextManager->generateSurface();
ContextManager->generateContext();
ExposedData = ContextManager->getContext();
ContextManager->activateContext(ExposedData);
genericDriverInit();
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_)
extGlSwapInterval(Params.Vsync ? 1 : 0);
#endif
return true;
}
//! destructor
COpenGLDriver::~COpenGLDriver()
@ -617,23 +112,13 @@ COpenGLDriver::~COpenGLDriver()
delete CacheHandler;
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
if (DeviceType == EIDT_WIN32)
if (ContextManager)
{
if (ExposedData.OpenGLWin32.HRc)
{
if (!wglMakeCurrent(HDc, 0))
os::Printer::log("Release of dc and rc failed.", ELL_WARNING);
if (!wglDeleteContext((HGLRC)ExposedData.OpenGLWin32.HRc))
os::Printer::log("Release of rendering context failed.", ELL_WARNING);
}
if (HDc)
ReleaseDC(Window, HDc);
ContextManager->destroyContext();
ContextManager->destroySurface();
ContextManager->terminate();
ContextManager->drop();
}
#endif
}
// -----------------------------------------------------------------------
@ -642,6 +127,9 @@ COpenGLDriver::~COpenGLDriver()
bool COpenGLDriver::genericDriverInit()
{
if (ContextManager)
ContextManager->grab();
Name=L"OpenGL ";
Name.append(glGetString(GL_VERSION));
s32 pos=Name.findNext(L' ', 7);
@ -811,33 +299,15 @@ bool COpenGLDriver::beginScene(u16 clearFlag, SColor clearColor, f32 clearDepth,
{
CNullDriver::beginScene(clearFlag, clearColor, clearDepth, clearStencil, videoData, sourceRect);
switch (DeviceType)
{
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
case EIDT_WIN32:
changeRenderContext(videoData, Win32Device);
break;
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
case EIDT_X11:
changeRenderContext(videoData, X11Device);
break;
#endif
default:
changeRenderContext(videoData, (void*)0);
break;
}
if (ContextManager)
ContextManager->activateContext(videoData);
#if defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
if (DeviceType == EIDT_SDL)
{
// todo: SDL sets glFrontFace(GL_CCW) after driver creation,
// it would be better if this was fixed elsewhere.
glFrontFace(GL_CW);
}
glFrontFace(GL_CW);
#endif
clearBuffers(clearFlag, clearColor, clearDepth, clearStencil);
return true;
}
@ -847,38 +317,19 @@ bool COpenGLDriver::endScene()
glFlush();
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
if (DeviceType == EIDT_WIN32)
return SwapBuffers(HDc) == TRUE;
#endif
bool status = false;
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
if (DeviceType == EIDT_X11)
{
glXSwapBuffers(X11Display, Drawable);
return true;
}
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
if (DeviceType == EIDT_OSX)
{
OSXDevice->flush();
return true;
}
#endif
if (ContextManager)
status = ContextManager->swapBuffers();
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
if (DeviceType == EIDT_SDL)
{
SDL_GL_SwapBuffers();
return true;
}
SDL_GL_SwapBuffers();
status = true;
#endif
// todo: console device present
return false;
return status;
}
@ -4820,64 +4271,24 @@ namespace irr
namespace video
{
// -----------------------------------
// WINDOWS VERSION
// -----------------------------------
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceWin32* device)
{
#ifdef _IRR_COMPILE_WITH_OPENGL_
COpenGLDriver* ogl = new COpenGLDriver(params, io, device);
if (!ogl->initDriver(device))
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager)
{
ogl->drop();
ogl = 0;
}
return ogl;
#else
return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_
}
#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
// -----------------------------------
// MACOSX VERSION
// -----------------------------------
#if defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceMacOSX *device)
{
#ifdef _IRR_COMPILE_WITH_OPENGL_
return new COpenGLDriver(params, io, device);
#else
return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_
}
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
COpenGLDriver* ogl = new COpenGLDriver(params, io, contextManager);
// -----------------------------------
// X11 VERSION
// -----------------------------------
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceLinux* device)
{
#ifdef _IRR_COMPILE_WITH_OPENGL_
COpenGLDriver* ogl = new COpenGLDriver(params, io, device);
if (!ogl->initDriver(device))
{
ogl->drop();
ogl = 0;
if (!ogl->initDriver())
{
ogl->drop();
ogl = 0;
}
return ogl;
#else
return 0;
#endif
}
return ogl;
#else
return 0;
#endif // _IRR_COMPILE_WITH_OPENGL_
}
#endif // _IRR_COMPILE_WITH_X11_DEVICE_
#endif
// -----------------------------------
// SDL VERSION

View File

@ -29,6 +29,8 @@ namespace irr
namespace video
{
class IContextManager;
class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler
{
friend COpenGLCacheHandler;
@ -43,30 +45,15 @@ namespace video
EOFPS_DISABLE_TO_ENABLE // switch from programmable to fixed pipeline.
};
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device);
//! inits the windows specific parts of the open gl driver
bool initDriver(CIrrDeviceWin32* device);
bool changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceWin32* device);
#endif
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceLinux* device);
//! inits the GLX specific parts of the open gl driver
bool initDriver(CIrrDeviceLinux* device);
bool changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceLinux* device);
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device);
#endif
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceMacOSX *device);
#endif
//! generic version which overloads the unimplemented versions
bool changeRenderContext(const SExposedVideoData& videoData, void* device) {return false;}
bool initDriver();
//! destructor
virtual ~COpenGLDriver();
@ -510,25 +497,12 @@ namespace video
S3DVertex Quad2DVertices[4];
static const u16 Quad2DIndices[4];
#ifdef _IRR_WINDOWS_API_
HDC HDc; // Private GDI Device Context
HWND Window;
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
CIrrDeviceWin32 *Win32Device;
#endif
#endif
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
GLXDrawable Drawable;
Display* X11Display;
CIrrDeviceLinux *X11Device;
#endif
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
CIrrDeviceMacOSX *OSXDevice;
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
CIrrDeviceSDL *SDLDevice;
#endif
IContextManager* ContextManager;
E_DEVICE_TYPE DeviceType;
};

View File

@ -2351,7 +2351,7 @@ void CBurningVideoDriver::drawStencilShadow(bool clearStencilBuffer, video::SCol
for ( u32 y = 0; y < h; ++y )
{
dst = (tVideoSample*)RenderTargetSurface->lock() + ( y * w );
dst = (tVideoSample*)RenderTargetSurface->getData() + ( y * w );
stencil = stencilBase + ( y * w );
for ( u32 x = 0; x < w; ++x )

View File

@ -78,7 +78,7 @@ CSoftwareTexture::~CSoftwareTexture()
//! lock function
void* CSoftwareTexture::lock(E_TEXTURE_LOCK_MODE mode, u32 mipmapLevel)
{
return Image->lock();
return Image->getData();
}
@ -91,8 +91,6 @@ void CSoftwareTexture::unlock()
os::Printer::log("Performance warning, slow unlock of non power of 2 texture.", ELL_WARNING);
Image->copyToScaling(Texture);
}
Image->unlock();
}

View File

@ -0,0 +1,487 @@
// Copyright (C) 2013 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "CWGLManager.h"
#ifdef _IRR_COMPILE_WITH_WGL_MANAGER_
#include "os.h"
#include <GL/gl.h>
#include "wglext.h"
#ifdef _MSC_VER
#pragma comment(lib, "OpenGL32.lib")
#endif
namespace irr
{
namespace video
{
CWGLManager::CWGLManager()
: PrimaryContext(SExposedVideoData(0)), PixelFormat(0)
{
#ifdef _DEBUG
setDebugName("CWGLManager");
#endif
}
CWGLManager::~CWGLManager()
{
}
bool CWGLManager::initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& videodata)
{
// store params, videoData is set later as it would be overwritten else
Params=params;
// Create a window to test antialiasing support
const fschar_t* ClassName = __TEXT("CWGLManager");
HINSTANCE lhInstance = GetModuleHandle(0);
// Register Class
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)DefWindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = lhInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = ClassName;
wcex.hIconSm = 0;
wcex.hIcon = 0;
RegisterClassEx(&wcex);
RECT clientSize;
clientSize.top = 0;
clientSize.left = 0;
clientSize.right = Params.WindowSize.Width;
clientSize.bottom = Params.WindowSize.Height;
DWORD style = WS_POPUP;
if (!Params.Fullscreen)
style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
AdjustWindowRect(&clientSize, style, FALSE);
const s32 realWidth = clientSize.right - clientSize.left;
const s32 realHeight = clientSize.bottom - clientSize.top;
const s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
const s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
HWND temporary_wnd=CreateWindow(ClassName, __TEXT(""), style, windowLeft,
windowTop, realWidth, realHeight, NULL, NULL, lhInstance, NULL);
if (!temporary_wnd)
{
os::Printer::log("Cannot create a temporary window.", ELL_ERROR);
UnregisterClass(ClassName, lhInstance);
return false;
}
HDC HDc = GetDC(temporary_wnd);
// Set up pixel format descriptor with desired parameters
PIXELFORMATDESCRIPTOR tmp_pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
(DWORD)(PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
(Params.Doublebuffer?PFD_DOUBLEBUFFER:0) | // Must Support Double Buffering
(Params.Stereobuffer?PFD_STEREO:0)), // Must Support Stereo Buffer
PFD_TYPE_RGBA, // Request An RGBA Format
Params.Bits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
Params.ZBufferBits, // Z-Buffer (Depth Buffer)
BYTE(Params.Stencilbuffer ? 1 : 0), // Stencil Buffer Depth
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
pfd=tmp_pfd;
for (u32 i=0; i<6; ++i)
{
if (i == 1)
{
if (Params.Stencilbuffer)
{
os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING);
Params.Stencilbuffer = false;
pfd.cStencilBits = 0;
}
else
continue;
}
else
if (i == 2)
{
pfd.cDepthBits = 24;
}
else
if (i == 3)
{
if (Params.Bits!=16)
pfd.cDepthBits = 16;
else
continue;
}
else
if (i == 4)
{
// try single buffer
if (Params.Doublebuffer)
pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
else
continue;
}
else
if (i == 5)
{
os::Printer::log("Cannot create a GL device context", "No suitable format for temporary window.", ELL_ERROR);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
return false;
}
// choose pixelformat
PixelFormat = ChoosePixelFormat(HDc, &pfd);
if (PixelFormat)
break;
}
SetPixelFormat(HDc, PixelFormat, &pfd);
os::Printer::log("Temporary context");
HGLRC hrc=wglCreateContext(HDc);
if (!hrc)
{
os::Printer::log("Cannot create a temporary GL rendering context.", ELL_ERROR);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
return false;
}
CurrentContext.OpenGLWin32.HDc = HDc;
CurrentContext.OpenGLWin32.HRc = hrc;
CurrentContext.OpenGLWin32.HWnd = temporary_wnd;
if (!activateContext(CurrentContext))
{
os::Printer::log("Cannot activate a temporary GL rendering context.", ELL_ERROR);
wglDeleteContext(hrc);
ReleaseDC(temporary_wnd, HDc);
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
return false;
}
core::stringc wglExtensions;
#ifdef WGL_ARB_extensions_string
PFNWGLGETEXTENSIONSSTRINGARBPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
if (irrGetExtensionsString)
wglExtensions = irrGetExtensionsString(HDc);
#elif defined(WGL_EXT_extensions_string)
PFNWGLGETEXTENSIONSSTRINGEXTPROC irrGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
if (irrGetExtensionsString)
wglExtensions = irrGetExtensionsString(HDc);
#endif
const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1);
const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) ||
(wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1) );
#ifdef _DEBUG
os::Printer::log("WGL_extensions", wglExtensions);
#endif
#ifdef WGL_ARB_pixel_format
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
if (pixel_format_supported && wglChoosePixelFormat_ARB)
{
// This value determines the number of samples used for antialiasing
// My experience is that 8 does not show a big
// improvement over 4, but 4 shows a big improvement
// over 2.
if (Params.AntiAlias > 32)
Params.AntiAlias = 32;
f32 fAttributes[] = {0.0, 0.0};
s32 iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB,1,
WGL_SUPPORT_OPENGL_ARB,1,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB,(Params.Bits==32) ? 24 : 15,
WGL_ALPHA_BITS_ARB,(Params.Bits==32) ? 8 : 1,
WGL_DEPTH_BITS_ARB,Params.ZBufferBits, // 10,11
WGL_STENCIL_BITS_ARB,Params.Stencilbuffer ? 1 : 0,
WGL_DOUBLE_BUFFER_ARB,Params.Doublebuffer ? 1 : 0,
WGL_STEREO_ARB,Params.Stereobuffer ? 1 : 0,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
#ifdef WGL_ARB_multisample
WGL_SAMPLES_ARB,Params.AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_ARB, 1,
#elif defined(WGL_EXT_multisample)
WGL_SAMPLES_EXT,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_EXT, 1,
#elif defined(WGL_3DFX_multisample)
WGL_SAMPLES_3DFX,AntiAlias, // 20,21
WGL_SAMPLE_BUFFERS_3DFX, 1,
#endif
#ifdef WGL_ARB_framebuffer_sRGB
WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, Params.HandleSRGB ? 1:0,
#elif defined(WGL_EXT_framebuffer_sRGB)
WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT, Params.HandleSRGB ? 1:0,
#endif
// WGL_DEPTH_FLOAT_EXT, 1,
0,0,0,0
};
int iAttrSize = sizeof(iAttributes)/sizeof(int);
const bool framebuffer_srgb_supported = ((wglExtensions.find("WGL_ARB_framebuffer_sRGB") != -1) ||
(wglExtensions.find("WGL_EXT_framebuffer_sRGB") != -1));
if (!framebuffer_srgb_supported)
{
memmove(&iAttributes[24],&iAttributes[26],sizeof(int)*(iAttrSize-26));
iAttrSize -= 2;
}
if (!multi_sample_supported)
{
memmove(&iAttributes[20],&iAttributes[24],sizeof(int)*(iAttrSize-24));
iAttrSize -= 4;
}
s32 rv=0;
// Try to get an acceptable pixel format
do
{
int pixelFormat=0;
UINT numFormats=0;
const BOOL valid = wglChoosePixelFormat_ARB(HDc,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
if (valid && numFormats)
rv = pixelFormat;
else
iAttributes[21] -= 1;
}
while(rv==0 && iAttributes[21]>1);
if (rv)
{
PixelFormat=rv;
Params.AntiAlias=iAttributes[21];
}
}
else
#endif
Params.AntiAlias=0;
// this only terminates the temporary HRc
destroyContext();
destroySurface();
terminate();
DestroyWindow(temporary_wnd);
UnregisterClass(ClassName, lhInstance);
// now get new window
CurrentContext.OpenGLWin32.HWnd=videodata.OpenGLWin32.HWnd;
// get hdc
if (!(CurrentContext.OpenGLWin32.HDc=GetDC((HWND)videodata.OpenGLWin32.HWnd)))
{
os::Printer::log("Cannot create a GL device context.", ELL_ERROR);
return false;
}
if (!PrimaryContext.OpenGLWin32.HWnd)
{
PrimaryContext.OpenGLWin32.HWnd=CurrentContext.OpenGLWin32.HWnd;
PrimaryContext.OpenGLWin32.HDc=CurrentContext.OpenGLWin32.HDc;
}
return true;
}
void CWGLManager::terminate()
{
if (CurrentContext.OpenGLWin32.HDc)
ReleaseDC((HWND)CurrentContext.OpenGLWin32.HWnd, (HDC)CurrentContext.OpenGLWin32.HDc);
if (PrimaryContext.OpenGLWin32.HDc && PrimaryContext.OpenGLWin32.HDc == CurrentContext.OpenGLWin32.HDc)
memset(&PrimaryContext, 0, sizeof(PrimaryContext));
memset(&CurrentContext, 0, sizeof(CurrentContext));
}
bool CWGLManager::generateSurface()
{
HDC HDc = (HDC)CurrentContext.OpenGLWin32.HDc;
// search for pixel format the simple way
if (PixelFormat==0 || (!SetPixelFormat(HDc, PixelFormat, &pfd)))
{
for (u32 i=0; i<5; ++i)
{
if (i == 1)
{
if (Params.Stencilbuffer)
{
os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING);
Params.Stencilbuffer = false;
pfd.cStencilBits = 0;
}
else
continue;
}
else
if (i == 2)
{
pfd.cDepthBits = 24;
}
if (i == 3)
{
if (Params.Bits!=16)
pfd.cDepthBits = 16;
else
continue;
}
else
if (i == 4)
{
os::Printer::log("Cannot create a GL device context", "No suitable format.", ELL_ERROR);
return false;
}
// choose pixelformat
PixelFormat = ChoosePixelFormat(HDc, &pfd);
if (PixelFormat)
break;
}
// set pixel format
if (!SetPixelFormat(HDc, PixelFormat, &pfd))
{
os::Printer::log("Cannot set the pixel format.", ELL_ERROR);
return false;
}
}
if (pfd.cAlphaBits != 0)
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_A8R8G8B8;
else
ColorFormat = ECF_A1R5G5B5;
}
else
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_R8G8B8;
else
ColorFormat = ECF_R5G6B5;
}
os::Printer::log("Pixel Format", core::stringc(PixelFormat).c_str(), ELL_DEBUG);
return true;
}
void CWGLManager::destroySurface()
{
}
bool CWGLManager::generateContext()
{
HDC HDc=(HDC)CurrentContext.OpenGLWin32.HDc;
HGLRC hrc;
// create rendering context
#ifdef WGL_ARB_create_context
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
if (wglCreateContextAttribs_ARB)
{
// with 3.0 all available profiles should be usable, higher versions impose restrictions
// we need at least 1.1
const int iAttribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 1,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
0
};
hrc=wglCreateContextAttribs_ARB(HDc, 0, iAttribs);
}
else
#endif
hrc=wglCreateContext(HDc);
os::Printer::log("Irrlicht context");
if (!hrc)
{
os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR);
return false;
}
// set exposed data
CurrentContext.OpenGLWin32.HRc = hrc;
if (!PrimaryContext.OpenGLWin32.HRc)
PrimaryContext.OpenGLWin32.HRc=CurrentContext.OpenGLWin32.HRc;
return true;
}
const SExposedVideoData& CWGLManager::getContext() const
{
return CurrentContext;
}
bool CWGLManager::activateContext(const SExposedVideoData& videoData)
{
if (videoData.OpenGLWin32.HWnd && videoData.OpenGLWin32.HDc && videoData.OpenGLWin32.HRc)
{
if (!wglMakeCurrent((HDC)videoData.OpenGLWin32.HDc, (HGLRC)videoData.OpenGLWin32.HRc))
{
os::Printer::log("Render Context switch failed.");
return false;
}
CurrentContext=videoData;
}
// set back to main context
else if (!videoData.OpenGLWin32.HWnd && CurrentContext.OpenGLWin32.HDc != PrimaryContext.OpenGLWin32.HDc)
{
if (!wglMakeCurrent((HDC)PrimaryContext.OpenGLWin32.HDc, (HGLRC)PrimaryContext.OpenGLWin32.HRc))
{
os::Printer::log("Render Context switch failed.");
return false;
}
CurrentContext=PrimaryContext;
}
return true;
}
void CWGLManager::destroyContext()
{
if (CurrentContext.OpenGLWin32.HRc)
{
if (!wglMakeCurrent((HDC)CurrentContext.OpenGLWin32.HDc, 0))
os::Printer::log("Release of render context failed.", ELL_WARNING);
if (!wglDeleteContext((HGLRC)CurrentContext.OpenGLWin32.HRc))
os::Printer::log("Deletion of render context failed.", ELL_WARNING);
if (PrimaryContext.OpenGLWin32.HRc==CurrentContext.OpenGLWin32.HRc)
PrimaryContext.OpenGLWin32.HRc=0;
CurrentContext.OpenGLWin32.HRc=0;
}
}
bool CWGLManager::swapBuffers()
{
return SwapBuffers((HDC)CurrentContext.OpenGLWin32.HDc) == TRUE;
}
}
}
#endif

View File

@ -0,0 +1,74 @@
// Copyright (C) 2013 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#ifndef __C_WGL_MANAGER_H_INCLUDED__
#define __C_WGL_MANAGER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_WGL_MANAGER_
#include "SIrrCreationParameters.h"
#include "SExposedVideoData.h"
#include "IContextManager.h"
#include "SColor.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace irr
{
namespace video
{
// WGL manager.
class CWGLManager : public IContextManager
{
public:
//! Constructor.
CWGLManager();
//! Destructor
~CWGLManager();
// Initialize
bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data);
// Terminate
void terminate();
// Create surface.
bool generateSurface();
// Destroy surface.
void destroySurface();
// Create context.
bool generateContext();
// Destroy EGL context.
void destroyContext();
//! Get current context
const SExposedVideoData& getContext() const;
//! Change render context, disable old and activate new defined by videoData
bool activateContext(const SExposedVideoData& videoData);
// Swap buffers.
bool swapBuffers();
private:
SIrrlichtCreationParameters Params;
SExposedVideoData PrimaryContext;
SExposedVideoData CurrentContext;
s32 PixelFormat;
PIXELFORMATDESCRIPTOR pfd;
ECOLOR_FORMAT ColorFormat;
};
}
}
#endif
#endif

View File

@ -445,6 +445,7 @@
<Unit filename="..\..\include\IBoneSceneNode.h" />
<Unit filename="..\..\include\ICameraSceneNode.h" />
<Unit filename="..\..\include\IColladaMeshWriter.h" />
<Unit filename="..\..\include\IContextManager.h" />
<Unit filename="..\..\include\ICursorControl.h" />
<Unit filename="..\..\include\IDummyTransformationSceneNode.h" />
<Unit filename="..\..\include\IDynamicMeshBuffer.h" />
@ -671,6 +672,8 @@
<Unit filename="CFileList.h" />
<Unit filename="CFileSystem.cpp" />
<Unit filename="CFileSystem.h" />
<Unit filename="CGLXManager.cpp" />
<Unit filename="CGLXManager.h" />
<Unit filename="CGUIButton.cpp" />
<Unit filename="CGUIButton.h" />
<Unit filename="CGUICheckBox.cpp" />
@ -988,6 +991,8 @@
<Unit filename="CWADReader.h" />
<Unit filename="CWaterSurfaceSceneNode.cpp" />
<Unit filename="CWaterSurfaceSceneNode.h" />
<Unit filename="CWGLManager.cpp" />
<Unit filename="CWGLManager.h" />
<Unit filename="CWriteFile.cpp" />
<Unit filename="CWriteFile.h" />
<Unit filename="CXMLReader.cpp" />
@ -1010,8 +1015,6 @@
<Unit filename="ITriangleRenderer.h" />
<Unit filename="IZBuffer.h" />
<Unit filename="Irrlicht.cpp" />
<Unit filename="MacOSX\CIrrDeviceMacOSX.h" />
<Unit filename="MacOSX\CIrrDeviceMacOSX.mm" />
<Unit filename="Octree.h" />
<Unit filename="S2DVertex.h" />
<Unit filename="S4DVertex.h" />

View File

@ -857,6 +857,7 @@
<ClInclude Include="..\..\include\SIrrCreationParameters.h" />
<ClInclude Include="..\..\include\SKeyMap.h" />
<ClInclude Include="..\..\include\EDriverTypes.h" />
<ClInclude Include="..\..\include\IContextManager.h" />
<ClInclude Include="..\..\include\IGeometryCreator.h" />
<ClInclude Include="..\..\include\IGPUProgrammingServices.h" />
<ClInclude Include="..\..\include\IImage.h" />
@ -1006,6 +1007,7 @@
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CGLXManager.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COGLCoreCacheHandler.h" />
@ -1023,6 +1025,7 @@
<ClInclude Include="COpenGLSLMaterialRenderer.h" />
<ClInclude Include="CProfiler.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="CWGLManager.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
<ClInclude Include="C3DSMeshFileLoader.h" />
@ -1257,6 +1260,7 @@
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CGLXManager.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCacheHandler.cpp" />
@ -1292,6 +1296,7 @@
<ClCompile Include="CQ3LevelMesh.cpp" />
<ClCompile Include="CSkinnedMesh.cpp" />
<ClCompile Include="CSTLMeshFileLoader.cpp" />
<ClCompile Include="CWGLManager.cpp" />
<ClCompile Include="CXMeshFileLoader.cpp" />
<ClCompile Include="CAnimatedMeshSceneNode.cpp" />
<ClCompile Include="CBillboardSceneNode.cpp" />

View File

@ -103,6 +103,9 @@
<Filter Include="Irrlicht\video\OpenGL Core">
<UniqueIdentifier>{2c9c6ef7-5662-4f11-83cd-921c717d3ab0}</UniqueIdentifier>
</Filter>
<Filter Include="Irrlicht\video\OpenGL Context">
<UniqueIdentifier>{397439c6-ad86-45a8-b692-f3606794a075}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\IEventReceiver.h">
@ -144,6 +147,9 @@
<ClInclude Include="..\..\include\EDriverTypes.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IContextManager.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IGeometryCreator.h">
<Filter>include\video</Filter>
</ClInclude>
@ -1327,6 +1333,12 @@
<ClInclude Include="COGLCoreTexture.h">
<Filter>Irrlicht\video\OpenGL Core</Filter>
</ClInclude>
<ClInclude Include="CGLXManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
<ClInclude Include="CWGLManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -2258,6 +2270,12 @@
<ClCompile Include="COpenGLSLMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
<ClCompile Include="CGLXManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
<ClCompile Include="CWGLManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />

View File

@ -858,6 +858,7 @@
<ClInclude Include="..\..\include\SIrrCreationParameters.h" />
<ClInclude Include="..\..\include\SKeyMap.h" />
<ClInclude Include="..\..\include\EDriverTypes.h" />
<ClInclude Include="..\..\include\IContextManager.h" />
<ClInclude Include="..\..\include\IGeometryCreator.h" />
<ClInclude Include="..\..\include\IGPUProgrammingServices.h" />
<ClInclude Include="..\..\include\IImage.h" />
@ -1006,6 +1007,7 @@
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CGLXManager.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COGLCoreCacheHandler.h" />
@ -1022,6 +1024,7 @@
<ClInclude Include="COpenGLShaderMaterialRenderer.h" />
<ClInclude Include="COpenGLSLMaterialRenderer.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="CWGLManager.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
<ClInclude Include="C3DSMeshFileLoader.h" />
@ -1257,6 +1260,7 @@
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CGLXManager.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCacheHandler.cpp" />
@ -1292,6 +1296,7 @@
<ClCompile Include="CQ3LevelMesh.cpp" />
<ClCompile Include="CSkinnedMesh.cpp" />
<ClCompile Include="CSTLMeshFileLoader.cpp" />
<ClCompile Include="CWGLManager.cpp" />
<ClCompile Include="CXMeshFileLoader.cpp" />
<ClCompile Include="CAnimatedMeshSceneNode.cpp" />
<ClCompile Include="CBillboardSceneNode.cpp" />

View File

@ -103,6 +103,9 @@
<Filter Include="Irrlicht\video\OpenGL Core">
<UniqueIdentifier>{bc1d03a2-7534-4b2f-857f-be5e0ab41dde}</UniqueIdentifier>
</Filter>
<Filter Include="Irrlicht\video\OpenGL Context">
<UniqueIdentifier>{d16493e0-554f-49e0-b228-0e4047839dba}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\IEventReceiver.h">
@ -150,6 +153,9 @@
<ClInclude Include="..\..\include\EDriverTypes.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IContextManager.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IGeometryCreator.h">
<Filter>include\video</Filter>
</ClInclude>
@ -1327,6 +1333,12 @@
<ClInclude Include="COGLCoreTexture.h">
<Filter>Irrlicht\video\OpenGL Core</Filter>
</ClInclude>
<ClInclude Include="CGLXManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
<ClInclude Include="CWGLManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -2258,6 +2270,12 @@
<ClCompile Include="COpenGLSLMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
<ClCompile Include="CGLXManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
<ClCompile Include="CWGLManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />

View File

@ -858,6 +858,7 @@
<ClInclude Include="..\..\include\SIrrCreationParameters.h" />
<ClInclude Include="..\..\include\SKeyMap.h" />
<ClInclude Include="..\..\include\EDriverTypes.h" />
<ClInclude Include="..\..\include\IContextManager.h" />
<ClInclude Include="..\..\include\IGeometryCreator.h" />
<ClInclude Include="..\..\include\IGPUProgrammingServices.h" />
<ClInclude Include="..\..\include\IImage.h" />
@ -1006,6 +1007,7 @@
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CGLXManager.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COGLCoreCacheHandler.h" />
@ -1022,6 +1024,7 @@
<ClInclude Include="COpenGLShaderMaterialRenderer.h" />
<ClInclude Include="COpenGLSLMaterialRenderer.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="CWGLManager.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
<ClInclude Include="C3DSMeshFileLoader.h" />
@ -1257,6 +1260,7 @@
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CGLXManager.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCacheHandler.cpp" />
@ -1292,6 +1296,7 @@
<ClCompile Include="CQ3LevelMesh.cpp" />
<ClCompile Include="CSkinnedMesh.cpp" />
<ClCompile Include="CSTLMeshFileLoader.cpp" />
<ClCompile Include="CWGLManager.cpp" />
<ClCompile Include="CXMeshFileLoader.cpp" />
<ClCompile Include="CAnimatedMeshSceneNode.cpp" />
<ClCompile Include="CBillboardSceneNode.cpp" />

View File

@ -103,6 +103,9 @@
<Filter Include="Irrlicht\video\OpenGL Core">
<UniqueIdentifier>{d6b83fe4-204d-4a95-aeb7-5b8ebdec7e5d}</UniqueIdentifier>
</Filter>
<Filter Include="Irrlicht\video\OpenGL Context">
<UniqueIdentifier>{f1f5ce52-0b36-4934-8c51-8e73026f94cc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\IEventReceiver.h">
@ -150,6 +153,9 @@
<ClInclude Include="..\..\include\EDriverTypes.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IContextManager.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IGeometryCreator.h">
<Filter>include\video</Filter>
</ClInclude>
@ -1327,6 +1333,12 @@
<ClInclude Include="COGLCoreTexture.h">
<Filter>Irrlicht\video\OpenGL Core</Filter>
</ClInclude>
<ClInclude Include="CGLXManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
<ClInclude Include="CWGLManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -2258,6 +2270,12 @@
<ClCompile Include="COpenGLSLMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
<ClCompile Include="CGLXManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
<ClCompile Include="CWGLManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />

View File

@ -868,6 +868,7 @@
<ClInclude Include="..\..\include\SIrrCreationParameters.h" />
<ClInclude Include="..\..\include\SKeyMap.h" />
<ClInclude Include="..\..\include\EDriverTypes.h" />
<ClInclude Include="..\..\include\IContextManager.h" />
<ClInclude Include="..\..\include\IGeometryCreator.h" />
<ClInclude Include="..\..\include\IGPUProgrammingServices.h" />
<ClInclude Include="..\..\include\IImage.h" />
@ -1016,6 +1017,7 @@
<ClInclude Include="CDefaultSceneNodeAnimatorFactory.h" />
<ClInclude Include="CDefaultSceneNodeFactory.h" />
<ClInclude Include="CGeometryCreator.h" />
<ClInclude Include="CGLXManager.h" />
<ClInclude Include="CMeshCache.h" />
<ClInclude Include="CMeshManipulator.h" />
<ClInclude Include="COGLCoreCacheHandler.h" />
@ -1032,6 +1034,7 @@
<ClInclude Include="COpenGLShaderMaterialRenderer.h" />
<ClInclude Include="COpenGLSLMaterialRenderer.h" />
<ClInclude Include="CSceneManager.h" />
<ClInclude Include="CWGLManager.h" />
<ClInclude Include="Octree.h" />
<ClInclude Include="CSMFMeshFileLoader.h" />
<ClInclude Include="C3DSMeshFileLoader.h" />
@ -1267,6 +1270,7 @@
<ClCompile Include="CDefaultSceneNodeAnimatorFactory.cpp" />
<ClCompile Include="CDefaultSceneNodeFactory.cpp" />
<ClCompile Include="CGeometryCreator.cpp" />
<ClCompile Include="CGLXManager.cpp" />
<ClCompile Include="CMeshCache.cpp" />
<ClCompile Include="CMeshManipulator.cpp" />
<ClCompile Include="COpenGLCacheHandler.cpp" />
@ -1302,6 +1306,7 @@
<ClCompile Include="CQ3LevelMesh.cpp" />
<ClCompile Include="CSkinnedMesh.cpp" />
<ClCompile Include="CSTLMeshFileLoader.cpp" />
<ClCompile Include="CWGLManager.cpp" />
<ClCompile Include="CXMeshFileLoader.cpp" />
<ClCompile Include="CAnimatedMeshSceneNode.cpp" />
<ClCompile Include="CBillboardSceneNode.cpp" />

View File

@ -103,6 +103,9 @@
<Filter Include="Irrlicht\video\OpenGL Core">
<UniqueIdentifier>{628de03e-6872-4682-b1f6-d3cc453c9d55}</UniqueIdentifier>
</Filter>
<Filter Include="Irrlicht\video\OpenGL Context">
<UniqueIdentifier>{2512a519-e6c0-4b48-aae4-ded2d2500b95}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\IEventReceiver.h">
@ -150,6 +153,9 @@
<ClInclude Include="..\..\include\EDriverTypes.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IContextManager.h">
<Filter>include\video</Filter>
</ClInclude>
<ClInclude Include="..\..\include\IGeometryCreator.h">
<Filter>include\video</Filter>
</ClInclude>
@ -1327,6 +1333,12 @@
<ClInclude Include="COGLCoreTexture.h">
<Filter>Irrlicht\video\OpenGL Core</Filter>
</ClInclude>
<ClInclude Include="CGLXManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
<ClInclude Include="CWGLManager.h">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\changes.txt">
@ -2258,6 +2270,12 @@
<ClCompile Include="COpenGLSLMaterialRenderer.cpp">
<Filter>Irrlicht\video\OpenGL</Filter>
</ClCompile>
<ClCompile Include="CGLXManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
<ClCompile Include="CWGLManager.cpp">
<Filter>Irrlicht\video\OpenGL Context</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Irrlicht.rc" />

View File

@ -38,7 +38,7 @@ IRRMESHOBJ = $(IRRMESHLOADER) $(IRRMESHWRITER) \
IRROBJ = CBillboardSceneNode.o CCameraSceneNode.o CDummyTransformationSceneNode.o CEmptySceneNode.o CGeometryCreator.o CLightSceneNode.o CMeshManipulator.o CMetaTriangleSelector.o COctreeSceneNode.o COctreeTriangleSelector.o CSceneCollisionManager.o CSceneManager.o CShadowVolumeSceneNode.o CSkyBoxSceneNode.o CSkyDomeSceneNode.o CTerrainSceneNode.o CTerrainTriangleSelector.o CVolumeLightSceneNode.o CCubeSceneNode.o CSphereSceneNode.o CTextSceneNode.o CTriangleBBSelector.o CTriangleSelector.o CWaterSurfaceSceneNode.o CMeshCache.o CDefaultSceneNodeAnimatorFactory.o CDefaultSceneNodeFactory.o CSceneLoaderIrr.o
IRRPARTICLEOBJ = CParticleAnimatedMeshSceneNodeEmitter.o CParticleBoxEmitter.o CParticleCylinderEmitter.o CParticleMeshEmitter.o CParticlePointEmitter.o CParticleRingEmitter.o CParticleSphereEmitter.o CParticleAttractionAffector.o CParticleFadeOutAffector.o CParticleGravityAffector.o CParticleRotationAffector.o CParticleSystemSceneNode.o CParticleScaleAffector.o
IRRANIMOBJ = CSceneNodeAnimatorCameraFPS.o CSceneNodeAnimatorCameraMaya.o CSceneNodeAnimatorCollisionResponse.o CSceneNodeAnimatorDelete.o CSceneNodeAnimatorFlyCircle.o CSceneNodeAnimatorFlyStraight.o CSceneNodeAnimatorFollowSpline.o CSceneNodeAnimatorRotation.o CSceneNodeAnimatorTexture.o
IRRDRVROBJ = CNullDriver.o COpenGLCacheHandler.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o
IRRDRVROBJ = CNullDriver.o COpenGLCacheHandler.o COpenGLDriver.o COpenGLNormalMapRenderer.o COpenGLParallaxMapRenderer.o COpenGLShaderMaterialRenderer.o COpenGLSLMaterialRenderer.o COpenGLExtensionHandler.o CD3D9Driver.o CD3D9HLSLMaterialRenderer.o CD3D9NormalMapRenderer.o CD3D9ParallaxMapRenderer.o CD3D9ShaderMaterialRenderer.o CD3D9Texture.o CGLXManager.o CWGLManager.o
IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CImageLoaderJPG.o CImageLoaderPCX.o CImageLoaderPNG.o CImageLoaderPSD.o CImageLoaderPVR.o CImageLoaderTGA.o CImageLoaderPPM.o CImageLoaderWAL.o CImageLoaderRGB.o \
CImageWriterBMP.o CImageWriterJPG.o CImageWriterPCX.o CImageWriterPNG.o CImageWriterPPM.o CImageWriterPSD.o CImageWriterTGA.o
IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)