This commit is contained in:
rti 2010-06-13 02:03:23 +02:00
commit 6ff4d15826
49 changed files with 1392 additions and 1129 deletions

View file

@ -104,7 +104,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 = 0x10;
const uint32 CDriverGL::ReleaseVersion = 0x11;
// Number of register to allocate for the EXTVertexShader extension
const uint CDriverGL::_EVSNumConstant = 97;
@ -196,7 +196,6 @@ CDriverGL::CDriverGL()
#ifdef NL_OS_WINDOWS
_PBuffer = NULL;
_hWnd = NULL;
_hRC = NULL;
_hDC = NULL;
_NeedToRestaureGammaRamp = false;
@ -207,19 +206,25 @@ CDriverGL::CDriverGL()
NL3D::MAC::ctor();
#elif defined (NL_OS_UNIX)
cursor = None;
win = 0;
dpy = 0;
_cursor = None;
_dpy = 0;
_visual_info = NULL;
# ifdef XF86VIDMODE
// zero the old screen mode
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
# endif //XF86VIDMODE
#endif // NL_OS_UNIX
_win = EmptyWindow;
_DestroyWindow = false;
_OffScreen = false;
_FullScreen = false;
_Resizable = false;
_AntiAliasing = -1;
_CurrentMaterial=NULL;
_Initialized = false;
@ -341,72 +346,6 @@ CDriverGL::~CDriverGL()
#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()
{
@ -682,6 +621,74 @@ bool CDriverGL::setupDisplay()
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()
{
@ -863,7 +870,7 @@ bool CDriverGL::swapBuffers()
NL3D::MAC::swapBuffers();
#elif defined (NL_OS_UNIX)
glXSwapBuffers(dpy, win);
glXSwapBuffers(_dpy, _win);
#endif // NL_OS_WINDOWS
@ -949,87 +956,9 @@ bool CDriverGL::release()
_AGPVertexArrayRange= NULL;
_VRAMVertexArrayRange= NULL;
#ifdef NL_OS_WINDOWS
// Then delete.
// wglMakeCurrent(NULL,NULL);
destroyWindow();
// Off-screen rendering ?
if (_OffScreen)
{
if (_PBuffer)
{
wglDeleteContext( _hRC );
nwglReleasePbufferDCARB( _PBuffer, _hDC );
nwglDestroyPbufferARB( _PBuffer );
}
}
else
{
if (_hRC)
wglDeleteContext(_hRC);
if (_hWnd&&_hDC)
{
ReleaseDC(_hWnd,_hDC);
if (_DestroyWindow)
DestroyWindow (_hWnd);
}
if(_FullScreen)
{
switchBackToOldMode();
_FullScreen= false;
}
}
_hRC=NULL;
_hDC=NULL;
_hWnd=NULL;
_PBuffer = NULL;
// Restaure monitor color parameters
if (_NeedToRestaureGammaRamp)
{
HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL);
if (dc)
{
if (!SetDeviceGammaRamp (dc, _GammaRampBackuped))
nlwarning ("(CDriverGL::release): SetDeviceGammaRamp failed");
// Release the DC
ReleaseDC (NULL, dc);
}
else
{
nlwarning ("(CDriverGL::release): can't create DC");
}
}
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
NL3D::MAC::release();
#elif defined (NL_OS_UNIX)
if(_FullScreen)
{
switchBackToOldMode();
// Ungrab the keyboard (probably not necessary);
XUnmapWindow(dpy, win);
XSync(dpy, True);
XUngrabKeyboard(dpy, CurrentTime);
}
if (ctx)
{
glXDestroyContext(dpy, ctx);
ctx = NULL;
}
XCloseDisplay(dpy);
dpy = NULL;
#endif // NL_OS_UNIX
unInit();
// released
_Initialized= false;
@ -1042,7 +971,7 @@ void CDriverGL::setupViewport (const class CViewport& viewport)
{
H_AUTO_OGL(CDriverGL_setupViewport )
#ifdef NL_OS_WINDOWS
if (_hWnd == NULL) return;
if (_win == EmptyWindow) return;
// Setup gl viewport
int clientWidth = _WindowWidth;
@ -1056,7 +985,7 @@ void CDriverGL::setupViewport (const class CViewport& viewport)
#elif defined (NL_OS_UNIX)
XWindowAttributes win_attributes;
if (!XGetWindowAttributes(dpy, win, &win_attributes))
if (!XGetWindowAttributes(_dpy, _win, &win_attributes))
throw EBadDisplay("Can't get window attributes.");
// Setup gl viewport
@ -1114,7 +1043,7 @@ void CDriverGL::setupScissor (const class CScissor& scissor)
{
H_AUTO_OGL(CDriverGL_setupScissor )
#ifdef NL_OS_WINDOWS
if (_hWnd == NULL) return;
if (_win == EmptyWindow) return;
// Setup gl viewport
int clientWidth = _WindowWidth;
@ -1130,7 +1059,7 @@ void CDriverGL::setupScissor (const class CScissor& scissor)
#elif defined (NL_OS_UNIX)
XWindowAttributes win_attributes;
if (!XGetWindowAttributes(dpy, win, &win_attributes))
if (!XGetWindowAttributes(_dpy, _win, &win_attributes))
throw EBadDisplay("Can't get window attributes.");
// Setup gl viewport
@ -2729,7 +2658,7 @@ void CDriverGL::stencilFunc(TStencilFunc stencilFunc, int ref, uint mask)
{
H_AUTO_OGL(CDriverGL_CDriverGL)
GLenum glstencilFunc;
GLenum glstencilFunc = 0;
switch(stencilFunc)
{
@ -2752,7 +2681,7 @@ void CDriverGL::stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass)
{
H_AUTO_OGL(CDriverGL_CDriverGL)
GLenum glFail, glZFail, glZPass;
GLenum glFail = 0, glZFail = 0, glZPass = 0;
switch(fail)
{

View file

@ -305,13 +305,11 @@ public:
virtual nlWindow getDisplay()
{
#ifdef NL_OS_WINDOWS
return _hWnd;
#elif defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
#if defined(NL_OS_MAC) && defined(NL_MAC_NATIVE)
return NULL;
#elif defined(NL_OS_UNIX)
return win;
#endif // NL_OS_WINDOWS
#else
return _win;
#endif
}
virtual uint32 getAvailableVertexAGPMemory ();
@ -655,26 +653,29 @@ private:
private:
// Version of the driver. Not the interface version!! Increment when implementation of the driver change.
static const uint32 ReleaseVersion;
static const uint32 ReleaseVersion;
bool _FullScreen;
bool _OffScreen;
bool _Resizable;
uint _Interval;
sint8 _AntiAliasing;
sint32 _WindowWidth, _WindowHeight, _WindowX, _WindowY;
nlWindow _win;
bool _DestroyWindow;
#ifdef NL_OS_WINDOWS
friend static bool GlWndProc(CDriverGL *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
HWND _hWnd;
HDC _hDC;
PIXELFORMATDESCRIPTOR _pfd;
HGLRC _hRC;
static uint _Registered;
DEVMODE _OldScreenMode;
NLMISC::CEventEmitterMulti _EventEmitter; // this can contains a win emitter and eventually a direct input emitter
bool _DestroyWindow;
// Off-screen rendering in Dib section
HPBUFFERARB _PBuffer;
@ -684,16 +685,16 @@ private:
#elif defined (NL_OS_UNIX)
Display *dpy;
GLXContext ctx;
Window win;
Cursor cursor;
Display* _dpy;
GLXContext _ctx;
Cursor _cursor;
NLMISC::CUnixEventEmitter _EventEmitter;
XVisualInfo* _visual_info;
#ifdef XF86VIDMODE
int _OldDotClock; // old dotclock
XF86VidModeModeLine _OldScreenMode; // old modeline
int _OldX, _OldY; //Viewport settings
int _OldDotClock; // old dotclock
XF86VidModeModeLine _OldScreenMode; // old modeline
int _OldX, _OldY; //Viewport settings
#endif //XF86VIDMODE
#endif // NL_OS_UNIX
@ -841,8 +842,15 @@ private:
bool _CurrentGlNormalize;
private:
void switchBackToOldMode();
bool setupDisplay();
bool unInit();
bool createWindow(const GfxMode& mode);
bool destroyWindow();
// Methods to manage screen resolutions
bool restoreScreenMode();
bool saveScreenMode();
bool setScreenMode(const GfxMode &mode);
// Get the proj matrix setupped in GL
void refreshProjMatrixFromGL();

View file

@ -416,9 +416,9 @@ PFNWGLFREEMEMORYNVPROC nwglFreeMemoryNV;
// Pbuffer extension
PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB;
PFNWGLGETPUFFERDCARBPROC nwglGetPbufferDCARB;
PFNWGLRELEASEPUFFERDCARBPROC nwglReleasePbufferDCARB;
PFNWGLDESTROYPUFFERARBPROC nwglDestroyPbufferARB;
PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB;
PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB;
PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB;
PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB;
// Get Pixel format extension
@ -431,10 +431,9 @@ PFNWGLSWAPINTERVALEXTPROC nwglSwapIntervalEXT;
PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT;
// WGL_ARB_extensions_string
PFNWGFGETEXTENSIONSSTRINGARB nwglGetExtensionsStringARB;
PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB;
#endif
// ***************************************************************************
// ***************************************************************************
// ***************************************************************************
@ -857,9 +856,9 @@ static bool setupWGLARBPBuffer(const char *glext)
#ifdef NL_OS_WINDOWS
CHECK_ADDRESS(PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB);
CHECK_ADDRESS(PFNWGLGETPUFFERDCARBPROC, wglGetPbufferDCARB);
CHECK_ADDRESS(PFNWGLRELEASEPUFFERDCARBPROC, wglReleasePbufferDCARB);
CHECK_ADDRESS(PFNWGLDESTROYPUFFERARBPROC, wglDestroyPbufferARB);
CHECK_ADDRESS(PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB);
CHECK_ADDRESS(PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB);
CHECK_ADDRESS(PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB);
CHECK_ADDRESS(PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB);
#endif
@ -1249,6 +1248,7 @@ void registerGlExtensions(CGlExtensions &ext)
// Disable feature ???
if(!ext.DisableHardwareVertexArrayAGP)
ext.NVVertexArrayRange= setupNVVertexArrayRange(glext);
if(ext.NVVertexArrayRange)
{
GLint nverts;
@ -1256,7 +1256,6 @@ void registerGlExtensions(CGlExtensions &ext)
ext.NVVertexArrayRangeMaxVertex= nverts;
}
// Compression S3TC OK iff ARBTextureCompression.
ext.EXTTextureCompressionS3TC= (ext.ARBTextureCompression && setupEXTTextureCompressionS3TC(glext));
@ -1269,7 +1268,6 @@ void registerGlExtensions(CGlExtensions &ext)
// Check NVTextureEnvCombine4.
ext.NVTextureEnvCombine4= setupNVTextureEnvCombine4(glext);
// Check for cube mapping
ext.ARBTextureCubeMap = setupARBTextureCubeMap(glext);
@ -1305,8 +1303,6 @@ void registerGlExtensions(CGlExtensions &ext)
ext.ARBFragmentProgram = false;
}
// For now, the only way to know if emulation, is to test some extension which exist only on GeForce3.
// if GL_NV_texture_shader is not here, then we are not on GeForce3.
ext.NVVertexProgramEmulated= ext.NVVertexProgram && (strstr(glext, "GL_NV_texture_shader")==NULL);
@ -1319,6 +1315,7 @@ void registerGlExtensions(CGlExtensions &ext)
// Check NVVertexArrayRange2
ext.NVVertexArrayRange2= setupNVVertexArrayRange2(glext);
// if supported
if(ext.NVVertexArrayRange2)
// VBHard swap without flush of the VAR.
@ -1411,7 +1408,7 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC)
{
H_AUTO_OGL(registerWGlExtensions);
// Get proc address
CHECK_ADDRESS(PFNWGFGETEXTENSIONSSTRINGARB, wglGetExtensionsStringARB);
CHECK_ADDRESS(PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB);
// Get extension string
const char *glext = nwglGetExtensionsStringARB (hDC);

View file

@ -158,7 +158,15 @@ public:
ARBFragmentProgram = false;
ARBVertexBufferObject = false;
ARBVertexProgram = false;
NVTextureRectangle = false;
EXTTextureRectangle = false;
ARBTextureRectangle = false;
ARBTextureNonPowerOfTwo = false;
NVOcclusionQuery = false;
FrameBufferObject = false;
PackedDepthStencil = false;
NVVertexArrayRange2 = false;
NVStateVARWithoutFlush = 0;
/// \name Disable Hardware feature. False by default. setuped by IDriver
DisableHardwareVertexProgram= false;
@ -167,6 +175,7 @@ public:
// misc
IsATI9500OrAbove = false;
IsGeforceFXOrAbove = false;
};
std::string toString()
@ -643,9 +652,9 @@ extern NEL_PFNGLGETOCCLUSIONQUERYUIVNVPROC nglGetOcclusionQueryuivNV;
// Pbuffer extension
//==================
extern PFNWGLCREATEPBUFFERARBPROC nwglCreatePbufferARB;
extern PFNWGLGETPUFFERDCARBPROC nwglGetPbufferDCARB;
extern PFNWGLRELEASEPUFFERDCARBPROC nwglReleasePbufferDCARB;
extern PFNWGLDESTROYPUFFERARBPROC nwglDestroyPbufferARB;
extern PFNWGLGETPBUFFERDCARBPROC nwglGetPbufferDCARB;
extern PFNWGLRELEASEPBUFFERDCARBPROC nwglReleasePbufferDCARB;
extern PFNWGLDESTROYPBUFFERARBPROC nwglDestroyPbufferARB;
extern PFNWGLQUERYPBUFFERARBPROC nwglQueryPbufferARB;
@ -663,7 +672,7 @@ extern PFNWGLGETSWAPINTERVALEXTPROC nwglGetSwapIntervalEXT;
// WGL_ARB_extensions_string
extern PFNWGFGETEXTENSIONSSTRINGARB nwglGetExtensionsStringARB;
extern PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB;
#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 * PFNWGLFREEMEMORYNVPROC) (void *pointer);
typedef HPBUFFERARB (APIENTRY * PFNWGLCREATEPBUFFERARBPROC) (HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (APIENTRY * PFNWGLGETPUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (APIENTRY * PFNWGLRELEASEPUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC);
typedef BOOL (APIENTRY * PFNWGLDESTROYPUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef HDC (APIENTRY * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (APIENTRY * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC);
typedef BOOL (APIENTRY * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (APIENTRY * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
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 int (APIENTRY * PFNWGLGETSWAPINTERVALEXTPROC) (void);
typedef const char* (APIENTRY * PFNWGFGETEXTENSIONSSTRINGARB) (HDC);
typedef const char* (APIENTRY * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC);
#endif

View file

@ -53,15 +53,19 @@ CTextureDrvInfosGL::CTextureDrvInfosGL(IDriver *drv, ItTexDrvInfoPtrMap it, CDri
// The id is auto created here.
glGenTextures(1,&ID);
Compressed= false;
MipMap= false;
TextureMemory= 0;
Compressed = false;
MipMap = false;
TextureMemory = 0;
// Nb: at Driver dtor, all tex infos are deleted, so _Driver is always valid.
_Driver= drvGl;
TextureMode = isRectangleTexture?GL_TEXTURE_RECTANGLE_NV:GL_TEXTURE_2D;
FBOId = 0;
DepthFBOId = 0;
StencilFBOId = 0;
InitFBO = false;
AttachDepthStencil = true;
UsePackedDepthStencil = drvGl->supportPackedDepthStencil();
@ -157,33 +161,41 @@ bool CTextureDrvInfosGL::initFrameBufferObject(ITexture * tex)
InitFBO = true;
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
nlwarning("Unsupported framebuffer format\n");
nlwarning("Unsupported framebuffer format");
break;
#if GL_GLEXT_VERSION > 24
#ifdef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
nlwarning("Framebuffer incomplete attachment\n");
nlwarning("Framebuffer incomplete attachment");
break;
#endif
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
nlwarning("Framebuffer incomplete, missing attachment\n");
nlwarning("Framebuffer incomplete, missing attachment");
break;
#if GL_GLEXT_VERSION < 39
#ifdef 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;
#endif
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;
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;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
nlwarning("Framebuffer incomplete, missing draw buffer\n");
nlwarning("Framebuffer incomplete, missing draw buffer");
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
nlwarning("Framebuffer incomplete, missing read buffer\n");
nlwarning("Framebuffer incomplete, missing read buffer");
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:
nlwarning("Framebuffer incomplete\n");
//nlassert(0);
@ -237,7 +249,6 @@ static inline CTextureDrvInfosGL* getTextureGl(ITexture& tex)
return gltex;
}
// ***************************************************************************
// Translation of TexFmt mode.
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.
if(_Extensions.EXTTextureCompressionS3TC)
{
@ -284,7 +294,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
}
}
// Get standard gl tex format.
compressed= false;
switch(texfmt)
@ -313,7 +322,6 @@ GLint CDriverGL::getGlTextureFormat(ITexture& tex, bool &compressed)
}
}
// ***************************************************************************
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;
}
// ***************************************************************************
// Translation of Wrap mode.
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)
{
@ -472,7 +478,6 @@ static inline GLenum translateMinFilterToGl(CTextureDrvInfosGL *glText)
#endif // NEL_FORCE_NEAREST
}
// ***************************************************************************
static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
{
@ -489,7 +494,6 @@ static inline bool sameDXTCFormat(ITexture &tex, GLint glfmt)
return false;
}
// ***************************************************************************
static inline bool isDXTCFormat(GLint glfmt)
{
@ -506,7 +510,6 @@ static inline bool isDXTCFormat(GLint glfmt)
return false;
}
// ***************************************************************************
bool CDriverGL::setupTexture (ITexture& tex)
{
@ -515,8 +518,6 @@ bool CDriverGL::setupTexture (ITexture& tex)
return setupTextureEx (tex, true, nTmp);
}
// ***************************************************************************
#ifndef NL_DEBUG
inline
@ -624,15 +625,12 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
return true; // Do not do anything
}
// 1. If modified, may (re)load texture part or all of the texture.
//=================================================================
bool mustLoadAll= false;
bool mustLoadPart= false;
// To avoid any delete/new ptr problem, disable all texturing.
/* 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).
@ -643,7 +641,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
activateTexture(stage, NULL);
}
// A. Share mgt.
//==============
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);
bAllUploaded = true;
NEL_MEASURE_UPLOAD_TIME_END
}
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));
// profiling. add new TextureMemory usage.
_AllocatedTextureMemory+= gltext->TextureMemory;
}
@ -983,8 +978,6 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
else
glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL);
// Next mipmap!!
// floor .
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_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
}
}
// Release, if wanted.
if(tex.getReleasable())
tex.release();
@ -1019,13 +1009,11 @@ bool CDriverGL::setupTextureEx (ITexture& tex, bool bUpload, bool &bAllUploaded,
_DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
}
// The texture is correctly setuped.
tex.clearTouched();
return true;
}
// ***************************************************************************
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);
bool dummy;
GLint glfmt = getGlTextureFormat (tex, dummy);
GLint glSrcFmt = getGlSrcTextureFormat (tex, glfmt);
GLenum glSrcType= getGlSrcTextureComponentType(glSrcFmt);
// If DXTC format
if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt))
{
@ -1116,7 +1101,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
return false;
}
nlassert (((x0&3) == 0) && ((y0&3) == 0));
if ((w>=4) && (h>=4))
{
@ -1132,8 +1116,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
nglCompressedTexImage2DARB (GL_TEXTURE_2D, nNumMipMap-decalMipMapResize,
glfmt, w, h, 0, imageSize, ptr);
}
}
else
{
@ -1150,8 +1132,6 @@ bool CDriverGL::uploadTexture (ITexture& tex, CRect& rect, uint8 nNumMipMap)
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
}
// Disable texture 0
@ -1195,7 +1175,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
_TextureUsed.insert (gltext);
}
if(tex->isTextureCube())
{
// setup texture mode, after activeTextureARB()
@ -1215,7 +1194,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
// setup this texture
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
// Change parameters of texture, if necessary.
//============================================
if(gltext->MagFilter!= tex->getMagFilter())
@ -1228,8 +1206,6 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
gltext->MinFilter= tex->getMinFilter();
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)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
//== RGB ==
switch(env.Env.OpRGB)
{
@ -1683,7 +1658,6 @@ void CDriverGL::forceActivateTexEnvMode(uint stage, const CMaterial::CTexEnv &
//=====
if (env.Env.OpAlpha == CMaterial::Mad)
{
if (_Extensions.ATITextureEnvCombine3)
{
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);
}
}
// ***************************************************************************
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)
{
@ -1825,7 +1794,13 @@ void CDriverGL::swapTextureHandle(ITexture &tex0, ITexture &tex1)
swap(t0->WrapT, t1->WrapT);
swap(t0->MagFilter, t1->MagFilter);
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);
getViewport(_OldViewport);
CViewport newVP;
newVP.init(0, 0, ((float)width/(float)w), ((float)height/(float)h));
setupViewport(newVP);
@ -1972,7 +1948,7 @@ bool CDriverGL::getRenderTargetSize (uint32 &width, uint32 &height)
#elif defined (NL_OS_UNIX)
XWindowAttributes win_attributes;
if (!XGetWindowAttributes(dpy, win, &win_attributes))
if (!XGetWindowAttributes(_dpy, _win, &win_attributes))
throw EBadDisplay("Can't get window attributes.");
// Setup gl viewport

File diff suppressed because it is too large Load diff

View file

@ -61,15 +61,11 @@ bool CNELU::initDriver (uint w, uint h, uint bpp, bool windowed, nlWindow syst
CNELU::Driver= CDRU::createD3DDriver();
}
else
#endif // NL_OS_WINDOWS
{
CNELU::Driver= CDRU::createGlDriver();
}
#else // NL_OS_WINDOWS
CNELU::Driver= CDRU::createGlDriver();
//CNELU::Driver= CDRU::createD3DDriver();
#endif // NL_OS_WINDOWS
if (!CNELU::Driver->init())
{
nlwarning ("CNELU::initDriver: init() failed");

View file

@ -48,7 +48,6 @@ uint32 CIFile::_ReadingFromFile = 0;
uint32 CIFile::_FileOpened = 0;
uint32 CIFile::_FileRead = 0;
CSynchronized<std::deque<std::string> > CIFile::_OpenedFiles("");
// = CSynchronized<std::deque<std::string> >("");
// ======================================================================================================
CIFile::CIFile() : IStream(true)

View file

@ -16,6 +16,7 @@
#include <nel/misc/path.h>
#include <nel/misc/md5.h>
#include <nel/misc/file.h>
#include "shapes_exporter.h"
using namespace NLMISC;
@ -40,6 +41,44 @@ void split(const std::string &str, std::vector<std::string> &tokens, const std::
}
}
static CHashKeyMD5 getNewMD5(const std::string &filename)
{
CMD5Context md5ctx;
CHashKeyMD5 Message_Digest;
Message_Digest.clear();
CIFile ifile;
if (!ifile.open(filename))
{
nlwarning ("MD5: Can't open the file '%s'", filename.c_str());
return Message_Digest;
}
md5ctx.init();
uint8 buffer[1024];
int bufferSize = 1024;
sint fs = ifile.getFileSize();
sint n, read = 0;
do
{
//bs = (int)fread (buffer, 1, bufferSize, fp);
n = std::min (bufferSize, fs-read);
//nlinfo ("read %d bytes", n);
ifile.serialBuffer((uint8 *)buffer, n);
md5ctx.update(buffer, n);
read += n;
}
while (!ifile.eof());
ifile.close ();
md5ctx.final(Message_Digest);
return Message_Digest;
}
#if defined(NL_OS_WINDOWS) && !defined(_CONSOLE)
sint WINAPI WinMain(HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR cmdline, int /* nCmdShow */)
@ -68,7 +107,6 @@ sint main(int argc, char **argv)
exporter.parseConfigFile("shapes_exporter.cfg");
exporter.init();
exporter.setupLight();
if (argc > 1)
{
@ -84,8 +122,26 @@ sint main(int argc, char **argv)
std::vector<std::string> filenames;
// search all .max files
CPath::getPathContent(exporter.settings.input_path, true, false, true, filenames);
// CPath::getFileList("max", filenames);
// search .max files corresponding to a filter
// fix bad textures
CPath::remapFile("ma_hof_armor_00_tibia_c1.tga", "ma_hof_armor00_tibia_c1.png");
CPath::remapFile("ma_hof_armor_00_foot_c1.tga", "ma_hof_armor00_foot_c1.png");
CPath::remapFile("ma_hof_armor_01_botte_c1.tga", "ma_hof_armor01_botte_c1.png");
CPath::remapFile("ma_hof_armor_01_pied_c1.tga", "ma_hof_armor01_pied_c1.png");
CPath::remapFile("ma_hom_armor_01_botte_c1.tga", "ma_hom_armor01_botte_c1.png");
CPath::remapFile("ma_hom_armor_01_pied_c1.tga", "ma_hom_armor01_pied_c1.png");
CPath::remapFile("hair_spec.tga", "spec_hair.png");
CPath::remapFile("zo_hof_armor_00_mollet_c1.tga", "zo_hof_armor00_mollet_c1.png");
CPath::remapFile("zo_hof_armor_00_pied_c1.tga", "zo_hof_armor00_pied_c1.png");
CPath::remapFile("zo_hom_armor_00_mollet_c1.tga", "zo_hom_armor00_mollet_c1.png");
CPath::remapFile("zo_hom_armor_00_pied_c1.tga", "zo_hom_armor00_pied_c1.png");
// CPath::getFileListByName("ps", "braziera", filenames);
// CPath::getFileListByName("ps", "fireworka", filenames);
// CPath::getFileListByName("ps", "fireworkf", filenames);
@ -100,38 +156,106 @@ sint main(int argc, char **argv)
CPath::getFileList("ps", shapes);
for(size_t i = 0; i < filenames.size(); ++i)
{
if (filenames[i].find(".max") == std::string::npos)
continue;
std::string baseFilename = toLower(CFile::getFilenameWithoutExtension(filenames[i]));
// compute the md5 of .max file
std::string md5 = getMD5(filenames[i]).toString();
std::string md5 = getNewMD5(filenames[i]).toString();
nlinfo("processing %s with md5 = %s", filenames[i].c_str(), md5.c_str());
// the final directory with images
std::string output_path = exporter.settings.output_path + md5.substr(0, 2) + "/" + md5;
// file is an animation
std::string animation = ""; // CPath::lookup(baseFilename + ".anim", false, false, false);
// file is a skeleton
std::string skeleton = ""; // CPath::lookup(baseFilename + ".skel", false, false, false);
// file is a shape
std::string shape = CPath::lookup(baseFilename + ".shape", false, false, false);
// copy .shape file
if (!shape.empty() && false)
{
CIFile in;
COFile out;
// create output directory if it doesn't already exists
if (!CFile::isExists(output_path) && !CFile::createDirectoryTree(output_path))
{
nlwarning("can't create %s", output_path.c_str());
continue;
}
if (in.open(shape) && out.open(output_path + "/" + baseFilename + ".shape"))
{
uint32 size = in.getFileSize();
uint8 *buffer = new uint8[size];
in.serialBuffer(buffer, size);
out.serialBuffer(buffer, size);
delete [] buffer;
}
}
// try with several shapes binded on a skeleton
std::vector<std::string> filtered_shapes;
if(CFile::getExtension(filenames[i]) == "ps")
if (!animation.empty())
{
// render animation
skeleton = ShapesExporter::findSkeleton(filenames[i]);
// TODO: take from cfg
// filtered_shapes.push_back();
continue;
// no filter if it's a PS
filtered_shapes.push_back(filenames[i]);
}
else if (!shape.empty())
{
// skeleton = ShapesExporter::findSkeleton(shape);
// render shape
}
else if (!skeleton.empty())
{
// don't render anything
continue;
}
else
{
continue;
/*
// create a temporary list with shapes which could correspond to .max file
for(size_t j = 0; j < shapes.size(); ++j)
{
// only add files with the same beginning
if (shapes[j].find(CFile::getFilenameWithoutExtension(filenames[i])) == 0)
if (shapes[j].find(baseFilename) == 0)
{
filtered_shapes.push_back(shapes[j]);
}
}
}
*/
// if there is no corresponding file, we can't render it
if (filtered_shapes.empty())
{
nlwarning("didn't find type of %s", filenames[i].c_str());
continue;
}
// if there is no corresponding file, we can't render it
if (filtered_shapes.empty())
{
nlinfo("no shape found");
continue;
// if we found only one shape, we don't need a skeleton
if (filtered_shapes.size() == 1)
{
shape = filtered_shapes[0];
}
else
{
skeleton = ShapesExporter::findSkeleton(filenames[i]);
}
}
// create output directory if it doesn't already exists
@ -141,32 +265,29 @@ sint main(int argc, char **argv)
continue;
}
// if we found only one shape, we don't need a skeleton
if (filtered_shapes.size() == 1)
bool res = false;
if (!skeleton.empty())
{
if (!exporter.exportShape(filtered_shapes[0], output_path))
res = exporter.exportSkeleton(skeleton, filtered_shapes, output_path);
}
else
{
res = exporter.exportShape(shape, output_path);
}
if (res)
{
if (!exporter.createThumbnail(filenames[i], output_path))
{
// an error occured, try to delete directory
nlwarning("can't export shape");
CFile::deleteDirectory(output_path);
continue;
nlwarning("can't create thumbnail");
}
}
else
{
// TODO: search for the right skeleton
if (!exporter.exportSkeleton("fy_hof_skel.skel", filtered_shapes, output_path))
{
// an error occured, try to delete directory
nlwarning("can't export shape");
CFile::deleteDirectory(output_path);
continue;
}
}
if (!exporter.createThumbnail(filenames[i], output_path))
{
nlwarning("can't create thumbnail");
// an error occured, try to delete directory
nlwarning("can't export shape");
CFile::deleteDirectory(output_path);
}
}
}

View file

@ -1,7 +1,8 @@
input_path = "";
search_pathes = { };
recursive_search_pathes = { };
output_path = "storage";
extensions_remapping = { "dds", "tga" };
extensions_remapping = { "png", "tga", "dds", "tga" };
preview_width = 80;
preview_height = 80;
@ -17,7 +18,7 @@ output_antialiasing = 2; // 0 or 1 = none, 2 = 2x, etc...
output_quality = 90;
output_background = { 0, 0, 0 };
light_ambiant = { 255, 255, 255 };
light_ambiant = { 0, 0, 0 };
light_diffuse = { 255, 255, 255 };
light_specular = { 255, 255, 255 };
light_direction = { 0.25, 0.5, 0.25 };
light_direction = { 0.25, 0.25, 0.25 };

View file

@ -106,6 +106,15 @@ bool ShapesExporter::parseConfigFile(const string &filename)
return false;
}
// input path
try
{
settings.input_path = CPath::standardizePath(cf.getVar("input_path").asString());
}
catch (EUnknownVar &)
{
}
// output path
try
{
@ -332,7 +341,7 @@ bool ShapesExporter::parseConfigFile(const string &filename)
return true;
}
bool ShapesExporter::setupLight()
bool ShapesExporter::setupLight(const CVector &position, const CVector &direction)
{
// create the light
ULight *Light = ULight::createLight();
@ -342,7 +351,8 @@ bool ShapesExporter::setupLight()
Light->setMode(ULight::DirectionalLight);
// set position of the light
Light->setupDirectional(settings.light_ambiant, settings.light_diffuse, settings.light_specular, settings.light_direction);
// Light->setupDirectional(settings.light_ambiant, settings.light_diffuse, settings.light_specular, settings.light_direction);
Light->setupPointLight(settings.light_ambiant, settings.light_diffuse, settings.light_specular, position, direction + settings.light_direction);
// set and enable the light
Driver->setLight(0, *Light);
@ -351,21 +361,117 @@ bool ShapesExporter::setupLight()
return true;
}
void ShapesExporter::setCamera(CAABBox &bbox, UInstance &entity, bool high_z)
void ShapesExporter::setCamera(CAABBox &bbox, UTransform &entity, bool high_z)
{
CVector pos(0.f, 0.f, 0.f);
CQuat quat(0.f, 0.f, 0.f, 0.f);
NL3D::UInstance inst;
inst.cast(entity);
if (!inst.empty())
{
inst.getDefaultPos(pos);
inst.getDefaultRotQuat(quat);
/*
if (quat.getAxis().isNull())
{
quat.set(0, 0, 0, 0);
inst.setRotQuat(quat);
}
*/
// quat.set(1.f, 1.f, 0.f, 0.f);
// inst.setRotQuat(quat);
// inst.getRotQuat(quat);
// check for presence of all textures from each sets
bool allGood = true;
for(uint s = 0; s < 5; ++s)
{
inst.selectTextureSet(s);
uint numMat = inst.getNumMaterials();
// by default, all textures are present
allGood = true;
for(uint i = 0; i < numMat; ++i)
{
UInstanceMaterial mat = inst.getMaterial(i);
for(sint j = 0; j <= mat.getLastTextureStage(); ++j)
{
// if a texture is missing
if (mat.isTextureFile(j) && mat.getTextureFileName(j) == "CTextureMultiFile:Dummy")
allGood = false;
}
}
// if all textures have been found for this set, skip other sets
if (allGood)
break;
}
}
// fix scale (some shapes have a different value)
entity.setScale(1.f, 1.f, 1.f);
UCamera Camera = Scene->getCam();
CVector center = bbox.getCenter();
CVector max_radius = bbox.getHalfSize();
CVector center = bbox.getCenter();
entity.setPivot(center);
center += pos;
float fov = float(20.0*Pi/180.0);
Camera.setPerspective (fov, 1.0f, 0.1f, 1000.0f);
float radius = max(max(max_radius.x, max_radius.y), max_radius.z);
if (radius == 0.f) radius = 1.f;
float left, right, bottom, top, znear, zfar;
Camera.getFrustum(left, right, bottom, top, znear, zfar);
float dist = radius / (tan(fov/2));
Camera.lookAt(CVector(center.x+dist+max_radius.x, center.y, center.z+(high_z?max_radius.z/1.0f:0.0f)), center);
CVector eye(center);
/* if (axis == CVector::I)
eye.y -= dist+radius;
else if (axis == CVector::J)
eye.x += dist+radius;
*/
// quat.normalize();
CVector ax(quat.getAxis());
// float angle = quat.getAngle();
/*
if (ax.isNull())
{
if (int(angle*100.f) == int(NLMISC::Pi * 200.f))
{
ax = CVector::J;
}
}
else
*/
if (ax.isNull() || ax == CVector::I)
{
ax = CVector::I;
}
else if (ax == -CVector::K)
{
ax = -CVector::J;
}
/* else if (ax.x < -0.9f && ax.y == 0.f && ax.z == 0.f)
{
ax = -CVector::J ;
}
*/
// ax.normalize();
eye -= ax * (dist+radius);
if (high_z)
eye.z += max_radius.z/1.0f;
Camera.lookAt(eye, center);
setupLight(eye, center - eye);
}
bool ShapesExporter::exportShape(const string &filename, const string &output_path)
@ -397,15 +503,15 @@ bool ShapesExporter::exportShape(const string &filename, const string &output_pa
Scene->animate(1.0);
Scene->render();
UParticleSystemInstance *psi = static_cast<UParticleSystemInstance*>(&Entity);
if(psi)
{
psi->getSystemBBox(bbox);
setCamera(bbox, Entity);
}
if(CFile::getExtension(filename) == "ps")
{
UParticleSystemInstance *psi = static_cast<UParticleSystemInstance*>(&Entity);
if(psi)
{
psi->getSystemBBox(bbox);
setCamera(bbox, Entity);
}
// first pass to detect bbox & duration
CAABBox bbox2;
double duration = 0.0;
@ -418,7 +524,7 @@ bool ShapesExporter::exportShape(const string &filename, const string &output_pa
}
else
{
renderShape(Entity, CVector::I, output_path);
renderShape(Entity, output_path);
}
// delete entity
@ -470,22 +576,9 @@ bool ShapesExporter::exportSkeleton(const string &skeleton, const vector<string>
// get AABox of Entity
CAABBox bbox;
Skeleton.computeCurrentBBox(bbox, NULL);
setCamera(bbox, Skeleton);
CVector center = bbox.getCenter();
CVector max_radius = bbox.getMax();
Skeleton.setPivot(center);
float radius = max_radius.x;
if (max_radius.y > radius) radius = max_radius.y;
if (max_radius.z > radius) radius = max_radius.z;
// camera will look at entities
// Camera.lookAt(CVector(center.x, center.y - bbox.getRadius() * 1.5f, center.z * 2.f), CVector(center.x, center.y, center.z * 2.f));
Camera.lookAt(CVector(center.x + bbox.getRadius() * 2.0f, center.y, center.z), CVector(center.x, center.y, center.z));
renderShape(Skeleton, CVector::J, output_path);
renderShape(Skeleton, output_path);
// delete entities
for(size_t i = 0; i < Entities.size(); ++i)
@ -500,6 +593,95 @@ bool ShapesExporter::exportSkeleton(const string &skeleton, const vector<string>
return true;
}
/*
bool ShapesExporter::exportAnimation(const std::string &animation, const std::string &skeleton, const std::vector<std::string> &parts, const std::string &output_path)
{
UPlayListManager *PlayListManager = Scene->createPlayListManager();
UAnimationSet *AnimSet = Driver->createAnimationSet();
// uint anim_id = AnimSet->addAnimation("anim.anim", "anim_name", false);
// uint weight_id = AnimSet->addSkeletonWeight("file.wgt", "skel_name"):
// UAnimation *anim = AnimSet->getAnimation(anim_id);
// anim->getEndTime();
// UPlayList *playlist = playlist_manager->createPlayList(AnimSet);
// playlist->registerTransform(Skeleton);
// playlist->setAnimation(0, anim_id);
// playlist->setTimeOrigin(newSlot, time);
// playlist->setWeightSmoothness(newSlot, 1.0f);
// get scene camera
UCamera Camera = Scene->getCam();
if (Camera.empty())
{
nlwarning("can't get camera from scene");
return false;
}
// add a skeleton to the scene
USkeleton Skeleton = Scene->createSkeleton(skeleton);
// if we can't create entity, skip it
if (Skeleton.empty())
{
nlwarning("can't create skeleton from %s", skeleton.c_str());
return false;
}
std::vector<UInstance> Entities(parts.size());
for(size_t i = 0; i < parts.size(); ++i)
{
Entities[i] = Scene->createInstance(parts[i]);
// if we can't create entity, skip it
if (Entities[i].empty())
{
nlwarning("can't create instance from %s", parts[i].c_str());
return false;
}
if (!Skeleton.bindSkin(Entities[i]))
{
nlwarning("can't bind %s to skeleton", parts[i].c_str());
return false;
}
}
// get AABox of Entity
CAABBox bbox;
Skeleton.computeCurrentBBox(bbox, NULL);
setCamera();
// camera will look at skeleton
Camera.lookAt(CVector(center.x + dist - radius, center.y, center.z), center);
renderAllImages(Skeleton, CVector::J, output_path);
// delete entities
for(size_t i = 0; i < Entities.size(); ++i)
{
Skeleton.detachSkeletonSon(Entities[i]);
Scene->deleteInstance(Entities[i]);
}
// delete skeleton
Scene->deleteSkeleton(Skeleton);
Scene->deletePlayListManager(PlayListManager);
Driver->deleteAnimationSet(AnimSet);
// m_playlist->emptyPlayList();
// m_playlist->resetAllChannels();
// m_playlistman->deletePlayList(m_playlist);
return true;
}
*/
bool ShapesExporter::saveOneImage(const string &filename)
{
CBitmap btm;
@ -543,21 +725,49 @@ bool ShapesExporter::saveOneImage(const string &filename)
nlwarning("can't create %s", filename.c_str());
return false;
}
return true;
}
bool ShapesExporter::renderShape(UTransform &entity, const CVector &axis, const string &output_path)
bool ShapesExporter::renderShape(UTransform &entity, const string &output_path)
{
CQuat quat(0.f, 0.f, 0.f, 0.f);
CVector axis1 = CVector::J, axis2 = CVector::K;
int orientation1 = -1, orientation2 = 1;
NL3D::UInstance inst;
inst.cast(entity);
if (!inst.empty())
{
// inst.getDefaultRotQuat(quat);
inst.getRotQuat(quat);
/* if (!quat.getAxis().isNull())
{
CVector a = quat.getAxis();
if (a.z != 0 && a.x == 0.f)
{
axis1 = CVector::J;
orientation1 = -1;
}
if (a.y != 0.f)
{
axis2 = CVector::J;
}
}
*/
}
// main loop
for (uint step_z = 0; step_z < settings.output_steps_z; ++step_z)
{
CQuat z(axis, (float)step_z * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_z));
CQuat z(axis1, orientation1 * (float)step_z * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_z));
for (uint step_x = 0; step_x < settings.output_steps_x; ++step_x)
{
CQuat x(CVector::K, (float)step_x * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_x));
CQuat x(axis2, orientation2 * (float)step_x * ((float)NLMISC::Pi*2.f / (float)settings.output_steps_x));
entity.setRotQuat(z * x);
entity.setRotQuat(quat * z * x);
string filename = CPath::standardizePath(output_path) + toString("%03d_%03d.%s", step_z, step_x, settings.output_format.c_str());
@ -729,3 +939,65 @@ bool ShapesExporter::createThumbnail(const string &filename, const string &path)
return true;
}
std::string ShapesExporter::findSkeleton(const std::string &shape)
{
std::string baseFilename = CFile::getFilenameWithoutExtension(shape);
// work in 60% of cases
std::string skeleton = CPath::lookup(baseFilename + ".skel", false, false, false);
if (!skeleton.empty())
return skeleton;
// remove last part
size_t pos = baseFilename.rfind("_");
if (pos != std::string::npos)
{
skeleton = CPath::lookup(baseFilename.substr(0, pos) + ".skel", false, false, false);
if (!skeleton.empty())
return skeleton;
pos = baseFilename.find("_");
std::vector<std::string> filenames;
CPath::getFileListByName("skel", baseFilename.substr(pos), filenames);
if (filenames.size() == 1)
{
skeleton = filenames[0];
return skeleton;
}
}
int gender = 0;
if (baseFilename.find("_hom_") != std::string::npos)
{
gender = 1;
}
else if (baseFilename.find("_hof_") != std::string::npos)
{
gender = 2;
}
// bipeds
if (gender > 0)
{
// karavan
if (baseFilename.find("ca_") == 0)
return gender == 1 ? "ca_hom_armor01.skel":"ca_hof_armor01.skel";
return gender == 1 ? "fy_hom_skel.skel":"fy_hof_skel.skel";
}
nlwarning("can't find skeleton for %s", shape.c_str());
// goo mobs
// CPath::getFileListByName("max", "_hof_", filenames);
return "";
}

View file

@ -26,6 +26,7 @@ struct Settings
{
Settings();
std::string input_path;
std::string output_path;
std::string preview_format;
@ -56,18 +57,19 @@ public:
bool init();
bool parseConfigFile(const std::string &filename);
bool setupLight();
bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction);
bool exportShape(const std::string &filename, const std::string &output_path);
bool exportSkeleton(const std::string &skeleton, const std::vector<std::string> &parts, const std::string &output_path);
void setCamera(NLMISC::CAABBox &bbox, NL3D::UInstance &entity, bool high_z=false);
void setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z=false);
bool saveOneImage(const std::string &output_path);
bool renderShape(NL3D::UTransform &entity, const NLMISC::CVector &axis, const std::string &output_path);
bool renderShape(NL3D::UTransform &entity, const std::string &output_path);
bool renderPS(NL3D::UInstance &entity, const std::string &output_path, double &duration, NLMISC::CAABBox &bbox);
bool createThumbnail(const std::string &filename, const std::string &path);
static std::string findSkeleton(const std::string &shape);
Settings settings;
NL3D::UDriver* Driver;
NL3D::UScene* Scene;

View file

@ -395,6 +395,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml_packer", "misc\xml_pack
{44B21233-EFCC-4825-B5E5-3A3BD6CC5516} = {44B21233-EFCC-4825-B5E5-3A3BD6CC5516}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shapes_exporter", "3d\shapes_exporter\shapes_exporter.vcproj", "{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}"
ProjectSection(ProjectDependencies) = postProject
{2B48BE83-108B-4E8E-8A55-6627CF09AC5A} = {2B48BE83-108B-4E8E-8A55-6627CF09AC5A}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -931,6 +936,14 @@ Global
{222663AE-5BAD-49B3-837F-26A518A3373A}.Release|Win32.Build.0 = Release|Win32
{222663AE-5BAD-49B3-837F-26A518A3373A}.Release|x64.ActiveCfg = Release|x64
{222663AE-5BAD-49B3-837F-26A518A3373A}.Release|x64.Build.0 = Release|x64
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|Win32.ActiveCfg = Debug|Win32
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|Win32.Build.0 = Debug|Win32
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|x64.ActiveCfg = Debug|x64
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Debug|x64.Build.0 = Debug|x64
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|Win32.ActiveCfg = Release|Win32
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|Win32.Build.0 = Release|Win32
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|x64.ActiveCfg = Release|x64
{F8607267-5BA2-4BE8-A674-26C3F7D0A9BB}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -1396,7 +1396,7 @@ void CCharacterCL::updateVisualPropertyBehaviour(const NLMISC::TGameCycle &gameC
// New Behaviour Received.
CBehaviour beh(prop);
if(verboseVP(this))
nlinfo("(%05d,%03d) CH::updateVPBeha:%d: '%s(%d)' received.", sint32(T1%100000), NetMngr.getCurrentServerTick(), _Slot, behaviourToString(beh.Behaviour).c_str(), beh.Behaviour);
nlinfo("(%05d,%03d) CH::updateVPBeha:%d: '%s(%d)' received.", sint32(T1%100000), NetMngr.getCurrentServerTick(), _Slot, behaviourToString((EBehaviour)beh.Behaviour).c_str(), beh.Behaviour);
// Add in right stage.
_Stages.addStage(gameCycle, PROPERTY_BEHAVIOUR, prop);
@ -2219,7 +2219,11 @@ void CCharacterCL::endAnimTransition()
// If the animation is a rotation, set the character direction he should have at the end of the animation.
if(_CurrentState->Rotation)
{
if(isUser()) nldebug("<CCharacterCL::endAnimTransition> rotation : set dir as end anim dir");
if(isUser())
{
nldebug("<CCharacterCL::endAnimTransition> rotation : set dir as end anim dir");
}
dir(dirEndAnim());
}
// Fit the current direction to the target when attacking.
@ -4173,6 +4177,8 @@ void CCharacterCL::performCurrentAttackEnd(const CBehaviourContext &bc, bool dir
}
}
break;
default:
break;
}
// if object has a list of cast rays, then we assume it is a static object (like guard towers)
@ -4671,7 +4677,7 @@ void CCharacterCL::applyBehaviour(const CBehaviourContext &bc) // virtual
// INFO : display some debug informations.
if((VerboseAnimUser && _Slot==0) || (VerboseAnimSelection && _Slot == UserEntity->selection()))
nlinfo("CH:applyBeh:%d: '%d(%s)'", _Slot, behaviour.Behaviour, behaviourToString(behaviour.Behaviour).c_str());
nlinfo("CH:applyBeh:%d: '%d(%s)'", _Slot, behaviour.Behaviour, behaviourToString((EBehaviour)behaviour.Behaviour).c_str());
// ***** Apply the behaviour according to type
@ -4730,6 +4736,8 @@ void CCharacterCL::applyBehaviour(const CBehaviourContext &bc) // virtual
case MBEHAV::CAST_MIX_LINK:
endCast(behaviour, previousBehaviour);
break;
default:
break;
}
// DeltaHP
applyBehaviourFlyingHPs(bc, behaviour, targetHitDates);
@ -6668,7 +6676,9 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime &currentTimeInMs, CEntityCL
// Else : There is no move.
}
else
{
CHECK(posInStage==false && dist2Dest()<=0.0);
}
// If there is no position in the next stage and the stage should be done already.
if(!_Stages._StageSet.empty() && !posInStage && !stageReach && !allToFirstPos && ((_LastFrameTime+loopTimeStep) >= stageTime))
@ -6682,7 +6692,7 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime &currentTimeInMs, CEntityCL
if(loopTimeStep < 0.0)
loopTimeStep = 0.0;
//
// \todo GUIGUI : ajuster le timeOffset comme on arrete la boucle avant l'heure
// \todo GUIGUI : adjust timeOffset, because we stopped the loop before
//
// Stage complete.
stageReach = true;

