Update: Merged in nlWindow patch from SVN.

This commit is contained in:
Matt Raykowski 2010-05-26 12:31:49 -05:00
parent 7c664c32f7
commit 10577effa0
12 changed files with 42 additions and 24 deletions

View file

@ -178,7 +178,7 @@ public:
// first param is the associated window.
// Must be a HWND for Windows (WIN32).
virtual bool setDisplay(void* wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay)=0;
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show = true, bool resizeable = true) throw(EBadDisplay)=0;
// Must be called after a setDisplay that initialize the mode
virtual bool setMode(const GfxMode& mode)=0;
virtual bool getModes(std::vector<GfxMode> &modes)=0;

View file

@ -138,7 +138,7 @@ public:
/// create the window.
virtual bool setDisplay(const CMode &mode, bool show, bool resizeable);
virtual bool setDisplay(void *wnd, const CMode &mode, bool show, bool resizeable);
virtual bool setDisplay(nlWindow wnd, const CMode &mode, bool show, bool resizeable);
virtual bool setMode(const CMode& mode);
virtual bool getModes(std::vector<CMode> &modes);
virtual bool getCurrentScreenMode(CMode &mode);

View file

@ -64,7 +64,7 @@ public:
*
* You can access the driver with CNELU::Driver.
*/
static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, void *systemWindow=NULL, bool offscreen=false, bool direct3d=false) throw(EDru);
static bool initDriver(uint w, uint h, uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen=false, bool direct3d=false) throw(EDru);
/** Init all that we need for a Scene.
* - register scene basics models,
@ -108,7 +108,7 @@ public:
* - initScene();
* - initEventServer();
*/
static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, void *systemWindow=NULL, bool offscreen = false, bool direct3d = false) throw(EDru);
static bool init(uint w, uint h, CViewport viewport=CViewport(), uint bpp=32, bool windowed=true, nlWindow systemWindow=EmptyWindow, bool offscreen = false, bool direct3d = false) throw(EDru);
/** Delete all:
* - releaseEventServer();

View file

@ -178,7 +178,7 @@ public:
* \param show show or hide the window in window mode.
*/
virtual bool setDisplay(const CMode &mode, bool show = true, bool resizeable = true) =0;
virtual bool setDisplay(void *wnd, const CMode &mode, bool show = true, bool resizeable = true) =0;
virtual bool setDisplay(nlWindow wnd, const CMode &mode, bool show = true, bool resizeable = true) =0;
virtual bool setMode(const CMode& mode)=0;
virtual bool getModes(std::vector<CMode> &modes)=0;
virtual bool getCurrentScreenMode(CMode &mode)=0;

View file

@ -33,6 +33,7 @@
#ifdef NL_OS_WINDOWS
# include <process.h>
# include <intrin.h>
# include <windows.h>
#else
# include <cmath>
# include <unistd.h>
@ -41,6 +42,13 @@
#include "string_common.h"
#ifdef NL_OS_WINDOWS
typedef HWND nlWindow;
#define EmptyWindow NULL
#else
typedef int nlWindow;
#define EmptyWindow 0
#endif
/// This namespace contains all miscellaneous classes used by other modules
namespace NLMISC

View file

