many changes

* Fixes in WIN32 platform
* Remove unused files
* Make StaticText work more like tibia
* Fix WIN32 compilation
* Fix regression in framebuffers that caused battle to disappear
* Shader fixes for DX9
* Add two new shaders: noise and heat
This commit is contained in:
Eduardo Bart
2012-06-15 19:18:30 -03:00
parent 10b60a3871
commit 4813b7eb4b
19 changed files with 203 additions and 177 deletions

View File

@@ -22,8 +22,7 @@ ELSE()
SET(ARCH_FLAGS "-m32 -march=i686 -mtune=generic")
ENDIF()
SET(WARNS_FLAGS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable")
SET(SECURE_FLAGS "-fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNS} ${SECURE_FLAGS} ${ARCH_FLAGS} -std=gnu++0x -pipe")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNS} ${ARCH_FLAGS} -std=gnu++0x -pipe")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -ggdb -fno-omit-frame-pointer")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")

View File

@@ -60,6 +60,7 @@ void Painter::refreshState()
void Painter::saveState()
{
assert(m_oldStateIndex<10);
m_olderStates[m_oldStateIndex].resolution = m_resolution;
m_olderStates[m_oldStateIndex].projectionMatrix = m_projectionMatrix;
m_olderStates[m_oldStateIndex].textureMatrix = m_textureMatrix;
m_olderStates[m_oldStateIndex].color = m_color;
@@ -69,7 +70,6 @@ void Painter::saveState()
m_olderStates[m_oldStateIndex].shaderProgram = m_shaderProgram;
m_olderStates[m_oldStateIndex].texture = m_texture;
m_olderStates[m_oldStateIndex].alphaWriting = m_alphaWriting;
m_olderStates[m_oldStateIndex].resolution = m_resolution;
m_oldStateIndex++;
}
@@ -82,6 +82,7 @@ void Painter::saveAndResetState()
void Painter::restoreSavedState()
{
m_oldStateIndex--;
setResolution(m_olderStates[m_oldStateIndex].resolution);
setProjectionMatrix(m_olderStates[m_oldStateIndex].projectionMatrix);
setTextureMatrix(m_olderStates[m_oldStateIndex].textureMatrix);
setColor(m_olderStates[m_oldStateIndex].color);
@@ -90,7 +91,7 @@ void Painter::restoreSavedState()
setClipRect(m_olderStates[m_oldStateIndex].clipRect);
setShaderProgram(m_olderStates[m_oldStateIndex].shaderProgram);
setTexture(m_olderStates[m_oldStateIndex].texture);
setResolution(m_olderStates[m_oldStateIndex].resolution);
setAlphaWriting(m_olderStates[m_oldStateIndex].alphaWriting);
}
void Painter::clear(const Color& color)

View File

@@ -44,6 +44,7 @@ public:
};
struct PainterState {
Size resolution;
Matrix3 projectionMatrix;
Matrix3 textureMatrix;
Color color;
@@ -53,7 +54,6 @@ public:
Texture *texture;
PainterShaderProgram *shaderProgram;
bool alphaWriting;
Size resolution;
};
Painter();

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef PAINTERSHADERMANAGER_H
#define PAINTERSHADERMANAGER_H
#include "paintershaderprogram.h"
class PainterShaderManager
{
public:
void init();
void terminate();
PainterShaderProgramPtr createShader();
PainterShaderProgramPtr createTexturedFragmentShader(const std::string& shaderFile);
const PainterShaderProgramPtr& getDrawTexturedProgram() { return m_drawTexturedProgram; }
const PainterShaderProgramPtr& getDrawSolidColorProgram() { return m_drawSolidColorProgram; }
private:
PainterShaderProgramPtr m_drawTexturedProgram;
PainterShaderProgramPtr m_drawSolidColorProgram;
};
extern PainterShaderManager g_shaders;
#endif

View File

@@ -205,6 +205,7 @@ void WIN32Window::init()
internalCreateWindow();
internalCreateGLContext();
internalRestoreGLContext();
}
void WIN32Window::terminate()
@@ -253,7 +254,7 @@ void WIN32Window::internalCreateWindow()
wc.hInstance = m_instance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = m_defaultCursor;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_app->getName().c_str();
@@ -344,8 +345,6 @@ void WIN32Window::internalCreateGLContext()
if(m_eglContext == EGL_NO_CONTEXT )
g_logger.fatal(stdext::format("Unable to create EGL context: %s", eglGetError()));
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
g_logger.fatal("Unable to make current EGL context");
#else
uint pixelFormat;
static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR),
@@ -374,9 +373,6 @@ void WIN32Window::internalCreateGLContext()
if(!(m_wglContext = wglCreateContext(m_deviceContext)))
g_logger.fatal("Unable to create GL context");
if(!wglMakeCurrent(m_deviceContext, m_wglContext))
g_logger.fatal("Unable to set GLX context on WIN32 window");
#endif
}
@@ -406,6 +402,17 @@ void WIN32Window::internalDestroyGLContext()
#endif
}
void WIN32Window::internalRestoreGLContext()
{
#ifdef OPENGL_ES
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
g_logger.fatal("Unable to make current EGL context");
#else
if(!wglMakeCurrent(m_deviceContext, m_wglContext))
g_logger.fatal("Unable to make current WGL context");
#endif
}
bool WIN32Window::isExtensionSupported(const char *ext)
{
#ifdef OPENGL_ES
@@ -707,6 +714,9 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break;
}
if(m_visible && m_deviceContext)
internalRestoreGLContext();
Size size;
size.setWidth(std::max(std::min((int)LOWORD(lParam), 7680), m_minimumSize.width()));
size.setHeight(std::max(std::min((int)HIWORD(lParam), 4320), m_minimumSize.height()));

View File

@@ -38,6 +38,7 @@ class WIN32Window : public PlatformWindow
void internalCreateWindow();
void internalCreateGLContext();
void internalDestroyGLContext();
void internalRestoreGLContext();
void *getExtensionProcAddress(const char *ext);
bool isExtensionSupported(const char *ext);