View file

@ -139,7 +139,10 @@ void CSeasonFXSheet::build(const NLGEORGES::UFormElm &item, NLMISC::CSheetId par
NLMISC::clamp(MinDuration, 0.f, CycleDuration /*- startHourMaxInterval*/);
NLMISC::clamp(MaxDuration, 0.f, CycleDuration /*- startHourMaxInterval*/);
if (!ok) nldebug("Key not found.");
if (!ok)
{
nldebug("Key not found.");
}
}
//=======================================================
@ -210,10 +213,11 @@ void CPlantSheet::build(const NLGEORGES::UFormElm &item)
{
if(!(item.getValueByName(_ShapeName, "3D.Shape") &&
item.getValueByName(_MaxDist, "3D.MaxDist") &&
item.getValueByName(_CoarseMeshDist, "3D.CoarseMeshDist")
)
)
nldebug("Key not found.");
item.getValueByName(_CoarseMeshDist, "3D.CoarseMeshDist")))
{
nldebug("Key not found.");
}
// serial fxs by season
SeasonFX[EGSPD::CSeason::Spring].build(item, Id, "3D.SpringFX.");
SeasonFX[EGSPD::CSeason::Summer].build(item, Id, "3D.SummerFX.");

View file

@ -890,7 +890,7 @@ NLMISC_COMMAND(db, "Modify Database","<Property> <Value>")
static bool talkInChan(uint32 nb,std::vector<std::string>args)
{
uint32 maxChans = CChatGroup::MaxDynChanPerPlayer;
if (nb<0||nb>=maxChans)
if (nb>=maxChans)
{
return false;
}

View file

@ -377,6 +377,7 @@ void CLoginStateMachine::run()
{
mustReboot = CPatchManager::getInstance()->mustLaunchBatFile();
}
if (mustReboot)
{
// skip eula and show reboot screen

View file

@ -239,7 +239,8 @@ void CBotChatManager::debugLocalReceiveMissionInfo()
{
viewTextID->setTextId(infos.Prerequisits[i].Description);
}
/*if (!help->ScrollTextGroup.empty())
#if 0
if (!help->ScrollTextGroup.empty())
{
CInterfaceGroup *viewTextGroup = help->HelpWindow->getGroup(help->ScrollTextGroup);
if (viewTextGroup)
@ -248,8 +249,8 @@ void CBotChatManager::debugLocalReceiveMissionInfo()
CInterfaceGroup *viewTextGroup = help->HelpWindow->getGroup(help->ScrollTextIdGroup);
if (viewTextGroup)
viewTextGroup->setActive(true);
*/
/* }
#endif
}
_MissionHelpWindowsWaiting.erase(index);
}

View file

@ -69,9 +69,9 @@ extern CClientChatManager ChatMngr;
CChatWindowDesc::CChatWindowDesc() : InsertPosition(-1),
ParentBlink(false),
Listener(NULL),
Savable(false),
Localize(false)
Localize(false),
Listener(NULL)
{
}
@ -80,7 +80,7 @@ CChatWindowDesc::CChatWindowDesc() : InsertPosition(-1),
/////////////////
//=================================================================================
CChatWindow::CChatWindow() : _Listener(NULL), _Chat(NULL), _ParentBlink(false), _EB(NULL)
CChatWindow::CChatWindow() : _Listener(NULL), _Chat(NULL), _EB(NULL), _ParentBlink(false)
{
}

View file

@ -49,7 +49,7 @@ struct CChatWindowDesc
ucstring Title; // unique title for the window
std::string FatherContainer; // name of the father container. If empty, the chat box must be added manually in the hierarchy
std::string ChatTemplate; // Template for the chat interface, or "" to use the default one
TTemplateParams ChatTemplateParams; // optional tempalte parameters
TTemplateParams ChatTemplateParams; // optional template parameters
sint InsertPosition; // [optional] -1 if the chat box should be inserted at the end of the container list, or the index otherwise
bool ParentBlink; // [optional] when true, make the parent group blink
bool Savable; // should the position of the chat box be saved between session ? Default is false

View file

@ -192,6 +192,8 @@ void CCtrlButton::draw ()
}
}
break;
default:
break;
}
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);

View file

@ -342,6 +342,8 @@ void CCtrlTextButton::draw ()
}
}
break;
default:
break;
}
// *** Draw

View file

@ -126,7 +126,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
// get item size.
CViewRenderer &rVR = pIM->getViewRenderer();
sint32 dispSlotBmpId;
sint32 dispSlotBmpId = 0;
switch(_CtrlInfo._Type)
{
case CCtrlSheetInfo::SheetType_Auto:
@ -144,6 +144,7 @@ bool CDBGroupListSheetText::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
case CCtrlSheetInfo::SheetType_Macro: dispSlotBmpId = rVR.getTextureIdFromName ("w_slot_brick.tga"); break;
case CCtrlSheetInfo::SheetType_GuildFlag: dispSlotBmpId = rVR.getTextureIdFromName ("w_slot_blason.tga"); break;
case CCtrlSheetInfo::SheetType_ElevatorDestination: dispSlotBmpId = rVR.getTextureIdFromName ("w_slot_blason.tga"); break;
default: break;
}
rVR.getTextureSizeFromId (dispSlotBmpId, _WSlot, _HSlot);

View file

@ -2475,13 +2475,12 @@ void CGroupHTML::setTitle (const ucstring &title)
CInterfaceElement *parent = getParent();
if (parent)
{
if (parent = parent->getParent())
parent = parent->getParent();
CGroupContainer *container = dynamic_cast<CGroupContainer*>(parent);
if (container)
{
CGroupContainer *container = dynamic_cast<CGroupContainer*>(parent);
if (container)
{
container->setUCTitle (title);
}
container->setUCTitle (title);
}
}
}

View file

@ -615,6 +615,8 @@ void CGroupTable::updateCoords()
alignmentX = _Columns[column].Width - cell->WidthMax;
widthReduceX = alignmentX;
break;
default:
break;
}
}
@ -665,6 +667,8 @@ void CGroupTable::updateCoords()
case CGroupCell::Bottom:
alignmentY = _Rows[row].Height - (sint32)cell->Group->getH();
break;
default:
break;
}
}

View file

@ -123,6 +123,8 @@ static bool affect(const CInterfaceExprValue &value, CInterfaceElement &destElem
return false;
}
break;
default:
break;
}
return true;

View file

@ -2907,7 +2907,7 @@ bool CInterfaceManager::handleEvent (const CEventDescriptor& event)
// window handling. if not handled by a control
if (!handled)
{
if ((pNewCurrentWnd != NULL) && _ModalStack.empty() || (!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd))
if (((pNewCurrentWnd != NULL) && _ModalStack.empty()) || ((!_ModalStack.empty() && _ModalStack.back().ModalWindow == pNewCurrentWnd)))
{
CEventDescriptorMouse ev2 = eventDesc;
sint32 x= eventDesc.getX(), y = eventDesc.getY();

View file

@ -61,7 +61,7 @@ class CNPCMissionGiverDesc
public:
/// Constructor
CNPCMissionGiverDesc() : _MissionGiverState(NPC_ICON::AwaitingFirstData), _IsDescTransient(true), _HasChanged(false)
CNPCMissionGiverDesc() : _MissionGiverState(NPC_ICON::AwaitingFirstData), _LastUpdateTimestamp(0), _IsDescTransient(true), _HasChanged(false)
{}
// Current assignment operator: bitwise copy

View file

@ -66,7 +66,7 @@
#include "../../far_tp.h"
#include "../../net_manager.h"
#include "zlib.h"
#include <zlib.h>

View file

@ -220,10 +220,16 @@ void releaseMainLoopReselect()
// Remove all entities.
if (Driver)
{
nldebug("RCSR1: %u textures", Driver->getTotalAsyncTextureSizeAsked());
}
EntitiesMngr.release();
if (Driver)
{
nldebug("RCSR2: %u textures", Driver->getTotalAsyncTextureSizeAsked());
}
// Reset Fx manager (must be done after EntitiesMngr.release()) Important because may still point to 3D elements
FXMngr.reset();
@ -266,11 +272,17 @@ void releaseMainLoopReselect()
// Release the Entities Animation Manager (Yoyo: fuckingly important because keep a pointer
// on a _PlayListManager that is created from Scene)
if (Driver)
{
nldebug("RCSR3: %u textures", Driver->getTotalAsyncTextureSizeAsked());
}
CEntityAnimationManager::delInstance();
EAM= NULL;
if (Driver)
{
nldebug("RCSR4: %u textures", Driver->getTotalAsyncTextureSizeAsked());
}
// Not necessary I think because owns only static data (string + function ptrs)
// --releaseContextualCursor();

View file

@ -1,6 +1,5 @@
/* 7zAlloc.c */
#include "nel/misc/types_nl.h"
#include <stdlib.h>
#include "7zAlloc.h"

View file

@ -1,7 +1,5 @@
/* 7zBuffer.c */
#include "nel/misc/types_nl.h"
#include "7zBuffer.h"
#include "7zAlloc.h"

View file

@ -1,6 +1,5 @@
/* 7zCrc.c */
#include "nel/misc/types_nl.h"
#include "7zCrc.h"
#define kCrcPoly 0xEDB88320

View file

@ -14,7 +14,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/misc/types_nl.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View file

@ -3,8 +3,6 @@
#ifndef __COMMON_TYPES_H
#define __COMMON_TYPES_H
#include "nel/misc/types_nl.h"
#ifndef _7ZIP_BYTE_DEFINED
#define _7ZIP_BYTE_DEFINED
typedef unsigned char Byte;

View file

@ -19,11 +19,11 @@ TARGET_LINK_LIBRARIES(ryzom_sevenzip ${PLATFORM_LINKFLAGS})
SET_TARGET_PROPERTIES(ryzom_sevenzip PROPERTIES VERSION ${NL_VERSION})
IF(WIN32)
SET_TARGET_PROPERTIES(seven_zip
SET_TARGET_PROPERTIES(ryzom_sevenzip
PROJECT_LABEL "Library: Seven Zip"
DEBUG_POSTFIX "_d"
RELEASE_POSTFIX "_r"
LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt"
LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt")
ENDIF(WIN32)
ADD_DEFINITIONS(-D_SZ_ONE_DIRECTORY)

View file

@ -1,6 +1,5 @@
/* LzmaRamDecode.c */
#include "nel/misc/types_nl.h"
#include "LzmaRamDecode.h"
#ifdef _SZ_ONE_DIRECTORY
#include "LzmaDecode.h"

View file

@ -10,8 +10,6 @@ This file is part of LZMA SDK 4.40 (2006-05-01)
#ifndef __LZMATYPES_H
#define __LZMATYPES_H
#include "nel/misc/types_nl.h"
#ifndef _7ZIP_BYTE_DEFINED
#define _7ZIP_BYTE_DEFINED
typedef unsigned char Byte;

View file

@ -85,7 +85,7 @@ private:
void CGenericRequestIdRegister::pushRequestId(uint32 requestId,const std::string& fileName)
{
// check for out of order entries in the request list
BOMB_IF(!_RequestIds.empty() && uint32(requestId-_RequestIds.back().RequestId)<0,"Ignoring out of order request id in generic callback registration for file "+CSString(fileName).quote(),return);
BOMB_IF(!_RequestIds.empty() && ((sint32)requestId-(sint32)_RequestIds.back().RequestId)<0,"Ignoring out of order request id in generic callback registration for file "+CSString(fileName).quote(),return);
// setup a new record for this request id / file name pair
SRequestId theNewRequestId;

View file

@ -174,7 +174,7 @@ uint32 CBackupInterfaceSingleton::pushGenericAckCallback(NLMISC::CSmartPtr<IBack
++_Counter;
if (!_GenericResponses.empty())
{
nlassert((_GenericResponses.front().first-requestId)<0);
nlassert(((sint32)_GenericResponses.front().first-(sint32)requestId)<0);
}
// if we have no callback then just return the generated request Id...

View file

@ -46,7 +46,7 @@ static std::string pactTypeStrings[]=
const std::string& toString (EPactNature pactNature)
{
if (pactNature >= sizeof(pactNatureStrings)/sizeof(string) )
if ((uint)pactNature >= sizeof(pactNatureStrings)/sizeof(string) )
{
nlwarning("<toString (EPactNature pactNature) : invalid pact nature %d",pactNature);
return pactNatureStrings[(uint)Unknown];
@ -56,7 +56,7 @@ const std::string& toString (EPactNature pactNature)
const std::string& toString (EPactType pactType)
{
if (pactType >= sizeof(pactTypeStrings)/sizeof(string) )
if ((uint)pactType >= sizeof(pactTypeStrings)/sizeof(string) )
{
nlwarning("<toString (EPactType pactType) : invalid pact type %d",pactType);
return pactTypeStrings[(uint)UnknownType];

View file

@ -962,7 +962,7 @@ bool CPersistentDataRecord::fromXML(const std::string& s)
// we have a buffer of xml-like blocks so we're going to start by chunking it up (from the back)
vector<CSString> clauses;
bool clauseOpen=false;
uint32 clauseEnd;
uint32 clauseEnd = 0;
for (uint32 i=len;i--;)
{
switch(buff[i])

View file

@ -1,18 +1,7 @@
//////////////////////////
//////////////////////////
/// CLIENT CONFIG FILE ///
//////////////////////////
//////////////////////////
FullScreen = 0;
Width = 800;
Height = 600;
PositionX = 0;
PositionY = 0;
Frequency = 60;
Depth = 32;
Sleep = -1;
Contrast = 0.0; // -1.0 ~ 1.0
Luminosity = 0.0; // -1.0 ~ 1.0
Gamma = 0.0; // -1.0 ~ 1.0
/////////////////////////////////
/////////////////////////////////
/// SHEETS PACKER CONFIG FILE ///
/////////////////////////////////
/////////////////////////////////
DataPath = { "../../common/data_leveldesign", "../../common/data_common", "../../client/data" };
LigoPrimitiveClass = "world_editor_classes.xml";

View file

@ -65,50 +65,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmdline,
int main(int argc, char **argv)
#endif
{
/*
#if defined(NL_OS_WINDOWS)
// extract the 2 first param (argv[1] and argv[2]) it must be cookie and addr
string cmd = cmdline;
std::string::size_type pos1 = cmd.find_first_not_of (' ');
std::string::size_type pos2;
if (pos1 != string::npos)
{
pos2 = cmd.find (' ', pos1);
if(pos2 != string::npos)
{
cookie = cmd.substr (pos1, pos2-pos1);
pos1 = cmd.find_first_not_of (' ', pos2);
if (pos1 != string::npos)
{
pos2 = cmd.find (' ', pos1);
if(pos2 == string::npos)
{
fsaddr = cmd.substr (pos1);
}
else if (pos1 != pos2)
{
fsaddr = cmd.substr (pos1, pos2-pos1);
}
}
}
}
#else
if (argc>=3)
{
cookie = argv[1];
fsaddr = argv[2];
}
nlinfo ("From command line (argc=%d): cookie '%s' addr '%s'", argc, cookie.c_str (), fsaddr.c_str());
#endif
*/
/////////////////////////////////
// Initialize the application. //
try

View file

@ -22,21 +22,12 @@
/////////////
#include "stdpch.h"
#if defined(NL_OS_WINDOWS)
#include <windows.h>
#endif
// Misc.
#include "nel/misc/config_file.h"
#include "nel/misc/bit_mem_stream.h"
// Client.
#include "sheets_packer_cfg.h"
#include "debug_client.h"
// 3D Interface.
//#include "nel/3d/u_driver.h"
//#include "nel/3d/u_scene.h"
// Game Share.
#include "game_share/time_weather_season/time_and_season.h"
///////////
// MACRO //
@ -138,7 +129,6 @@
// USING //
///////////
using namespace NLMISC;
//using namespace NL3D;
////////////
@ -148,13 +138,6 @@ CClientConfig AppCfg;
const std::string ConfigFileName = "sheets_packer.cfg";
////////////
// EXTERN //
////////////
//extern NL3D::UScene *Scene;
//extern NL3D::UDriver *Driver;
extern CRyzomTime RT;
/////////////
// METHODS //
/////////////
@ -165,17 +148,6 @@ extern CRyzomTime RT;
CClientConfig::CClientConfig()
{
SaveConfig = false;
PositionX = 0;
PositionY = 0;
Frequency = 60;
Windowed = false; // Default is windowed mode.
Width = 800; // Default Width for the window.
Height = 600; // Default Height for the window.
Depth = 32; // Default Bit per Pixel.
Contrast = 0.f; // Default Monitor Contrast.
Luminosity = 0.f; // Default Monitor Luminosity.
Gamma = 0.f; // Default Monitor Gamma.
PreDataPath.push_back("../../client/data/gamedev/language/"); // Default Path for the language data
DataPath.push_back("../../client/data/"); // Default Path for the Data.
DataPath.push_back("../../common/data_leveldesign/"); // Default Path for the Level Design Directory.
DataPath.push_back("../../common/data_common/"); // Default Path for the Level Design Directory.
@ -197,69 +169,8 @@ void setValues()
CConfigFile::CVar *varPtr = 0;
///////////////////
// WINDOW CONFIG //
// Mode.
// SaveConfig
varPtr = AppCfg.ConfigFile.getVarPtr ("SaveConfig");
if (varPtr)
AppCfg.SaveConfig = varPtr->asInt() ? true : false;
else
nlwarning ("Default value used for 'SaveConfig' !!!");
// Window Positon
varPtr = AppCfg.ConfigFile.getVarPtr ("PositionX");
if (varPtr)
AppCfg.PositionX = varPtr->asInt();
else
nlwarning ("Default value used for 'PositionX' !!!");
varPtr = AppCfg.ConfigFile.getVarPtr ("PositionY");
if (varPtr)
AppCfg.PositionY = varPtr->asInt();
else
nlwarning ("Default value used for 'PositionY' !!!");
// Window frequency
varPtr = AppCfg.ConfigFile.getVarPtr ("Frequency");
if (varPtr)
AppCfg.Frequency = varPtr->asInt();
else
nlwarning ("Default value used for 'Frequency' !!!");
try
{
CConfigFile::CVar &cvFullScreen = AppCfg.ConfigFile.getVar("FullScreen");
AppCfg.Windowed = cvFullScreen.asInt() ? false : true;
}
catch(EUnknownVar &) {nlwarning("Default value used for 'Fullscreen' !!!");}
// Width
READ_INT(Width)
// Height
READ_INT(Height)
// Depth : Bit Per Pixel
READ_INT(Depth)
// Contrast
READ_FLOAT(Contrast)
// Luminosity
READ_FLOAT(Luminosity)
// Gamma
READ_FLOAT(Gamma)
//////////
// MISC //
// Pre Data Path.
try
{
CConfigFile::CVar &cvPreDataPath = AppCfg.ConfigFile.getVar("PreDataPath");
AppCfg.PreDataPath.clear ();
for (uint i = 0; i < cvPreDataPath.size(); i++)
AppCfg.PreDataPath.push_back(cvPreDataPath.asString(i));
}
catch(EUnknownVar &) {nlwarning("Default value used for 'PreDataPath' !!!");}
// Data Path.
try
{
@ -314,35 +225,7 @@ void setValues()
// LanguageCode
READ_STRING(LanguageCode)
READ_BOOL(FPExceptions)
//////////
// INIT //
// FPU
#ifdef NL_OS_WINDOWS
if(AppCfg.FPExceptions)
_control87(_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
else
_control87(_EM_INVALID|_EM_DENORMAL|_EM_ZERODIVIDE|_EM_OVERFLOW|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
#endif // NL_OS_WINDOWS
/* if(Driver)
{
// Set the monitor color properties
CMonitorColorProperties monitorColor;
for(uint i=0; i<3; i++)
{
monitorColor.Contrast[i] = AppCfg.Contrast;
monitorColor.Luminosity[i] = AppCfg.Luminosity;
monitorColor.Gamma[i] = AppCfg.Gamma;
}
if(!Driver->setMonitorColorProperties(monitorColor))
nlwarning("reloadCFG: setMonitorColorProperties fails");
}
*/
}// load //
@ -355,41 +238,6 @@ void CClientConfig::serial(class NLMISC::IStream &f) throw(NLMISC::EStream)
// Start the opening of a new node named ClientCFG.
f.xmlPush("ClientCFG");
f.xmlPushBegin("Windowed");
f.xmlPushEnd();
f.serial(Windowed);
f.xmlPop();
f.xmlPushBegin("Width");
f.xmlPushEnd();
f.serial(Width);
f.xmlPop();
f.xmlPushBegin("Height");
f.xmlPushEnd();
f.serial(Height);
f.xmlPop();
f.xmlPushBegin("Depth");
f.xmlPushEnd();
f.serial(Depth);
f.xmlPop();
f.xmlPushBegin("Contrast");
f.xmlPushEnd();
f.serial(Contrast);
f.xmlPop();
f.xmlPushBegin("Luminosity");
f.xmlPushEnd();
f.serial(Luminosity);
f.xmlPop();
f.xmlPushBegin("Gamma");
f.xmlPushEnd();
f.serial(Gamma);
f.xmlPop();
// Close the serial for hte Client CFG.
f.xmlPop();
}// serial //
@ -412,52 +260,13 @@ void CClientConfig::init(const std::string &configFileName)
//-----------------------------------------------
// init :
// release :
//-----------------------------------------------
void CClientConfig::release ()
{
// Do we have to save the cfg file ?
if (AppCfg.SaveConfig)
{
// Are we in window mode ?
if (AppCfg.Windowed)
{
/* // Driver still alive ?
if (Driver && Driver->isActive ())
{
#ifdef NL_OS_WINDOWS
HWND hWnd = (HWND)Driver->getDisplay ();
// Get the window position
RECT window;
RECT client;
GetWindowRect (hWnd, &window);
GetClientRect (hWnd, &client);
// Save values
try
{
CConfigFile::CVar *varPtr = AppCfg.ConfigFile.getVarPtr ("PositionX");
if (varPtr)
varPtr->setAsInt (window.left);
varPtr = AppCfg.ConfigFile.getVarPtr ("PositionY");
if (varPtr)
varPtr->setAsInt (window.top);
varPtr = AppCfg.ConfigFile.getVarPtr ("Width");
if (varPtr)
varPtr->setAsInt (client.right - client.left);
varPtr = AppCfg.ConfigFile.getVarPtr ("Height");
if (varPtr)
varPtr->setAsInt (client.bottom - client.top);
}
catch (Exception &e)
{
nlwarning ("Error while set config file variables : %s", e.what ());
}
#endif // NL_OS_WINDOWS
}
*/ }
// Save it
AppCfg.ConfigFile.save ();
}

View file

@ -43,29 +43,7 @@ struct CClientConfig
/// Save the cfg file when exit the client ?
bool SaveConfig;
/// Window position in windowed mode
sint PositionX;
sint PositionY;
/// Window frequency
uint Frequency;
/// Application start in a window or in fullscreen.
bool Windowed;
/// Width for the Application.
uint16 Width;
/// Height for the Application.
uint16 Height;
/// Bit Per Pixel (only used in Fullscreen mode).
uint16 Depth;
/// Monitor Constrast [-1 ~ 1], default 0
float Contrast;
/// Monitor Luminosity [-1 ~ 1], default 0
float Luminosity;
/// Monitor Gamma [-1 ~ 1], default 0
float Gamma;
/// Pre Data Path.
std::vector<std::string> PreDataPath;
/// Data Path.
std::vector<std::string> DataPath;
/// True if we want the packed sheet to be updated if needed

View file

@ -81,26 +81,6 @@ bool init()
nlinfo("Loading config file...");
AppCfg.init(ConfigFileName);
/*
// Create the driver (most important part of the client).
nlinfo("Creating 3d driver...");
Driver = UDriver::createDriver ();
if(Driver == 0)
{
nlerror("sheets_packer_init: Cannot create a Driver.");
return false;
}
UDriver::CMode mode;
mode.Windowed = AppCfg.Windowed;
mode.Depth = AppCfg.Depth;
mode.Width = AppCfg.Width;
mode.Height = AppCfg.Height;
// Set the mode of the window.
Driver->setDisplay(mode);
*/
// Define the root path that contains all data needed for the application.
nlinfo("Adding search paths...");
for(uint i = 0; i < AppCfg.DataPath.size(); i++)

View file

@ -21,27 +21,17 @@
// INCLUDE //
/////////////
#include "stdpch.h"
// Misc.
#include "nel/misc/debug.h"
// 3D Interface.
//#include "nel/3d/u_driver.h"
// Client
#include "sheets_packer_release.h"
#include "nel/misc/debug.h"
///////////
// USING //
///////////
//using namespace NL3D;
using namespace NLMISC;
////////////
// EXTERN //
////////////
//extern UDriver *Driver;
///////////////
// FUNCTIONS //
///////////////
@ -51,20 +41,9 @@ using namespace NLMISC;
//---------------------------------------------------
void release()
{
// Delete the driver.
/* if(Driver)
{
// Release Scene, textcontexts, materials, ...
Driver->release();
// Delete the driver.
delete Driver;
Driver = 0;
}
*/
DebugLog->removeDisplayer ("CLIENT.LOG");
InfoLog->removeDisplayer ("CLIENT.LOG");
WarningLog->removeDisplayer ("CLIENT.LOG");
ErrorLog->removeDisplayer ("CLIENT.LOG");
AssertLog->removeDisplayer ("CLIENT.LOG");
DebugLog->removeDisplayer ("SHEETS_PACKER.LOG");
InfoLog->removeDisplayer ("SHEETS_PACKER.LOG");
WarningLog->removeDisplayer ("SHEETS_PACKER.LOG");
ErrorLog->removeDisplayer ("SHEETS_PACKER.LOG");
AssertLog->removeDisplayer ("SHEETS_PACKER.LOG");
}// release //