mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-24 14:49:53 -06:00

* Make cleanup a little more robust to mitigate undefined behavior - Add some null checks before cleaning up the GPU3D renderer - Make sure that all deleted objects are null - Move cleanup logic out of an assert call - Note that deleting a null pointer is a no-op, so there's no need to check for null beforehand - Use RAII for GLCompositor instead of Init/DeInit methods * Replace a DeInit call that I missed * Make ARMJIT_Memory less likely to generate errors - Set FastMem7/9Start to nullptr at the end - Only close and unmap the file if it's initialized * Make Renderer3D manage its resources with RAII * Don't try to deallocate frontend resources that aren't loaded * Make ARMJIT_Memory::DeInit more robust on the Switch * Reset MemoryFile on Windows to INVALID_HANDLE_VALUE, not nullptr - There is a difference * Don't explicitly store a Valid state in GLCompositor or the 3D renderers - Instead, create them with static methods while making the actual constructors private * Make initialization of OpenGL resources fail if OpenGL isn't loaded * assert that OpenGL is loaded instead of returning failure
71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
/*
|
|
Copyright 2016-2022 melonDS team
|
|
|
|
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"
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
|
|
namespace GPU
|
|
{
|
|
|
|
struct RenderSettings;
|
|
|
|
class GLCompositor
|
|
{
|
|
public:
|
|
static std::unique_ptr<GLCompositor> New() noexcept;
|
|
GLCompositor(const GLCompositor&) = delete;
|
|
GLCompositor& operator=(const GLCompositor&) = delete;
|
|
~GLCompositor();
|
|
|
|
void Reset();
|
|
|
|
void SetRenderSettings(RenderSettings& settings);
|
|
|
|
void Stop();
|
|
void RenderFrame();
|
|
void BindOutputTexture(int buf);
|
|
private:
|
|
GLCompositor(std::array<GLuint, 3> CompShader) noexcept;
|
|
|
|
int Scale;
|
|
int ScreenH, ScreenW;
|
|
|
|
std::array<GLuint, 3> CompShader;
|
|
GLuint CompScaleLoc;
|
|
GLuint Comp3DXPosLoc;
|
|
|
|
GLuint CompVertexBufferID;
|
|
GLuint CompVertexArrayID;
|
|
|
|
struct CompVertex
|
|
{
|
|
float Position[2];
|
|
float Texcoord[2];
|
|
};
|
|
CompVertex CompVertices[2 * 3*2];
|
|
|
|
GLuint CompScreenInputTex;
|
|
GLuint CompScreenOutputTex[2];
|
|
GLuint CompScreenOutputFB[2];
|
|
};
|
|
|
|
} |