mirror of
https://github.com/edubart/otclient.git
synced 2025-12-03 00:16:50 +01:00
too many changes to list, many regressions were made, master will be UNSTABLE for a few days
This commit is contained in:
@@ -23,11 +23,8 @@
|
||||
#include "animatedtexture.h"
|
||||
#include "graphics.h"
|
||||
|
||||
#include <framework/platform/platform.h>
|
||||
#include <framework/core/eventdispatcher.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFrames, uchar *framesPixels, int *framesDelay) :
|
||||
Texture(),
|
||||
m_numFrames(numFrames)
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
std::vector<int> m_framesDelay;
|
||||
int m_numFrames;
|
||||
int m_currentFrame;
|
||||
int m_lastAnimCheckTicks;
|
||||
ticks_t m_lastAnimCheckTicks;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define FRAMEWORK_GRAPHICS_DECLARATIONS_H
|
||||
|
||||
#include <framework/global.h>
|
||||
#include "glutil.h"
|
||||
|
||||
class Texture;
|
||||
class AnimatedTexture;
|
||||
|
||||
@@ -24,17 +24,6 @@
|
||||
#include "graphics.h"
|
||||
#include "texture.h"
|
||||
|
||||
#include <framework/platform/platform.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
PFNGLGENFRAMEBUFFERSPROC oglGenFramebuffers = 0;
|
||||
PFNGLBINDFRAMEBUFFERPROC oglBindFramebuffer = 0;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC oglFramebufferTexture2D = 0;
|
||||
PFNGLDELETEFRAMEBUFFERSPROC oglDeleteFramebuffers = 0;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC oglCheckFramebufferStatus = 0;
|
||||
|
||||
FrameBuffer::FrameBuffer(int width, int height)
|
||||
{
|
||||
m_fbo = 0;
|
||||
@@ -46,22 +35,15 @@ FrameBuffer::FrameBuffer(int width, int height)
|
||||
// use FBO ext only if supported
|
||||
if(g_graphics.isExtensionSupported("GL_ARB_framebuffer_object")) {
|
||||
m_fallbackOldImp = false;
|
||||
if(!oglGenFramebuffers) {
|
||||
oglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)g_platform.getExtensionProcAddress("glGenFramebuffers");
|
||||
oglBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)g_platform.getExtensionProcAddress("glBindFramebuffer");
|
||||
oglFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)g_platform.getExtensionProcAddress("glFramebufferTexture2D");
|
||||
oglDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)g_platform.getExtensionProcAddress("glDeleteFramebuffers");
|
||||
oglCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)g_platform.getExtensionProcAddress("glCheckFramebufferStatus");
|
||||
}
|
||||
|
||||
// generate FBO
|
||||
oglGenFramebuffers(1, &m_fbo);
|
||||
oglBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
|
||||
glGenFramebuffers(1, &m_fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
|
||||
|
||||
// attach 2D texture to this FBO
|
||||
oglFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture->getId(), 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture->getId(), 0);
|
||||
|
||||
GLenum status = oglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
|
||||
switch(status) {
|
||||
case GL_FRAMEBUFFER_COMPLETE_EXT:
|
||||
//ok
|
||||
@@ -72,7 +54,7 @@ FrameBuffer::FrameBuffer(int width, int height)
|
||||
}
|
||||
|
||||
// restore back buffer
|
||||
oglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDrawBuffer(GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
} else {
|
||||
@@ -87,14 +69,14 @@ FrameBuffer::FrameBuffer(int width, int height)
|
||||
FrameBuffer::~FrameBuffer()
|
||||
{
|
||||
if(m_fbo)
|
||||
oglDeleteFramebuffers(1, &m_fbo);
|
||||
glDeleteFramebuffers(1, &m_fbo);
|
||||
}
|
||||
|
||||
void FrameBuffer::bind()
|
||||
{
|
||||
if(!m_fallbackOldImp) {
|
||||
// bind framebuffer
|
||||
oglBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);
|
||||
} else {
|
||||
int screenWidth = g_graphics.getScreenSize().width();
|
||||
int screenHeight = g_graphics.getScreenSize().height();
|
||||
@@ -126,7 +108,7 @@ void FrameBuffer::unbind()
|
||||
{
|
||||
if(!m_fallbackOldImp) {
|
||||
// bind back buffer again
|
||||
oglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDrawBuffer(GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
|
||||
|
||||
@@ -31,13 +31,8 @@ public:
|
||||
FrameBuffer(int width, int height);
|
||||
virtual ~FrameBuffer();
|
||||
|
||||
/// Binds the framebuffer, by switching render buffer to itself, everything rendered will be draw on it
|
||||
void bind();
|
||||
|
||||
/// Unbinds the framebuffer (switch render buffer to back buffer again)
|
||||
void unbind();
|
||||
|
||||
/// Draws framebuffer texture
|
||||
void draw(const Rect& screenCoords, const Rect& framebufferCoords = Rect());
|
||||
|
||||
TexturePtr getTexture() { return m_texture; }
|
||||
|
||||
37
src/framework/graphics/glutil.h
Normal file
37
src/framework/graphics/glutil.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 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 GLUTIL_H
|
||||
#define GLUTIL_H
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#ifndef OPENGL_ES2
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -25,9 +25,6 @@
|
||||
#include <framework/graphics/graphics.h>
|
||||
#include <framework/graphics/texture.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
Graphics g_graphics;
|
||||
|
||||
void Graphics::init()
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
#include "texture.h"
|
||||
#include "graphics.h"
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
Texture::Texture()
|
||||
{
|
||||
m_textureId = 0;
|
||||
@@ -61,7 +58,7 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
|
||||
logError("loading texture with size ", width, "x", height, " failed, "
|
||||
"the maximum size allowed by the graphics card is ", maxTexSize, "x", maxTexSize, ",",
|
||||
"to prevent crashes the texture will be displayed as a blank texture");
|
||||
//TODO: a workground, like bilinear scaling the texture
|
||||
//TODO: make a workaround, could be bilinear scaling the texture
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user