2016-12-23 16:06:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2016-12-22 17:58:29 +00:00
|
|
|
#ifndef OPENGL_ANTIALIASING_H__
|
|
|
|
#define OPENGL_ANTIALIASING_H__
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <gal/opengl/shader.h>
|
|
|
|
#include <math/vector2d.h>
|
|
|
|
|
|
|
|
namespace KIGFX {
|
|
|
|
|
|
|
|
class OPENGL_COMPOSITOR;
|
|
|
|
|
|
|
|
class OPENGL_PRESENTOR
|
|
|
|
{
|
|
|
|
public:
|
2017-01-31 20:35:52 +00:00
|
|
|
virtual ~OPENGL_PRESENTOR()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-22 17:58:29 +00:00
|
|
|
virtual bool Init() = 0;
|
|
|
|
virtual unsigned int CreateBuffer() = 0;
|
|
|
|
|
2023-06-28 20:48:07 +00:00
|
|
|
virtual VECTOR2I GetInternalBufferSize() = 0;
|
2016-12-22 17:58:29 +00:00
|
|
|
virtual void OnLostBuffers() = 0;
|
|
|
|
|
|
|
|
virtual void Begin() = 0;
|
2017-01-11 15:19:58 +00:00
|
|
|
virtual void DrawBuffer( GLuint aBuffer ) = 0;
|
2016-12-22 17:58:29 +00:00
|
|
|
virtual void Present() = 0;
|
|
|
|
};
|
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
|
|
|
|
class ANTIALIASING_NONE : public OPENGL_PRESENTOR
|
|
|
|
{
|
2016-12-22 17:58:29 +00:00
|
|
|
public:
|
|
|
|
ANTIALIASING_NONE( OPENGL_COMPOSITOR* aCompositor );
|
|
|
|
|
|
|
|
bool Init() override;
|
|
|
|
unsigned int CreateBuffer() override;
|
|
|
|
|
2023-06-28 20:48:07 +00:00
|
|
|
VECTOR2I GetInternalBufferSize() override;
|
2016-12-22 17:58:29 +00:00
|
|
|
void OnLostBuffers() override;
|
|
|
|
|
|
|
|
void Begin() override;
|
2017-01-11 15:19:58 +00:00
|
|
|
void DrawBuffer( GLuint aBuffer ) override;
|
2016-12-22 17:58:29 +00:00
|
|
|
void Present() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
OPENGL_COMPOSITOR* compositor;
|
|
|
|
};
|
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
|
|
|
|
class ANTIALIASING_SUPERSAMPLING : public OPENGL_PRESENTOR
|
|
|
|
{
|
2016-12-22 19:02:34 +00:00
|
|
|
public:
|
2021-06-09 00:20:41 +00:00
|
|
|
ANTIALIASING_SUPERSAMPLING( OPENGL_COMPOSITOR* aCompositor );
|
2016-12-22 19:02:34 +00:00
|
|
|
|
|
|
|
bool Init() override;
|
|
|
|
unsigned int CreateBuffer() override;
|
|
|
|
|
2023-06-28 20:48:07 +00:00
|
|
|
VECTOR2I GetInternalBufferSize() override;
|
2016-12-22 19:02:34 +00:00
|
|
|
void OnLostBuffers() override;
|
|
|
|
|
|
|
|
void Begin() override;
|
2017-01-11 15:19:58 +00:00
|
|
|
void DrawBuffer( GLuint ) override;
|
2016-12-22 19:02:34 +00:00
|
|
|
void Present() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
OPENGL_COMPOSITOR* compositor;
|
|
|
|
|
|
|
|
unsigned int ssaaMainBuffer;
|
|
|
|
bool areBuffersCreated;
|
|
|
|
|
|
|
|
bool areShadersCreated;
|
2016-12-23 15:21:00 +00:00
|
|
|
};
|
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
class ANTIALIASING_SMAA : public OPENGL_PRESENTOR
|
|
|
|
{
|
2016-12-22 20:36:22 +00:00
|
|
|
public:
|
2021-06-09 00:20:41 +00:00
|
|
|
ANTIALIASING_SMAA( OPENGL_COMPOSITOR* aCompositor );
|
2016-12-22 20:36:22 +00:00
|
|
|
|
|
|
|
bool Init() override;
|
|
|
|
unsigned int CreateBuffer () override;
|
|
|
|
|
2023-06-28 20:48:07 +00:00
|
|
|
VECTOR2I GetInternalBufferSize() override;
|
2017-01-11 15:19:58 +00:00
|
|
|
void OnLostBuffers() override;
|
2016-12-22 20:36:22 +00:00
|
|
|
|
|
|
|
void Begin() override;
|
|
|
|
void DrawBuffer( GLuint buffer ) override;
|
2017-01-11 15:19:58 +00:00
|
|
|
void Present() override;
|
2016-12-22 20:36:22 +00:00
|
|
|
|
|
|
|
private:
|
2017-01-11 15:19:58 +00:00
|
|
|
void loadShaders();
|
|
|
|
void updateUniforms();
|
2016-12-22 20:36:22 +00:00
|
|
|
|
2017-01-17 14:07:57 +00:00
|
|
|
bool areBuffersInitialized;
|
2016-12-22 20:36:22 +00:00
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
unsigned int smaaBaseBuffer; // base + overlay temporary
|
|
|
|
unsigned int smaaEdgesBuffer;
|
|
|
|
unsigned int smaaBlendBuffer;
|
2016-12-22 20:36:22 +00:00
|
|
|
|
|
|
|
// smaa shader lookup textures
|
2017-01-11 15:19:58 +00:00
|
|
|
unsigned int smaaAreaTex;
|
|
|
|
unsigned int smaaSearchTex;
|
2016-12-22 20:36:22 +00:00
|
|
|
|
|
|
|
bool shadersLoaded;
|
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
std::unique_ptr<SHADER> pass_1_shader;
|
2016-12-22 20:36:22 +00:00
|
|
|
GLint pass_1_metrics;
|
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
std::unique_ptr<SHADER> pass_2_shader;
|
2016-12-22 20:36:22 +00:00
|
|
|
GLint pass_2_metrics;
|
|
|
|
|
2017-01-11 15:19:58 +00:00
|
|
|
std::unique_ptr<SHADER> pass_3_shader;
|
2016-12-22 20:36:22 +00:00
|
|
|
GLint pass_3_metrics;
|
|
|
|
|
|
|
|
OPENGL_COMPOSITOR* compositor;
|
|
|
|
};
|
|
|
|
|
2016-12-22 17:58:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|