2021-02-09 15:38:51 -07:00
|
|
|
/*
|
2024-06-15 09:01:19 -06:00
|
|
|
Copyright 2016-2024 melonDS team
|
2021-02-09 15:38:51 -07:00
|
|
|
|
|
|
|
This file is part of melonDS.
|
|
|
|
|
|
|
|
melonDS 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 3 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
melonDS 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 melonDS. If not, see http://www.gnu.org/licenses/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "OpenGLSupport.h"
|
|
|
|
|
2023-09-15 07:31:05 -06:00
|
|
|
#include <array>
|
2023-11-29 07:23:11 -07:00
|
|
|
#include <optional>
|
2023-09-15 07:31:05 -06:00
|
|
|
|
2023-11-25 10:32:09 -07:00
|
|
|
namespace melonDS
|
2021-02-09 15:38:51 -07:00
|
|
|
{
|
2023-11-09 13:54:51 -07:00
|
|
|
class GPU;
|
2021-02-09 15:38:51 -07:00
|
|
|
struct RenderSettings;
|
2023-11-29 07:23:11 -07:00
|
|
|
class GLRenderer;
|
2024-05-13 09:17:39 -06:00
|
|
|
class Renderer3D;
|
2021-02-09 15:38:51 -07:00
|
|
|
class GLCompositor
|
|
|
|
{
|
|
|
|
public:
|
2023-11-29 07:23:11 -07:00
|
|
|
static std::optional<GLCompositor> New() noexcept;
|
2021-02-09 15:38:51 -07:00
|
|
|
GLCompositor(const GLCompositor&) = delete;
|
|
|
|
GLCompositor& operator=(const GLCompositor&) = delete;
|
2023-11-29 07:23:11 -07:00
|
|
|
GLCompositor(GLCompositor&&) noexcept;
|
|
|
|
GLCompositor& operator=(GLCompositor&&) noexcept;
|
2023-09-15 07:31:05 -06:00
|
|
|
~GLCompositor();
|
2021-02-09 15:38:51 -07:00
|
|
|
|
2023-11-29 07:23:11 -07:00
|
|
|
void SetScaleFactor(int scale) noexcept;
|
|
|
|
[[nodiscard]] int GetScaleFactor() const noexcept { return Scale; }
|
2021-02-09 15:38:51 -07:00
|
|
|
|
2023-11-29 07:23:11 -07:00
|
|
|
void Stop(const GPU& gpu) noexcept;
|
2024-05-13 09:17:39 -06:00
|
|
|
void RenderFrame(const GPU& gpu, Renderer3D& renderer) noexcept;
|
2021-02-09 15:38:51 -07:00
|
|
|
void BindOutputTexture(int buf);
|
|
|
|
private:
|
2024-05-13 09:17:39 -06:00
|
|
|
GLCompositor(GLuint CompShader) noexcept;
|
2023-11-29 07:23:11 -07:00
|
|
|
int Scale = 0;
|
|
|
|
int ScreenH = 0, ScreenW = 0;
|
2021-02-09 15:38:51 -07:00
|
|
|
|
2024-05-13 09:17:39 -06:00
|
|
|
GLuint CompShader {};
|
2023-11-29 07:23:11 -07:00
|
|
|
GLuint CompScaleLoc = 0;
|
2021-02-09 15:38:51 -07:00
|
|
|
|
2023-11-29 07:23:11 -07:00
|
|
|
GLuint CompVertexBufferID = 0;
|
|
|
|
GLuint CompVertexArrayID = 0;
|
2021-02-09 15:38:51 -07:00
|
|
|
|
|
|
|
struct CompVertex
|
|
|
|
{
|
2023-11-29 07:23:11 -07:00
|
|
|
std::array<float, 2> Position {};
|
|
|
|
std::array<float, 2> Texcoord {};
|
2021-02-09 15:38:51 -07:00
|
|
|
};
|
2023-11-29 07:23:11 -07:00
|
|
|
std::array<CompVertex, 2*3*2> CompVertices {};
|
2021-02-09 15:38:51 -07:00
|
|
|
|
2023-11-29 07:23:11 -07:00
|
|
|
GLuint CompScreenInputTex = 0;
|
|
|
|
std::array<GLuint, 2> CompScreenOutputTex {};
|
|
|
|
std::array<GLuint, 2> CompScreenOutputFB {};
|
2021-02-09 15:38:51 -07:00
|
|
|
};
|
|
|
|
|
2023-11-03 17:21:46 -06:00
|
|
|
}
|