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. // first param is the associated window.
// Must be a HWND for Windows (WIN32). // 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 // Must be called after a setDisplay that initialize the mode
virtual bool setMode(const GfxMode& mode)=0; virtual bool setMode(const GfxMode& mode)=0;
virtual bool getModes(std::vector<GfxMode> &modes)=0; virtual bool getModes(std::vector<GfxMode> &modes)=0;

View file

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

View file

@ -64,7 +64,7 @@ public:
* *
* You can access the driver with CNELU::Driver. * 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. /** Init all that we need for a Scene.
* - register scene basics models, * - register scene basics models,
@ -108,7 +108,7 @@ public:
* - initScene(); * - initScene();
* - initEventServer(); * - 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: /** Delete all:
* - releaseEventServer(); * - releaseEventServer();

View file

@ -178,7 +178,7 @@ public:
* \param show show or hide the window in window mode. * \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(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 setMode(const CMode& mode)=0;
virtual bool getModes(std::vector<CMode> &modes)=0; virtual bool getModes(std::vector<CMode> &modes)=0;
virtual bool getCurrentScreenMode(CMode &mode)=0; virtual bool getCurrentScreenMode(CMode &mode)=0;

View file

@ -33,6 +33,7 @@
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
# include <process.h> # include <process.h>
# include <intrin.h> # include <intrin.h>
# include <windows.h>
#else #else
# include <cmath> # include <cmath>
# include <unistd.h> # include <unistd.h>
@ -41,6 +42,13 @@
#include "string_common.h" #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 /// This namespace contains all miscellaneous classes used by other modules
namespace NLMISC 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" ) 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); H_AUTO_D3D(CDriver3D_setDisplay);
if (!_D3D) if (!_D3D)

View file

@ -737,7 +737,7 @@ public:
// Mode initialisation, requests // Mode initialisation, requests
virtual bool init (uint windowIcon = 0, emptyProc exitFunc = 0); 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 release();
virtual bool setMode(const GfxMode& mode); virtual bool setMode(const GfxMode& mode);
virtual bool getModes(std::vector<GfxMode> &modes); virtual bool getModes(std::vector<GfxMode> &modes);

View file

@ -98,7 +98,7 @@ uint CDriverGL::_Registered=0;
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
// Version of the driver. Not the interface version!! Increment when implementation of the driver change. // 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 // Number of register to allocate for the EXTVertexShader extension
const uint CDriverGL::_EVSNumConstant = 97; 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) 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"); nldebug("3D: glXCreateContext() OK");
} }
Colormap cmap = XCreateColormap (dpy, RootWindow(dpy, DefaultScreen(dpy)), visual_info->visual, AllocNone);
XSetWindowAttributes attr; XSetWindowAttributes attr;
attr.colormap = cmap;
attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy)); attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy));
#ifdef XF86VIDMODE #ifdef XF86VIDMODE
@ -1113,18 +1110,31 @@ bool CDriverGL::setDisplay(void *wnd, const GfxMode &mode, bool show, bool resiz
attr.override_redirect = False; attr.override_redirect = False;
#endif #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(wnd == EmptyWindow)
if(!win)
{ {
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 else
{ {
nldebug("3D: XCreateWindow() OK"); nldebug("3D: XCreateWindow() OK");
} }
}
else
{
win = wnd;
XChangeWindowAttributes(dpy, win, attr_flags, &attr);
}
XSizeHints size_hints; XSizeHints size_hints;
size_hints.x = 0; size_hints.x = 0;

View file

@ -283,7 +283,7 @@ public:
virtual void disableHardwareVertexArrayAGP(); virtual void disableHardwareVertexArrayAGP();
virtual void disableHardwareTextureShader(); 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 setMode(const GfxMode& mode);
virtual bool getModes(std::vector<GfxMode> &modes); virtual bool getModes(std::vector<GfxMode> &modes);
virtual bool getCurrentScreenMode(GfxMode &mode); 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; 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; NL3D_HAUTO_UI_DRIVER;

View file

@ -47,7 +47,7 @@ CEventServer CNELU::EventServer;
CEventListenerAsync CNELU::AsyncListener; 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 // Init debug system
// NLMISC::InitDebug(); // 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(); NL3D::registerSerial3d();
if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d)) if (initDriver(w,h,bpp,windowed,systemWindow,offscreen,direct3d))