Changed: #970 Move all window and input related methods to a new file from OpenGL driver

This commit is contained in:
kervala 2010-06-12 15:34:20 +02:00
parent a6d55108f2
commit d16356fefe
7 changed files with 346 additions and 290 deletions

View file

@ -207,9 +207,9 @@ CDriverGL::CDriverGL()
NL3D::MAC::ctor(); NL3D::MAC::ctor();
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
cursor = None; _cursor = None;
win = 0; _win = 0;
dpy = 0; _dpy = 0;
# ifdef XF86VIDMODE # ifdef XF86VIDMODE
// zero the old screen mode // zero the old screen mode
@ -220,6 +220,7 @@ CDriverGL::CDriverGL()
_OffScreen = false; _OffScreen = false;
_FullScreen = false; _FullScreen = false;
_Resizable = false;
_CurrentMaterial=NULL; _CurrentMaterial=NULL;
_Initialized = false; _Initialized = false;
@ -341,72 +342,6 @@ CDriverGL::~CDriverGL()
#endif #endif
} }
// ***************************************************************************
bool CDriverGL::stretchRect(ITexture * /* srcText */, NLMISC::CRect &/* srcRect */, ITexture * /* destText */, NLMISC::CRect &/* destRect */)
{
H_AUTO_OGL(CDriverGL_stretchRect)
return false;
}
// ***************************************************************************
bool CDriverGL::supportBloomEffect() const
{
return (isVertexProgramSupported() && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle());
}
// ***************************************************************************
bool CDriverGL::supportNonPowerOfTwoTextures() const
{
return _Extensions.ARBTextureNonPowerOfTwo;
}
// ***************************************************************************
bool CDriverGL::isTextureRectangle(ITexture * tex) const
{
return (supportTextureRectangle() && tex->isBloomTexture() && tex->mipMapOff()
&& (!isPowerOf2(tex->getWidth()) || !isPowerOf2(tex->getHeight())));
}
// ***************************************************************************
bool CDriverGL::activeFrameBufferObject(ITexture * tex)
{
if(supportFrameBufferObject()/* && supportPackedDepthStencil()*/)
{
if(tex)
{
CTextureDrvInfosGL* gltext = (CTextureDrvInfosGL*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture);
return gltext->activeFrameBufferObject(tex);
}
else
{
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return true;
}
}
return false;
}
// --------------------------------------------------
void CDriverGL::disableHardwareVertexProgram()
{
H_AUTO_OGL(CDriverGL_disableHardwareVertexProgram)
_Extensions.DisableHardwareVertexProgram= true;
}
void CDriverGL::disableHardwareVertexArrayAGP()
{
H_AUTO_OGL(CDriverGL_disableHardwareVertexArrayAGP)
_Extensions.DisableHardwareVertexArrayAGP= true;
}
void CDriverGL::disableHardwareTextureShader()
{
H_AUTO_OGL(CDriverGL_disableHardwareTextureShader)
_Extensions.DisableHardwareTextureShader= true;
}
// -------------------------------------------------- // --------------------------------------------------
bool CDriverGL::setupDisplay() bool CDriverGL::setupDisplay()
{ {
@ -682,6 +617,74 @@ bool CDriverGL::setupDisplay()
return true; return true;
} }
// ***************************************************************************
bool CDriverGL::stretchRect(ITexture * /* srcText */, NLMISC::CRect &/* srcRect */, ITexture * /* destText */, NLMISC::CRect &/* destRect */)
{
H_AUTO_OGL(CDriverGL_stretchRect)
return false;
}
// ***************************************************************************
bool CDriverGL::supportBloomEffect() const
{
return (isVertexProgramSupported() && supportFrameBufferObject() && supportPackedDepthStencil() && supportTextureRectangle());
}
// ***************************************************************************
bool CDriverGL::supportNonPowerOfTwoTextures() const
{
return _Extensions.ARBTextureNonPowerOfTwo;
}
// ***************************************************************************
bool CDriverGL::isTextureRectangle(ITexture * tex) const
{
return (supportTextureRectangle() && tex->isBloomTexture() && tex->mipMapOff()
&& (!isPowerOf2(tex->getWidth()) || !isPowerOf2(tex->getHeight())));
}
// ***************************************************************************
bool CDriverGL::activeFrameBufferObject(ITexture * tex)
{
if(supportFrameBufferObject()/* && supportPackedDepthStencil()*/)
{
if(tex)
{
CTextureDrvInfosGL* gltext = (CTextureDrvInfosGL*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture);
return gltext->activeFrameBufferObject(tex);
}
else
{
nglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return true;
}
}
return false;
}
// --------------------------------------------------
void CDriverGL::disableHardwareVertexProgram()
{
H_AUTO_OGL(CDriverGL_disableHardwareVertexProgram)
_Extensions.DisableHardwareVertexProgram= true;
}
// ***************************************************************************
void CDriverGL::disableHardwareVertexArrayAGP()
{
H_AUTO_OGL(CDriverGL_disableHardwareVertexArrayAGP)
_Extensions.DisableHardwareVertexArrayAGP= true;
}
// ***************************************************************************
void CDriverGL::disableHardwareTextureShader()
{
H_AUTO_OGL(CDriverGL_disableHardwareTextureShader)
_Extensions.DisableHardwareTextureShader= true;
}
// -------------------------------------------------- // --------------------------------------------------
void CDriverGL::resetTextureShaders() void CDriverGL::resetTextureShaders()
{ {
@ -863,7 +866,7 @@ bool CDriverGL::swapBuffers()
NL3D::MAC::swapBuffers(); NL3D::MAC::swapBuffers();
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
glXSwapBuffers(dpy, win); glXSwapBuffers(_dpy, _win);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
@ -977,7 +980,7 @@ bool CDriverGL::release()
if(_FullScreen) if(_FullScreen)
{ {
switchBackToOldMode(); restoreScreenMode();
_FullScreen= false; _FullScreen= false;
} }
} }
@ -1010,24 +1013,24 @@ bool CDriverGL::release()
NL3D::MAC::release(); NL3D::MAC::release();
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
if(_FullScreen) if (_FullScreen)
{ {
switchBackToOldMode(); restoreScreenMode();
// Ungrab the keyboard (probably not necessary); // Ungrab the keyboard (probably not necessary);
XUnmapWindow(dpy, win); XUnmapWindow(_dpy, _win);
XSync(dpy, True); XSync(_dpy, True);
XUngrabKeyboard(dpy, CurrentTime); XUngrabKeyboard(_dpy, CurrentTime);
} }
if (ctx) if (_ctx)
{ {
glXDestroyContext(dpy, ctx); glXDestroyContext(_dpy, _ctx);
ctx = NULL; _ctx = NULL;
} }
XCloseDisplay(dpy); XCloseDisplay(_dpy);
dpy = NULL; _dpy = NULL;
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
@ -1056,7 +1059,7 @@ void CDriverGL::setupViewport (const class CViewport& viewport)
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
XWindowAttributes win_attributes; XWindowAttributes win_attributes;
if (!XGetWindowAttributes(dpy, win, &win_attributes)) if (!XGetWindowAttributes(_dpy, _win, &win_attributes))
throw EBadDisplay("Can't get window attributes."); throw EBadDisplay("Can't get window attributes.");
// Setup gl viewport // Setup gl viewport
@ -1130,7 +1133,7 @@ void CDriverGL::setupScissor (const class CScissor& scissor)
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
XWindowAttributes win_attributes; XWindowAttributes win_attributes;
if (!XGetWindowAttributes(dpy, win, &win_attributes)) if (!XGetWindowAttributes(_dpy, _win, &win_attributes))
throw EBadDisplay("Can't get window attributes."); throw EBadDisplay("Can't get window attributes.");
// Setup gl viewport // Setup gl viewport
@ -2729,7 +2732,7 @@ void CDriverGL::stencilFunc(TStencilFunc stencilFunc, int ref, uint mask)
{ {
H_AUTO_OGL(CDriverGL_CDriverGL) H_AUTO_OGL(CDriverGL_CDriverGL)
GLenum glstencilFunc; GLenum glstencilFunc = 0;
switch(stencilFunc) switch(stencilFunc)
{ {
@ -2752,7 +2755,7 @@ void CDriverGL::stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass)
{ {
H_AUTO_OGL(CDriverGL_CDriverGL) H_AUTO_OGL(CDriverGL_CDriverGL)
GLenum glFail, glZFail, glZPass; GLenum glFail = 0, glZFail = 0, glZPass = 0;
switch(fail) switch(fail)
{ {

View file

@ -310,7 +310,7 @@ public:
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
return NULL; return NULL;
#elif defined(NL_OS_UNIX) #elif defined(NL_OS_UNIX)
return win; return _win;
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
} }
@ -659,6 +659,7 @@ private:
bool _FullScreen; bool _FullScreen;
bool _OffScreen; bool _OffScreen;
bool _Resizable;
uint _Interval; uint _Interval;
sint32 _WindowWidth, _WindowHeight, _WindowX, _WindowY; sint32 _WindowWidth, _WindowHeight, _WindowX, _WindowY;
@ -684,16 +685,16 @@ private:
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
Display *dpy; Display* _dpy;
GLXContext ctx; GLXContext _ctx;
Window win; Window _win;
Cursor cursor; Cursor _cursor;
NLMISC::CUnixEventEmitter _EventEmitter; NLMISC::CUnixEventEmitter _EventEmitter;
#ifdef XF86VIDMODE #ifdef XF86VIDMODE
int _OldDotClock; // old dotclock int _OldDotClock; // old dotclock
XF86VidModeModeLine _OldScreenMode; // old modeline XF86VidModeModeLine _OldScreenMode; // old modeline
int _OldX, _OldY; //Viewport settings int _OldX, _OldY; //Viewport settings
#endif //XF86VIDMODE #endif //XF86VIDMODE
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
@ -841,9 +842,11 @@ private:
bool _CurrentGlNormalize; bool _CurrentGlNormalize;
private: private:
void switchBackToOldMode();
bool setupDisplay(); bool setupDisplay();
bool restoreScreenMode();
bool saveScreenMode();
// Get the proj matrix setupped in GL // Get the proj matrix setupped in GL
void refreshProjMatrixFromGL(); void refreshProjMatrixFromGL();

View file

@ -416,9 +416,9 @@ PFNWGLFREEMEMORYNVPROC nwglFreeMemoryNV;
// Pbuffer extension // Pbuffer extension
PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB; PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB;
PFNWGLGETPUFFERDCARBPROC nwglGetPbufferDCARB; PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB;
PFNWGLRELEASEPUFFERDCARBPROC nwglReleasePbufferDCARB; PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB;
PFNWGLDESTROYPUFFERARBPROC nwglDestroyPbufferARB; PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB;
PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB; PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB;
// Get Pixel format extension // Get Pixel format extension
@ -431,10 +431,9 @@ PFNWGLSWAPINTERVALEXTPROC nwglSwapIntervalEXT;
PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT; PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT;
// WGL_ARB_extensions_string // WGL_ARB_extensions_string
PFNWGFGETEXTENSIONSSTRINGARB nwglGetExtensionsStringARB; PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB;
#endif #endif
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************
@ -857,9 +856,9 @@ static bool setupWGLARBPBuffer(const char *glext)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
CHECK_ADDRESS(PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB); CHECK_ADDRESS(PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB);
CHECK_ADDRESS(PFNWGLGETPUFFERDCARBPROC, wglGetPbufferDCARB); CHECK_ADDRESS(PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB);
CHECK_ADDRESS(PFNWGLRELEASEPUFFERDCARBPROC, wglReleasePbufferDCARB); CHECK_ADDRESS(PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB);
CHECK_ADDRESS(PFNWGLDESTROYPUFFERARBPROC, wglDestroyPbufferARB); CHECK_ADDRESS(PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB);
CHECK_ADDRESS(PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB); CHECK_ADDRESS(PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB);
#endif #endif
@ -1411,7 +1410,7 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
{ {
H_AUTO_OGL(registerWGlExtensions); H_AUTO_OGL(registerWGlExtensions);
// Get proc address // Get proc address
CHECK_ADDRESS(PFNWGFGETEXTENSIONSSTRINGARB, wglGetExtensionsStringARB); CHECK_ADDRESS(PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB);
// Get extension string // Get extension string
const char *glext = nwglGetExtensionsStringARB (hDC); const char *glext = nwglGetExtensionsStringARB (hDC);

View file

@ -158,7 +158,15 @@ public:
ARBFragmentProgram = false; ARBFragmentProgram = false;
ARBVertexBufferObject = false; ARBVertexBufferObject = false;
ARBVertexProgram = false; ARBVertexProgram = false;
NVTextureRectangle = false;
EXTTextureRectangle = false;
ARBTextureRectangle = false;
ARBTextureNonPowerOfTwo = false; ARBTextureNonPowerOfTwo = false;
NVOcclusionQuery = false;
FrameBufferObject = false;
PackedDepthStencil = false;
NVVertexArrayRange2 = false;
NVStateVARWithoutFlush = 0;
/// \name Disable Hardware feature. False by default. setuped by IDriver /// \name Disable Hardware feature. False by default. setuped by IDriver
DisableHardwareVertexProgram= false; DisableHardwareVertexProgram= false;
@ -167,6 +175,7 @@ public:
// misc // misc
IsATI9500OrAbove = false; IsATI9500OrAbove = false;
IsGeforceFXOrAbove = false;
}; };
std::string toString() std::string toString()
@ -643,9 +652,9 @@ extern NEL_PFNGLGETOCCLUSIONQUERYUIVNVPROC nglGetOcclusionQueryuivNV;
// Pbuffer extension // Pbuffer extension
//================== //==================
extern PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB; extern PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB;
extern PFNWGLGETPUFFERDCARBPROC nwglGetPbufferDCARB; extern PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB;
extern PFNWGLRELEASEPUFFERDCARBPROC nwglReleasePbufferDCARB; extern PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB;
extern PFNWGLDESTROYPUFFERARBPROC nwglDestroyPbufferARB; extern PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB;
extern PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB; extern PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB;
@ -663,7 +672,7 @@ extern PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT;
// WGL_ARB_extensions_string // WGL_ARB_extensions_string
extern PFNWGFGETEXTENSIONSSTRINGARB nwglGetExtensionsStringARB; extern PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB;
#endif #endif

View file

@ -55,9 +55,9 @@ DECLARE_HANDLE (HPBUFFERARB);
typedef void *(APIENTRY * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); typedef void *(APIENTRY * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority);
typedef void *(APIENTRY * PFNWGLFREEMEMORYNVPROC) (void *pointer); typedef void *(APIENTRY * PFNWGLFREEMEMORYNVPROC) (void *pointer);
typedef HPBUFFERARB (APIENTRY * PFNWGLCREATEPBUFFERARBPROC) (HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HPBUFFERARB (APIENTRY * PFNWGLCREATEPBUFFERARBPROC) (HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (APIENTRY * PFNWGLGETPUFFERDCARBPROC) (HPBUFFERARB hPbuffer); typedef HDC (APIENTRY * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (APIENTRY * PFNWGLRELEASEPUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC); typedef int (APIENTRY * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC);
typedef BOOL (APIENTRY * PFNWGLDESTROYPUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (APIENTRY * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (APIENTRY * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); typedef BOOL (APIENTRY * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
typedef BOOL (APIENTRY * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC, int, int, UINT, const int *, int *); typedef BOOL (APIENTRY * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC, int, int, UINT, const int *, int *);
@ -67,7 +67,7 @@ typedef BOOL (APIENTRY * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC, const int *, con
typedef BOOL (APIENTRY * PFNWGLSWAPINTERVALEXTPROC) (int); typedef BOOL (APIENTRY * PFNWGLSWAPINTERVALEXTPROC) (int);
typedef int (APIENTRY * PFNWGLGETSWAPINTERVALEXTPROC) (void); typedef int (APIENTRY * PFNWGLGETSWAPINTERVALEXTPROC) (void);
typedef const char* (APIENTRY * PFNWGFGETEXTENSIONSSTRINGARB) (HDC); typedef const char* (APIENTRY * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC);
#endif #endif

View file

@ -53,15 +53,19 @@ CTextureDrvInfosGL::CTextureDrvInfosGL(IDriver *drv, ItTexDrvInfoPtrMap it, CDri
// The id is auto created here. // The id is auto created here.
glGenTextures(1,&ID); glGenTextures(1,&ID);
Compressed= false; Compressed = false;
MipMap= false; MipMap = false;
TextureMemory= 0; TextureMemory = 0;
// Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid. // Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid.
_Driver= drvGl; _Driver= drvGl;
TextureMode = isRectangleTexture?GL_TEXTURE_RECTANGLE_NV:GL_TEXTURE_2D; TextureMode = isRectangleTexture?GL_TEXTURE_RECTANGLE_NV:GL_TEXTURE_2D;
FBOId = 0;
DepthFBOId = 0;
StencilFBOId = 0;
InitFBO = false; InitFBO = false;
AttachDepthStencil = true; AttachDepthStencil = true;
UsePackedDepthStencil = drvGl->supportPackedDepthStencil(); UsePackedDepthStencil = drvGl->supportPackedDepthStencil();
@ -157,33 +161,41 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
InitFBO = true; InitFBO = true;
break; break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
nlwarning("Unsupported framebuffer format\n"); nlwarning("Unsupported framebuffer format");
break; break;
#if GL_GLEXT_VERSION > 24 #ifdef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
nlwarning("Framebuffer incomplete attachment\n"); nlwarning("Framebuffer incomplete attachment");
break; break;
#endif #endif
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
nlwarning("Framebuffer incomplete, missing attachment\n"); nlwarning("Framebuffer incomplete, missing attachment");
break; break;
#if GL_GLEXT_VERSION < 39 #ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT
case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
nlwarning("Framebuffer incomplete, duplicate attachment\n"); nlwarning("Framebuffer incomplete, duplicate attachment");
break; break;
#endif #endif
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
nlwarning("Framebuffer incomplete, attached images must have same dimensions\n"); nlwarning("Framebuffer incomplete, attached images must have same dimensions");
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
nlwarning("Framebuffer incomplete, attached images must have same format\n"); nlwarning("Framebuffer incomplete, attached images must have same format");
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
nlwarning("Framebuffer incomplete, missing draw buffer\n"); nlwarning("Framebuffer incomplete, missing draw buffer");
break; break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
nlwarning("Framebuffer incomplete, missing read buffer\n"); nlwarning("Framebuffer incomplete, missing read buffer");
break; break;
case GL_FRAMEBUFFER_BINDING_EXT:
nlwarning("Framebuffer BINDING_EXT");
break;
#ifdef GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
nlwarning("Framebuffer incomplete multisample");
break;
#endif
default: default:
nlwarning("Framebuffer incomplete\n"); nlwarning("Framebuffer incomplete\n");
//nlassert(0); //nlassert(0);
@ -237,7 +249,6 @@ static inline CTextureDrvInfosGL* getTextureGl(ITexture& tex)
return gltex; return gltex;
} }
// *************************************************************************** // ***************************************************************************
// Translation of TexFmt mode. // Translation of TexFmt mode.
GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed) GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
@ -268,7 +279,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
} }
} }
// Get gl tex format, try S3TC compressed ones. // Get gl tex format, try S3TC compressed ones.
if(_Extensions.EXTTextureCompressionS3TC) if(_Extensions.EXTTextureCompressionS3TC)
{ {
@ -284,7 +294,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
} }
} }
// Get standard gl tex format. // Get standard gl tex format.
compressed= false; compressed= false;
switch(texfmt) switch(texfmt)
@ -313,7 +322,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
} }
} }
// *************************************************************************** // ***************************************************************************
static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt) static GLint getGlSrcTextureFormat(ITexture &tex, GLint glfmt)
{ {
@ -392,7 +400,6 @@ uint CDriverGL::computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const
return w*h* 4; return w*h* 4;
} }
// *************************************************************************** // ***************************************************************************
// Translation of Wrap mode. // Translation of Wrap mode.
static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtensions &extensions) static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtensions &extensions)
@ -409,7 +416,6 @@ static inline GLenum translateWrapToGl(ITexture::TWrapMode mode, const CGlExtens
} }
} }
// *************************************************************************** // ***************************************************************************
static inline GLenum translateMagFilterToGl(CTextureDrvInfosGL *glText) static inline GLenum translateMagFilterToGl(CTextureDrvInfosGL *glText)
{ {
@ -472,7 +478,6 @@ static inline GLenum translateMinFilterToGl(CTextureDrvInfosGL *glText)
#endif // NEL_FORCE_NEAREST #endif // NEL_FORCE_NEAREST
} }
// *************************************************************************** // ***************************************************************************
static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt) static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
{ {
@ -489,7 +494,6 @@ static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
static inline bool isDXTCFormat(GLint glfmt) static inline bool isDXTCFormat(GLint glfmt)
{ {
@ -506,7 +510,6 @@ static inline bool isDXTCFormat(GLint glfmt)
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
bool CDriverGL::setupTexture (ITexture& tex) bool CDriverGL::setupTexture (ITexture& tex)
{ {
@ -515,8 +518,6 @@ bool CDriverGL::setupTexture (ITexture& tex)
return setupTextureEx (tex, true, nTmp); return setupTextureEx (tex, true, nTmp);
} }
// *************************************************************************** // ***************************************************************************
#ifndef NL_DEBUG #ifndef NL_DEBUG
inline inline
@ -624,15 +625,12 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
return true; // Do not do anything return true; // Do not do anything
} }
// 1. If modified, may (re)load texture part or all of the texture. // 1. If modified, may (re)load texture part or all of the texture.
//================================================================= //=================================================================
bool mustLoadAll= false; bool mustLoadAll= false;
bool mustLoadPart= false; bool mustLoadPart= false;
// To avoid any delete/new ptr problem, disable all texturing. // To avoid any delete/new ptr problem, disable all texturing.
/* If an old texture is deleted, _CurrentTexture[*] and _CurrentTextureInfoGL[*] are invalid. /* If an old texture is deleted, _CurrentTexture[*] and _CurrentTextureInfoGL[*] are invalid.
But this is grave only if a new texture is created, with the same pointer (bad luck). But this is grave only if a new texture is created, with the same pointer (bad luck).
@ -643,7 +641,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
activateTexture(stage, NULL); activateTexture(stage, NULL);
} }
// A. Share mgt. // A. Share mgt.
//============== //==============
if(tex.supportSharing()) if(tex.supportSharing())
@ -786,7 +783,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
glTexImage2D (NLCubeFaceToGLCubeFace[nText], i, glfmt, w, h, 0, glSrcFmt, glSrcType, ptr); glTexImage2D (NLCubeFaceToGLCubeFace[nText], i, glfmt, w, h, 0, glSrcFmt, glSrcType, ptr);
bAllUploaded = true; bAllUploaded = true;
NEL_MEASURE_UPLOAD_TIME_END NEL_MEASURE_UPLOAD_TIME_END
} }
else else
{ {
@ -915,7 +911,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
} }
//printf("%d,%d,%d\n", tex.getMipMapCount(), tex.getWidth(0), tex.getHeight(0)); //printf("%d,%d,%d\n", tex.getMipMapCount(), tex.getWidth(0), tex.getHeight(0));
// profiling. add new TextureMemory usage. // profiling. add new TextureMemory usage.
_AllocatedTextureMemory+= gltext->TextureMemory; _AllocatedTextureMemory+= gltext->TextureMemory;
} }
@ -983,8 +978,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
else else
glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL); glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL);
// Next mipmap!! // Next mipmap!!
// floor . // floor .
x0= x0/2; x0= x0/2;
@ -999,12 +992,9 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
} }
} }
// Release, if wanted. // Release, if wanted.
if(tex.getReleasable()) if(tex.getReleasable())
tex.release(); tex.release();
@ -1019,13 +1009,11 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
_DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled); _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
} }
// The texture is correctly setuped. // The texture is correctly setuped.
tex.clearTouched(); tex.clearTouched();
return true; return true;
} }
// *************************************************************************** // ***************************************************************************
bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap) bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
{ {
@ -1067,14 +1055,11 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
bool dummy; bool dummy;
GLint glfmt = getGlTextureFormat (tex, dummy); GLint glfmt = getGlTextureFormat (tex, dummy);
GLint glSrcFmt = getGlSrcTextureFormat (tex, glfmt); GLint glSrcFmt = getGlSrcTextureFormat (tex, glfmt);
GLenum glSrcType= getGlSrcTextureComponentType(glSrcFmt); GLenum glSrcType= getGlSrcTextureComponentType(glSrcFmt);
// If DXTC format // If DXTC format
if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt)) if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt))
{ {
@ -1116,7 +1101,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
return false; return false;
} }
nlassert (((x0&3) == 0) && ((y0&3) == 0)); nlassert (((x0&3) == 0) && ((y0&3) == 0));
if ((w>=4) && (h>=4)) if ((w>=4) && (h>=4))
{ {
@ -1132,8 +1116,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
nglCompressedTexImage2DARB (GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, nglCompressedTexImage2DARB (GL_TEXTURE_2D, nNumMipMap-decalMipMapResize,
glfmt, w, h, 0, imageSize, ptr); glfmt, w, h, 0, imageSize, ptr);
} }
} }
else else
{ {
@ -1150,8 +1132,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
} }
// Disable texture 0 // Disable texture 0
@ -1195,7 +1175,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
_TextureUsed.insert (gltext); _TextureUsed.insert (gltext);
} }
if(tex->isTextureCube()) if(tex->isTextureCube())
{ {
// setup texture mode, after activeTextureARB() // setup texture mode, after activeTextureARB()
@ -1215,7 +1194,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
// setup this texture // setup this texture
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
// Change parameters of texture, if necessary. // Change parameters of texture, if necessary.
//============================================ //============================================
if(gltext->MagFilter!= tex->getMagFilter()) if(gltext->MagFilter!= tex->getMagFilter())
@ -1228,8 +1206,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
gltext->MinFilter= tex->getMinFilter(); gltext->MinFilter= tex->getMinFilter();
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext)); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
} }
} }
} }
} }
@ -1320,7 +1296,6 @@ static void forceActivateTexEnvModeEnvCombine4(const CMaterial::CTexEnv &env)
H_AUTO_OGL(forceActivateTexEnvModeEnvCombine4) H_AUTO_OGL(forceActivateTexEnvModeEnvCombine4)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
//== RGB == //== RGB ==
switch(env.Env.OpRGB) switch(env.Env.OpRGB)
{ {
@ -1683,7 +1658,6 @@ void CDriverGL::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &
//===== //=====
if (env.Env.OpAlpha == CMaterial::Mad) if (env.Env.OpAlpha == CMaterial::Mad)
{ {
if (_Extensions.ATITextureEnvCombine3) if (_Extensions.ATITextureEnvCombine3)
{ {
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATI);
@ -1737,12 +1711,8 @@ void CDriverGL::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &
{ {
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGL::activateTexEnvColor(uint stage, NLMISC::CRGBA col) void CDriverGL::activateTexEnvColor(uint stage, NLMISC::CRGBA col)
{ {
@ -1753,7 +1723,6 @@ void CDriverGL::activateTexEnvColor(uint stage, NLMISC::CRGBA col)
} }
} }
// *************************************************************************** // ***************************************************************************
void CDriverGL::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env) void CDriverGL::activateTexEnvMode(uint stage, const CMaterial::CTexEnv &env)
{ {
@ -1825,7 +1794,13 @@ void CDriverGL::swapTextureHandle(ITexture &tex0, ITexture &tex1)
swap(t0->WrapT, t1->WrapT); swap(t0->WrapT, t1->WrapT);
swap(t0->MagFilter, t1->MagFilter); swap(t0->MagFilter, t1->MagFilter);
swap(t0->MinFilter, t1->MinFilter); swap(t0->MinFilter, t1->MinFilter);
swap(t0->TextureMode, t1->TextureMode);
swap(t0->FBOId, t1->FBOId);
swap(t0->DepthFBOId, t1->DepthFBOId);
swap(t0->StencilFBOId, t1->StencilFBOId);
swap(t0->InitFBO, t1->InitFBO);
swap(t0->AttachDepthStencil, t1->AttachDepthStencil);
swap(t0->UsePackedDepthStencil, t1->UsePackedDepthStencil);
} }
@ -1879,6 +1854,7 @@ bool CDriverGL::setRenderTarget (ITexture *tex, uint32 x, uint32 y, uint32 width
getWindowSize(w, h); getWindowSize(w, h);
getViewport(_OldViewport); getViewport(_OldViewport);
CViewport newVP; CViewport newVP;
newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h)); newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h));
setupViewport(newVP); setupViewport(newVP);
@ -1972,7 +1948,7 @@ bool CDriverGL::getRenderTargetSize (uint32 &width, uint32 &height)
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
XWindowAttributes win_attributes; XWindowAttributes win_attributes;
if (!XGetWindowAttributes(dpy, win, &win_attributes)) if (!XGetWindowAttributes(_dpy, _win, &win_attributes))
throw EBadDisplay("Can't get window attributes."); throw EBadDisplay("Can't get window attributes.");
// Setup gl viewport // Setup gl viewport

View file

@ -153,7 +153,7 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc)
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL); wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = (HICON)windowIcon; wc.hIcon = (HICON)windowIcon;
wc.hCursor = LoadCursorW(NULL,(LPCWSTR)IDC_ARROW); wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
wc.hbrBackground = WHITE_BRUSH; wc.hbrBackground = WHITE_BRUSH;
wc.lpszClassName = L"NLClass"; wc.lpszClassName = L"NLClass";
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
@ -186,8 +186,9 @@ bool CDriverGL::init (uint windowIcon, emptyProc exitFunc)
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
dpy = XOpenDisplay(NULL); _dpy = XOpenDisplay(NULL);
if (dpy == NULL)
if (_dpy == NULL)
{ {
nlerror ("XOpenDisplay failed on '%s'", getenv("DISPLAY")); nlerror ("XOpenDisplay failed on '%s'", getenv("DISPLAY"));
} }
@ -656,9 +657,12 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
{ {
_EventEmitter.removeEmitter(_EventEmitter.getEmitter(_EventEmitter.getNumEmitters() - 1)); _EventEmitter.removeEmitter(_EventEmitter.getEmitter(_EventEmitter.getNumEmitters() - 1));
} }
NLMISC::CWinEventEmitter *we = new NLMISC::CWinEventEmitter; NLMISC::CWinEventEmitter *we = new NLMISC::CWinEventEmitter;
// setup the event emitter, and try to retrieve a direct input interface // setup the event emitter, and try to retrieve a direct input interface
_EventEmitter.addEmitter(we, true /*must delete*/); // the main emitter _EventEmitter.addEmitter(we, true /*must delete*/); // the main emitter
/// try to get direct input /// try to get direct input
try try
{ {
@ -706,56 +710,44 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
}; };
// first try 24bpp and if that fails 16bpp // first try 24bpp and if that fails 16bpp
XVisualInfo *visual_info = glXChooseVisual (dpy, DefaultScreen(dpy), sAttribList24bpp); XVisualInfo *visual_info = glXChooseVisual (_dpy, DefaultScreen(_dpy), sAttribList24bpp);
if (visual_info == NULL) if (visual_info == NULL)
visual_info = glXChooseVisual(dpy, DefaultScreen(dpy), sAttribList16bpp); visual_info = glXChooseVisual(_dpy, DefaultScreen(_dpy), sAttribList16bpp);
if(visual_info == NULL) if(visual_info == NULL)
{ {
nlerror("glXChooseVisual() failed"); nlerror("glXChooseVisual() failed");
} }
else
{
nldebug("3D: glXChooseVisual OK");
}
ctx = glXCreateContext (dpy, visual_info, None, GL_TRUE); _ctx = glXCreateContext (_dpy, visual_info, None, GL_TRUE);
if(ctx == NULL) if(_ctx == NULL)
{ {
nlerror("glXCreateContext() failed"); nlerror("glXCreateContext() failed");
} }
else
{
nldebug("3D: glXCreateContext() OK");
}
XSetWindowAttributes attr; XSetWindowAttributes attr;
attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy)); attr.background_pixel = BlackPixel(_dpy, DefaultScreen(_dpy));
attr.override_redirect = False; attr.override_redirect = False;
int attr_flags = CWOverrideRedirect | CWBackPixel; int attr_flags = CWOverrideRedirect | CWBackPixel;
if(wnd == EmptyWindow) if(wnd == EmptyWindow)
{ {
nlWindow root = RootWindow(dpy, DefaultScreen(dpy)); nlWindow root = RootWindow(_dpy, DefaultScreen(_dpy));
attr.colormap = XCreateColormap(dpy, root, visual_info->visual, AllocNone); attr.colormap = XCreateColormap(_dpy, root, visual_info->visual, AllocNone);
attr_flags |= CWColormap; attr_flags |= CWColormap;
win = XCreateWindow (dpy, root, 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr); _win = XCreateWindow (_dpy, root, 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr);
if (win == EmptyWindow) if (_win == EmptyWindow)
{ {
nlerror("3D: XCreateWindow() failed"); nlerror("3D: XCreateWindow() failed");
} }
else
{
nldebug("3D: XCreateWindow() OK");
}
} }
else else
{ {
win = wnd; _win = wnd;
XChangeWindowAttributes(dpy, win, attr_flags, &attr); XChangeWindowAttributes(_dpy, _win, attr_flags, &attr);
} }
const char *title="NeL window"; const char *title="NeL window";
@ -772,21 +764,21 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re
size_hints.max_height = height; size_hints.max_height = height;
#ifdef X_HAVE_UTF8_STRING #ifdef X_HAVE_UTF8_STRING
Xutf8SetWMProperties (dpy, win, (char*)title, (char*)title, NULL, 0, &size_hints, NULL, NULL); Xutf8SetWMProperties (_dpy, _win, (char*)title, (char*)title, NULL, 0, &size_hints, NULL, NULL);
#else #else
XTextProperty text_property; XTextProperty text_property;
XStringListToTextProperty((char**)&title, 1, &text_property); XStringListToTextProperty((char**)&title, 1, &text_property);
XSetWMProperties (dpy, win, &text_property, &text_property, 0, 0, &size_hints, 0, 0); XSetWMProperties (_dpy, _win, &text_property, &text_property, 0, 0, &size_hints, 0, 0);
#endif #endif
glXMakeCurrent (dpy, win, ctx); glXMakeCurrent (_dpy, _win, _ctx);
XMapRaised (dpy, win); XMapRaised (_dpy, _win);
XSelectInput (dpy, win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask); XSelectInput (_dpy, _win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask);
XMapWindow(dpy, win); XMapWindow(_dpy, _win);
_EventEmitter.init (dpy, win); _EventEmitter.init (_dpy, _win);
// XEvent event; // XEvent event;
// XIfEvent(dpy, &event, WaitForNotify, (char *)this); // XIfEvent(dpy, &event, WaitForNotify, (char *)this);
@ -814,11 +806,47 @@ static void modifyStyle (HWND hWnd, int nStyleOffset, LONG_PTR dwRemove, LONG_PT
#endif #endif
// -------------------------------------------------- // --------------------------------------------------
void CDriverGL::switchBackToOldMode() bool CDriverGL::saveScreenMode()
{ {
#ifdef NL_OS_WINDOWS H_AUTO_OGL(CDriverGL_saveScreenMode)
ChangeDisplaySettings(&_OldScreenMode, 0);
#elif defined(XF86VIDMODE) bool res = true;
#if defined(NL_OS_WINDOWS)
// don't need to save it because Windows will use default desktop resolution
#elif defined(NL_OS_UNIX)
#if defined(XF86VIDMODE)
// Store old mode in order to restore it when leaving fullscreen
memset(&_OldScreenMode, 0, sizeof(XF86VidModeModeLine));
XF86VidModeGetModeLine(_dpy, DefaultScreen(_dpy), &_OldDotClock, &_OldScreenMode);
res = XF86VidModeGetViewPort(_dpy, DefaultScreen(_dpy), &_OldX, &_OldY);
#endif // XF86VIDMODE
#endif // NL_OS_WINDOWS
return res;
}
// --------------------------------------------------
bool CDriverGL::restoreScreenMode()
{
H_AUTO_OGL(CDriverGL_restoreScreenMode)
bool res = false;
#if defined(NL_OS_WINDOWS)
res = (ChangeDisplaySettings(NULL, 0) == DISP_CHANGE_SUCCESSFUL);
#elif defined(NL_OS_UNIX)
#if defined(XF86VIDMODE)
XF86VidModeModeInfo info; XF86VidModeModeInfo info;
nlinfo("3D: Switching back to original mode"); nlinfo("3D: Switching back to original mode");
@ -837,12 +865,16 @@ void CDriverGL::switchBackToOldMode()
info.c_private = _OldScreenMode.c_private; info.c_private = _OldScreenMode.c_private;
nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay); nlinfo("3D: Switching back mode to %dx%d", info.hdisplay, info.vdisplay);
XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &info); XF86VidModeSwitchToMode(_dpy, DefaultScreen(_dpy), &info);
nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY); nlinfo("3D: Switching back viewport to %d,%d",_OldX, _OldY);
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), _OldX, _OldY); res = XF86VidModeSetViewPort(_dpy, DefaultScreen(_dpy), _OldX, _OldY);
#endif // XF86VIDMODE
}
#endif // XF86VIDMODE
#endif // NL_OS_WINDOWS
return res;
}
// -------------------------------------------------- // --------------------------------------------------
bool CDriverGL::setMode(const GfxMode& mode) bool CDriverGL::setMode(const GfxMode& mode)
@ -853,7 +885,7 @@ bool CDriverGL::setMode(const GfxMode& mode)
{ {
if (_FullScreen) if (_FullScreen)
{ {
switchBackToOldMode(); restoreScreenMode();
modifyStyle(_hWnd, GWL_STYLE, WS_POPUP, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS); modifyStyle(_hWnd, GWL_STYLE, WS_POPUP, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS);
} }
_WindowWidth = mode.Width; _WindowWidth = mode.Width;
@ -863,14 +895,8 @@ bool CDriverGL::setMode(const GfxMode& mode)
else else
{ {
// get old mode. // get old mode.
DEVMODE oldDevMode;
if (!_FullScreen) if (!_FullScreen)
{ saveScreenMode();
oldDevMode.dmSize= sizeof(DEVMODE);
oldDevMode.dmDriverExtra= 0;
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &oldDevMode);
oldDevMode.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY ;
}
// setup new mode // setup new mode
DEVMODE newDevMode; DEVMODE newDevMode;
@ -900,9 +926,6 @@ bool CDriverGL::setMode(const GfxMode& mode)
_WindowWidth = mode.Width; _WindowWidth = mode.Width;
_WindowHeight = mode.Height; _WindowHeight = mode.Height;
_Depth= mode.Depth; _Depth= mode.Depth;
// bkup user mode
if (!_FullScreen)
_OldScreenMode= oldDevMode;
// if old mode was not fullscreen // if old mode was not fullscreen
if (!_FullScreen) if (!_FullScreen)
@ -944,28 +967,26 @@ bool CDriverGL::setMode(const GfxMode& mode)
#ifdef XF86VIDMODE #ifdef XF86VIDMODE
if (!mode.Windowed) if (!mode.Windowed)
{ {
int screen = DefaultScreen(_dpy);
// Store old mdoe in order to restore it when leaving fullscreen // Store old mdoe in order to restore it when leaving fullscreen
if (mode.Windowed == _FullScreen) if (mode.Windowed == _FullScreen)
{ saveScreenMode();
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &_OldDotClock, &_OldScreenMode);
XF86VidModeGetViewPort(dpy, DefaultScreen(dpy), &_OldX, &_OldY);
}
// Find the requested mode and use it // Find the requested mode and use it
XF86VidModeModeInfo **modes; XF86VidModeModeInfo **modes;
int nmodes; int nmodes;
if (XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &modes)) if (XF86VidModeGetAllModeLines(_dpy, screen, &nmodes, &modes))
{ {
for (int i = 0; i < nmodes; i++) for (int i = 0; i < nmodes; i++)
{ {
nldebug("3D: Available mode - %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); nldebug("3D: Available mode - %dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
if(modes[i]->hdisplay == mode.Width && modes[i]->vdisplay == mode.Height) if(modes[i]->hdisplay == mode.Width && modes[i]->vdisplay == mode.Height)
{ {
if(XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), modes[i])) if(XF86VidModeSwitchToMode(_dpy, screen, modes[i]))
{ {
nlinfo("3D: Switching to mode %dx%d", modes[i]->hdisplay, modes[i]->vdisplay); nlinfo("3D: Switching to mode %dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0); XF86VidModeSetViewPort(_dpy, screen, 0, 0);
} }
break; break;
} }
@ -973,7 +994,7 @@ bool CDriverGL::setMode(const GfxMode& mode)
} }
} }
else if (mode.Windowed == _FullScreen) else if (mode.Windowed == _FullScreen)
switchBackToOldMode(); restoreScreenMode();
#endif // XF86VIDMODE #endif // XF86VIDMODE
// Update WM hints (update size and disallow resizing) // Update WM hints (update size and disallow resizing)
@ -996,7 +1017,7 @@ bool CDriverGL::setMode(const GfxMode& mode)
} }
#endif #endif
XSetWMNormalHints(dpy, win, &size_hints); XSetWMNormalHints(_dpy, _win, &size_hints);
// x11 fullscreen is not working on mac os x // x11 fullscreen is not working on mac os x
#if !defined(NL_OS_MAC) #if !defined(NL_OS_MAC)
@ -1006,13 +1027,13 @@ bool CDriverGL::setMode(const GfxMode& mode)
XEvent xev; XEvent xev;
memset(&xev, 0, sizeof(xev)); memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage; xev.type = ClientMessage;
xev.xclient.window = win; xev.xclient.window = _win;
xev.xclient.message_type = XInternAtom(dpy, "_NET_WM_STATE", false); xev.xclient.message_type = XInternAtom(_dpy, "_NET_WM_STATE", false);
xev.xclient.format = 32; xev.xclient.format = 32;
xev.xclient.data.l[0] = !mode.Windowed; xev.xclient.data.l[0] = !mode.Windowed;
xev.xclient.data.l[1] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", false); xev.xclient.data.l[1] = XInternAtom(_dpy, "_NET_WM_STATE_FULLSCREEN", false);
xev.xclient.data.l[2] = 0; xev.xclient.data.l[2] = 0;
XSendEvent(dpy, DefaultRootWindow(dpy), false, SubstructureNotifyMask, &xev); XSendEvent(_dpy, DefaultRootWindow(_dpy), false, SubstructureNotifyMask, &xev);
} }
#endif #endif
@ -1023,8 +1044,8 @@ bool CDriverGL::setMode(const GfxMode& mode)
#endif #endif
// Resize and update the window // Resize and update the window
XResizeWindow(dpy, win, mode.Width, mode.Height); XResizeWindow(_dpy, _win, mode.Width, mode.Height);
XMapWindow(dpy, win); XMapWindow(_dpy, _win);
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
return true; return true;
@ -1065,7 +1086,7 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
# ifdef XF86VIDMODE # ifdef XF86VIDMODE
int nmodes; int nmodes;
XF86VidModeModeInfo **ms; XF86VidModeModeInfo **ms;
Bool ok = XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &nmodes, &ms); Bool ok = XF86VidModeGetAllModeLines(_dpy, DefaultScreen(_dpy), &nmodes, &ms);
if(ok) if(ok)
{ {
nldebug("3D: %d available modes:", nmodes); nldebug("3D: %d available modes:", nmodes);
@ -1096,18 +1117,21 @@ bool CDriverGL::getModes(std::vector<GfxMode> &modes)
bool CDriverGL::getCurrentScreenMode(GfxMode &mode) bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
{ {
H_AUTO_OGL(CDriverGL_getCurrentScreenMode) H_AUTO_OGL(CDriverGL_getCurrentScreenMode)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
DEVMODE devmode; DEVMODE devmode;
devmode.dmSize= sizeof(DEVMODE); devmode.dmSize = sizeof(DEVMODE);
devmode.dmDriverExtra= 0; devmode.dmDriverExtra = 0;
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
mode.Windowed= !_FullScreen; mode.Windowed = !_FullScreen;
mode.OffScreen= false; mode.OffScreen = false;
mode.Depth= (uint8)devmode.dmBitsPerPel; mode.Depth = (uint8)devmode.dmBitsPerPel;
mode.Frequency= devmode.dmDisplayFrequency, mode.Frequency = devmode.dmDisplayFrequency,
mode.Width= (uint16)devmode.dmPelsWidth; mode.Width = (uint16)devmode.dmPelsWidth;
mode.Height= (uint16)devmode.dmPelsHeight; mode.Height = (uint16)devmode.dmPelsHeight;
mode.AntiAlias = -1;
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
# warning "OpenGL Driver: Temporary Mac Implementation" # warning "OpenGL Driver: Temporary Mac Implementation"
@ -1131,7 +1155,7 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
sint pixelClock; sint pixelClock;
XF86VidModeModeLine xmode; XF86VidModeModeLine xmode;
if (!XF86VidModeGetModeLine(dpy, DefaultScreen(dpy), &pixelClock, &xmode)) if (!XF86VidModeGetModeLine(_dpy, DefaultScreen(_dpy), &pixelClock, &xmode))
{ {
nlwarning("XF86VidModeGetModeLine returns 0, cannot get current video mode"); nlwarning("XF86VidModeGetModeLine returns 0, cannot get current video mode");
return false; return false;
@ -1145,7 +1169,7 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
#endif #endif
mode.OffScreen = false; mode.OffScreen = false;
mode.Depth = (uint) DefaultDepth(dpy, DefaultScreen(dpy)); mode.Depth = (uint) DefaultDepth(_dpy, DefaultScreen(_dpy));
mode.Frequency = 1000 * pixelClock / (xmode.htotal * xmode.vtotal) ; mode.Frequency = 1000 * pixelClock / (xmode.htotal * xmode.vtotal) ;
mode.Width = xmode.hdisplay; mode.Width = xmode.hdisplay;
mode.Height = xmode.vdisplay; mode.Height = xmode.vdisplay;
@ -1161,16 +1185,23 @@ bool CDriverGL::getCurrentScreenMode(GfxMode &mode)
void CDriverGL::setWindowTitle(const ucstring &title) void CDriverGL::setWindowTitle(const ucstring &title)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
SetWindowTextW(_hWnd,(WCHAR*)title.c_str());
SetWindowTextW(_hWnd, (WCHAR*)title.c_str());
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::setWindowTitle(title); NL3D::MAC::setWindowTitle(title);
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
#ifdef X_HAVE_UTF8_STRING
Xutf8SetWMProperties (_dpy, _win, (char*)title.toUtf8().c_str(), (char*)title.toUtf8().c_str(), NULL, 0, NULL, NULL, NULL);
#else
XTextProperty text_property; XTextProperty text_property;
char *t = (char*)title.toUtf8().c_str(); XStringListToTextProperty((char**)&title.toUtf8().c_str(), 1, &text_property);
XStringListToTextProperty(&t, 1, &text_property); XSetWMProperties (_dpy, _win, &text_property, &text_property, 0, 0, NULL, 0, 0);
XSetWMName(dpy, win, &text_property); #endif
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
} }
@ -1179,14 +1210,18 @@ void CDriverGL::setWindowPos(uint32 x, uint32 y)
{ {
_WindowX = (sint32)x; _WindowX = (sint32)x;
_WindowY = (sint32)y; _WindowY = (sint32)y;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
SetWindowPos(_hWnd, NULL, _WindowX, _WindowY, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
SetWindowPos(_hWnd, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::setWindowPos(x, y); NL3D::MAC::setWindowPos(x, y);
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
XMoveWindow(dpy, win, _WindowX, _WindowY);
XMoveWindow(_dpy, _win, x, y);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
} }
@ -1201,10 +1236,17 @@ void CDriverGL::showWindow(bool show)
nlwarning("OpenGL Driver: Missing Mac Implementation"); nlwarning("OpenGL Driver: Missing Mac Implementation");
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
if (show) if (show)
XMapWindow(dpy, win); {
XMapWindow(_dpy, _win);
// XMapRaised(_dpy, _win);
}
else else
XUnmapWindow(dpy, win); {
XUnmapWindow(_dpy, _win);
}
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
} }
@ -1224,25 +1266,26 @@ bool CDriverGL::activate()
{ {
H_AUTO_OGL(CDriverGL_activate) H_AUTO_OGL(CDriverGL_activate)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
HGLRC hglrc=wglGetCurrentContext();
HGLRC hglrc = wglGetCurrentContext();
if (hglrc != _hRC)
wglMakeCurrent(_hDC, _hRC);
if (hglrc!=_hRC)
{
wglMakeCurrent(_hDC,_hRC);
}
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
# warning "OpenGL Driver: Temporary Mac Implementation" # warning "OpenGL Driver: Temporary Mac Implementation"
nlwarning("OpenGL Driver: Temporary Mac Implementation"); nlwarning("OpenGL Driver: Temporary Mac Implementation");
// already done in setDisplay, not needed here - unclean! FIXME // already done in setDisplay, not needed here - unclean! FIXME
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
GLXContext nctx=glXGetCurrentContext();
if (nctx != NULL && nctx!=ctx) GLXContext nctx = glXGetCurrentContext();
{
glXMakeCurrent(dpy, win,ctx); if (nctx != NULL && nctx != _ctx)
} glXMakeCurrent(_dpy, _win, _ctx);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
return true; return true;
} }
@ -1294,7 +1337,9 @@ IDriver::TMessageBoxId CDriverGL::systemMessageBox (const char* message, const c
void CDriverGL::showCursor(bool b) void CDriverGL::showCursor(bool b)
{ {
H_AUTO_OGL(CDriverGL_showCursor) H_AUTO_OGL(CDriverGL_showCursor)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
if (b) if (b)
{ {
while (ShowCursor(b) < 0) while (ShowCursor(b) < 0)
@ -1305,6 +1350,7 @@ void CDriverGL::showCursor(bool b)
while (ShowCursor(b) >= 0) while (ShowCursor(b) >= 0)
; ;
} }
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::showCursor(b); NL3D::MAC::showCursor(b);
@ -1313,36 +1359,38 @@ void CDriverGL::showCursor(bool b)
if (b) if (b)
{ {
if (cursor != None) if (_cursor != None)
{ {
XFreeCursor(dpy, cursor); XFreeCursor(_dpy, _cursor);
cursor = None; _cursor = None;
} }
XUndefineCursor(dpy, win); XUndefineCursor(_dpy, _win);
} }
else else
{ {
if (cursor == None) if (_cursor == None)
{ {
char bm_no_data[] = { 0,0,0,0, 0,0,0,0 }; char bm_no_data[] = { 0,0,0,0, 0,0,0,0 };
Pixmap pixmap_no_data = XCreateBitmapFromData (dpy, win, bm_no_data, 8, 8); Pixmap pixmap_no_data = XCreateBitmapFromData (_dpy, _win, bm_no_data, 8, 8);
XColor black; XColor black;
memset(&black, 0, sizeof (XColor)); memset(&black, 0, sizeof (XColor));
black.flags = DoRed | DoGreen | DoBlue; black.flags = DoRed | DoGreen | DoBlue;
cursor = XCreatePixmapCursor (dpy, pixmap_no_data, pixmap_no_data, &black, &black, 0, 0); _cursor = XCreatePixmapCursor (_dpy, pixmap_no_data, pixmap_no_data, &black, &black, 0, 0);
XFreePixmap(dpy, pixmap_no_data); XFreePixmap(_dpy, pixmap_no_data);
} }
XDefineCursor(dpy, win, cursor); XDefineCursor(_dpy, _win, _cursor);
} }
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
} }
// -------------------------------------------------- // --------------------------------------------------
void CDriverGL::setMousePos(float x, float y) void CDriverGL::setMousePos(float x, float y)
{ {
H_AUTO_OGL(CDriverGL_setMousePos) H_AUTO_OGL(CDriverGL_setMousePos)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
if (_hWnd) if (_hWnd)
{ {
// NeL window coordinate to MSWindows coordinates // NeL window coordinate to MSWindows coordinates
@ -1352,24 +1400,29 @@ void CDriverGL::setMousePos(float x, float y)
ClientToScreen (_hWnd, &pt); ClientToScreen (_hWnd, &pt);
SetCursorPos(pt.x, pt.y); SetCursorPos(pt.x, pt.y);
} }
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::setMousePos(x, y); NL3D::MAC::setMousePos(x, y);
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
XWindowAttributes xwa; XWindowAttributes xwa;
XGetWindowAttributes (dpy, win, &xwa); XGetWindowAttributes (_dpy, _win, &xwa);
int x1 = (int)(x * (float) xwa.width); int x1 = (int)(x * (float) xwa.width);
int y1 = (int)((1.0f - y) * (float) xwa.height); int y1 = (int)((1.0f - y) * (float) xwa.height);
XWarpPointer (dpy, None, win, None, None, None, None, x1, y1); XWarpPointer (_dpy, None, _win, None, None, None, None, x1, y1);
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
} }
void CDriverGL::getWindowSize(uint32 &width, uint32 &height) void CDriverGL::getWindowSize(uint32 &width, uint32 &height)
{ {
H_AUTO_OGL(CDriverGL_getWindowSize) H_AUTO_OGL(CDriverGL_getWindowSize)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Off-srceen rendering ?
// Off-screen rendering ?
if (_OffScreen) if (_OffScreen)
{ {
if (_PBuffer) if (_PBuffer)
@ -1386,23 +1439,28 @@ void CDriverGL::getWindowSize(uint32 &width, uint32 &height)
height = (uint32)(_WindowHeight); height = (uint32)(_WindowHeight);
} }
} }
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::getWindowSize(width, height); NL3D::MAC::getWindowSize(width, height);
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
XWindowAttributes xwa; XWindowAttributes xwa;
XGetWindowAttributes (dpy, win, &xwa); XGetWindowAttributes (_dpy, _win, &xwa);
width = (uint32) xwa.width; width = (uint32) xwa.width;
height = (uint32) xwa.height; height = (uint32) xwa.height;
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
} }
void CDriverGL::getWindowPos(uint32 &x, uint32 &y) void CDriverGL::getWindowPos(uint32 &x, uint32 &y)
{ {
H_AUTO_OGL(CDriverGL_getWindowPos) H_AUTO_OGL(CDriverGL_getWindowPos)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
// Off-srceen rendering ?
// Off-screen rendering ?
if (_OffScreen) if (_OffScreen)
{ {
if (_PBuffer) if (_PBuffer)
@ -1414,16 +1472,19 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y)
{ {
if (_hWnd) if (_hWnd)
{ {
x = (uint32)(_WindowX); x = (uint32)_WindowX;
y = (uint32)(_WindowY); y = (uint32)_WindowY;
} }
} }
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::getWindowPos(x, y); NL3D::MAC::getWindowPos(x, y);
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
x = y = 0; x = y = 0;
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
} }
@ -1431,8 +1492,13 @@ void CDriverGL::getWindowPos(uint32 &x, uint32 &y)
bool CDriverGL::isActive() bool CDriverGL::isActive()
{ {
H_AUTO_OGL(CDriverGL_isActive) H_AUTO_OGL(CDriverGL_isActive)
bool res = true;
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
return (IsWindow(_hWnd) != 0);
res = (IsWindow(_hWnd) != FALSE);
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
# warning "OpenGL Driver: Missing Mac Implementation" # warning "OpenGL Driver: Missing Mac Implementation"
// nlwarning("OpenGL Driver: Missing Mac Implementation"); // nlwarning("OpenGL Driver: Missing Mac Implementation");
@ -1440,7 +1506,8 @@ bool CDriverGL::isActive()
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
return true;
return res;
} }
void CDriverGL::setCapture (bool b) void CDriverGL::setCapture (bool b)
@ -1488,11 +1555,11 @@ void CDriverGL::setCapture (bool b)
if(b) // capture the cursor. if(b) // capture the cursor.
{ {
XGrabPointer(dpy, win, True, 0, GrabModeAsync, GrabModeAsync, win, None, CurrentTime); XGrabPointer(_dpy, _win, True, 0, GrabModeAsync, GrabModeAsync, _win, None, CurrentTime);
} }
else // release the cursor. else // release the cursor.
{ {
XUngrabPointer(dpy, CurrentTime); XUngrabPointer(_dpy, CurrentTime);
} }
#endif // NL_OS_UNIX #endif // NL_OS_UNIX
@ -1671,21 +1738,20 @@ bool CDriverGL::setMonitorColorProperties (const CMonitorColorProperties &proper
else else
{ {
nlwarning ("(CDriverGL::setMonitorColorProperties): can't create DC"); nlwarning ("(CDriverGL::setMonitorColorProperties): can't create DC");
return false;
} }
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE) #elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
# warning "OpenGL Driver: Missing Mac Implementation" # warning "OpenGL Driver: Missing Mac Implementation"
nlwarning("OpenGL Driver: Missing Mac Implementation"); nlwarning("OpenGL Driver: Missing Mac Implementation");
return false;
#elif defined (NL_OS_UNIX) #elif defined (NL_OS_UNIX)
// TODO for Linux: implement CDriverGL::setMonitorColorProperties // TODO for Linux: implement CDriverGL::setMonitorColorProperties
nlwarning ("CDriverGL::setMonitorColorProperties not implemented"); nlwarning ("CDriverGL::setMonitorColorProperties not implemented");
return false;
#endif #endif
return false;
} }
} // NL3D } // NL3D