@ -34,7 +34,7 @@ namespace NL3D
{
// ***************************************************************************
const uint32 IDriver::InterfaceVersion = 0x63; // added supportNonPowerOfTwoTextures()
const uint32 IDriver::InterfaceVersion = 0x64; // Added nlWindow patch.
// ***************************************************************************
IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" )

View file

@ -1295,7 +1295,7 @@ const D3DFORMAT FinalPixelFormat[ITexture::UploadFormatCount][CDriverD3D::FinalP
// ***************************************************************************
bool CDriverD3D::setDisplay(void* wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay)
bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay)
{
H_AUTO_D3D(CDriver3D_setDisplay);
if (!_D3D)

View file

@ -737,7 +737,7 @@ public:
// Mode initialisation, requests
virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0);
virtual bool setDisplay(void* wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool release();
virtual bool setMode(const GfxMode& mode);
virtual bool getModes(std::vector<GfxMode> &modes);

View file

@ -98,7 +98,7 @@ uint CDriverGL::_Registered=0;
#endif // NL_OS_WINDOWS
// Version of the driver. Not the interface version!! Increment when implementation of the driver change.
const uint32 CDriverGL::ReleaseVersion = 0xf;
const uint32 CDriverGL::ReleaseVersion = 0x10;
// Number of register to allocate for the EXTVertexShader extension
const uint CDriverGL::_EVSNumConstant = 97;
@ -551,7 +551,7 @@ void CDriverGL::disableHardwareTextureShader()
// --------------------------------------------------
bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay)
bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool resizeable) throw(EBadDisplay)
{
H_AUTO_OGL(CDriverGL_setDisplay)
@ -1091,10 +1091,7 @@ bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resiz
nldebug("3D: glXCreateContext() OK");
}
Colormap cmap = XCreateColormap (dpy, RootWindow(dpy, DefaultScreen(dpy)), visual_info->visual, AllocNone);
XSetWindowAttributes attr;
attr.colormap = cmap;
attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy));
#ifdef XF86VIDMODE
@ -1113,18 +1110,31 @@ bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resiz
attr.override_redirect = False;
#endif
int attr_flags = CWOverrideRedirect | CWColormap | CWBackPixel;
int attr_flags = CWOverrideRedirect | CWBackPixel;
win = XCreateWindow (dpy, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr);
if(!win)
if(wnd == EmptyWindow)
{
nlerror("XCreateWindow() failed");
nlWindow root = RootWindow(dpy, DefaultScreen(dpy));
attr.colormap = XCreateColormap(dpy, root, visual_info->visual, AllocNone);
attr_flags |= CWColormap;
win = XCreateWindow (dpy, root, 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr);
if (win == EmptyWindow)
{
nlerror("3D: XCreateWindow() failed");
}
else
{
nldebug("3D: XCreateWindow() OK");
}
}
else
{
win = wnd;
XChangeWindowAttributes(dpy, win, attr_flags, &attr);
}
XSizeHints size_hints;
size_hints.x = 0;

View file

@ -283,7 +283,7 @@ public:
virtual void disableHardwareVertexArrayAGP();
virtual void disableHardwareTextureShader();
virtual bool setDisplay(void* wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeable) throw(EBadDisplay);
virtual bool setMode(const GfxMode& mode);
virtual bool getModes(std::vector<GfxMode> &modes);
virtual bool getCurrentScreenMode(GfxMode &mode);

View file

@ -224,11 +224,11 @@ bool CDriverUser::setDisplay(const CMode &mode, bool show, bool resizeable)
{
NL3D_HAUTO_UI_DRIVER;
return setDisplay(NULL, mode, show, resizeable);
return setDisplay(EmptyWindow, mode, show, resizeable);
}
// ***************************************************************************
bool CDriverUser::setDisplay(void *wnd, const CMode &mode, bool show, bool resizeable)
bool CDriverUser::setDisplay(nlWindow wnd, const CMode &mode, bool show, bool resizeable)
{
NL3D_HAUTO_UI_DRIVER;

View file

@ -47,7 +47,7 @@ CEventServer CNELU::EventServer;
CEventListenerAsync CNELU::AsyncListener;
bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, void *systemWindow, bool offscreen, bool direct3d) throw(EDru)
bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru)
{
// Init debug system
// NLMISC::InitDebug();
@ -174,7 +174,7 @@ void CNELU::releaseDriver()
}
}
bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, void *systemWindow, bool offscreen, bool direct3d) throw(EDru)
bool CNELU::init (uint w, uint h, CViewport viewport, uint bpp, bool windowed, nlWindow systemWindow, bool offscreen, bool direct3d) throw(EDru)
{
NL3D::registerSerial3d();
if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d))