jak-project/game/graphics/opengl_renderer/opengl_utils.h
water111 e38832365c
Loader improvements and blackout (#1254)
* temp

* also tfrag

* fix order
2022-03-26 15:53:44 -04:00

58 lines
1.6 KiB
C++

#pragma once
#include "game/graphics/pipelines/opengl.h"
#include "common/math/Vector.h"
struct SharedRenderState;
class ScopedProfilerNode;
/*!
* This is a wrapper around a framebuffer and texture to make it easier to render to a texture.
*/
class FramebufferTexturePair {
public:
FramebufferTexturePair(int w, int h, u64 texture_format, int num_levels = 1);
~FramebufferTexturePair();
GLuint texture() const { return m_texture; }
FramebufferTexturePair(const FramebufferTexturePair&) = delete;
FramebufferTexturePair& operator=(const FramebufferTexturePair&) = delete;
private:
friend class FramebufferTexturePairContext;
std::vector<GLuint> m_framebuffers;
GLuint m_texture;
int m_w, m_h;
};
class FramebufferTexturePairContext {
public:
FramebufferTexturePairContext(FramebufferTexturePair& fb, int level = 0);
~FramebufferTexturePairContext();
void switch_to(FramebufferTexturePair& fb);
FramebufferTexturePairContext(const FramebufferTexturePairContext&) = delete;
FramebufferTexturePairContext& operator=(const FramebufferTexturePairContext&) = delete;
private:
FramebufferTexturePair* m_fb;
GLint m_old_viewport[4];
GLint m_old_framebuffer;
};
// draw over the full screen.
// you must set alpha/ztest/etc.
class FullScreenDraw {
public:
FullScreenDraw();
~FullScreenDraw();
FullScreenDraw(const FullScreenDraw&) = delete;
FullScreenDraw& operator=(const FullScreenDraw&) = delete;
void draw(const math::Vector4f& color, SharedRenderState* render_state, ScopedProfilerNode& prof);
private:
GLuint m_vao;
GLuint m_vertex_buffer;
};