mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 06:19:19 +02:00
Migration cleanup and renderer documentation
This commit is contained in:
@@ -24,8 +24,6 @@ inline std::vector<glm::vec4> const ndcfrustumshapepoints //
|
||||
{-1, 1, 1, 1}, // z-far
|
||||
};
|
||||
|
||||
inline std::vector<std::size_t> const frustumshapepoinstorder { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };
|
||||
|
||||
// generic frustum class. used to determine if objects are inside current view area
|
||||
|
||||
class cFrustum {
|
||||
|
||||
@@ -108,7 +108,6 @@ bool opengl46_renderer::Init(GLFWwindow *Window)
|
||||
return false;
|
||||
|
||||
WriteLog("preparing renderer..");
|
||||
OpenGLMatrices.upload() = false; // set matrix stack in virtual mode
|
||||
|
||||
m_window = Window;
|
||||
|
||||
@@ -495,7 +494,7 @@ bool opengl46_renderer::init_viewport(viewport_config &vp)
|
||||
vp.main_texv = std::make_unique<opengl_texture>();
|
||||
vp.main_texv->alloc_rendertarget(Global.gfx_postfx_motionblur_format, GL_RG, vp.width, vp.height);
|
||||
vp.main_fb->attach(*vp.main_texv, GL_COLOR_ATTACHMENT1);
|
||||
} else
|
||||
}
|
||||
|
||||
if( !vp.main_fb->is_complete() ) {
|
||||
ErrorLog( "main framebuffer setup failed" );
|
||||
|
||||
@@ -34,7 +34,7 @@ void bind_for_upload(opengl_texture const &Texture)
|
||||
void set_anisotropy(GLenum const Target)
|
||||
{
|
||||
if (Global.AnisotropicFiltering >= 0)
|
||||
::glTexParameterf(Target, GL_TEXTURE_MAX_ANISOTROPY_EXT, Global.AnisotropicFiltering);
|
||||
::glTexParameterf(Target, GL_TEXTURE_MAX_ANISOTROPY, Global.AnisotropicFiltering);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -47,53 +47,38 @@ public:
|
||||
glm::mat4 const top { m_stack.back() };
|
||||
m_stack.emplace_back( top ); }
|
||||
void
|
||||
pop_matrix( bool const Upload = true ) {
|
||||
pop_matrix() {
|
||||
if( m_stack.size() > 1 ) {
|
||||
m_stack.pop_back();
|
||||
if( Upload ) { upload(); } } }
|
||||
m_stack.pop_back(); } }
|
||||
void
|
||||
load_identity( bool const Upload = true ) {
|
||||
m_stack.back() = glm::mat4( 1.f );
|
||||
if( Upload ) { upload(); } }
|
||||
load_identity() {
|
||||
m_stack.back() = glm::mat4( 1.f ); }
|
||||
void
|
||||
load_matrix( glm::mat4 const &Matrix, bool const Upload = true ) {
|
||||
m_stack.back() = Matrix;
|
||||
if( Upload ) { upload(); } }
|
||||
load_matrix( glm::mat4 const &Matrix ) {
|
||||
m_stack.back() = Matrix; }
|
||||
void
|
||||
rotate( float const Angle, glm::vec3 const &Axis, bool const Upload = true ) {
|
||||
m_stack.back() = glm::rotate( m_stack.back(), Angle, Axis );
|
||||
if( Upload ) { upload(); } }
|
||||
rotate( float const Angle, glm::vec3 const &Axis ) {
|
||||
m_stack.back() = glm::rotate( m_stack.back(), Angle, Axis ); }
|
||||
void
|
||||
translate( glm::vec3 const &Translation, bool const Upload = true ) {
|
||||
m_stack.back() = glm::translate( m_stack.back(), Translation );
|
||||
if( Upload ) { upload(); } }
|
||||
translate( glm::vec3 const &Translation ) {
|
||||
m_stack.back() = glm::translate( m_stack.back(), Translation ); }
|
||||
void
|
||||
scale( glm::vec3 const &Scale, bool const Upload = true ) {
|
||||
m_stack.back() = glm::scale( m_stack.back(), Scale );
|
||||
if( Upload ) { upload(); } }
|
||||
scale( glm::vec3 const &Scale ) {
|
||||
m_stack.back() = glm::scale( m_stack.back(), Scale ); }
|
||||
void
|
||||
multiply( glm::mat4 const &Matrix, bool const Upload = true ) {
|
||||
m_stack.back() *= Matrix;
|
||||
if( Upload ) { upload(); } }
|
||||
multiply( glm::mat4 const &Matrix ) {
|
||||
m_stack.back() *= Matrix; }
|
||||
void
|
||||
ortho( float const Left, float const Right, float const Bottom, float const Top, float const Znear, float const Zfar, bool const Upload = true ) {
|
||||
m_stack.back() *= glm::ortho( Left, Right, Bottom, Top, Znear, Zfar );
|
||||
if( Upload ) { upload(); } }
|
||||
ortho( float const Left, float const Right, float const Bottom, float const Top, float const Znear, float const Zfar ) {
|
||||
m_stack.back() *= glm::ortho( Left, Right, Bottom, Top, Znear, Zfar ); }
|
||||
void
|
||||
perspective( float const Fovy, float const Aspect, float const Znear, float const Zfar, bool const Upload = true ) {
|
||||
m_stack.back() *= glm::perspective( Fovy, Aspect, Znear, Zfar );
|
||||
if( Upload ) { upload(); } }
|
||||
perspective( float const Fovy, float const Aspect, float const Znear, float const Zfar ) {
|
||||
m_stack.back() *= glm::perspective( Fovy, Aspect, Znear, Zfar ); }
|
||||
void
|
||||
look_at( glm::vec3 const &Eye, glm::vec3 const &Center, glm::vec3 const &Up, bool const Upload = true ) {
|
||||
m_stack.back() *= glm::lookAt( Eye, Center, Up );
|
||||
if( Upload ) { upload(); } }
|
||||
look_at( glm::vec3 const &Eye, glm::vec3 const &Center, glm::vec3 const &Up ) {
|
||||
m_stack.back() *= glm::lookAt( Eye, Center, Up ); }
|
||||
|
||||
private:
|
||||
// methods:
|
||||
// the core profile has no fixed pipeline matrices to upload to; the renderer passes the matrices to its shaders itself
|
||||
void
|
||||
upload() {}
|
||||
|
||||
// members:
|
||||
std::vector<glm::mat4> m_stack;
|
||||
};
|
||||
@@ -110,9 +95,6 @@ public:
|
||||
}
|
||||
|
||||
// methods:
|
||||
bool &
|
||||
upload() {
|
||||
return m_upload; }
|
||||
void
|
||||
mode( GLuint const Mode ) {
|
||||
switch( Mode ) {
|
||||
@@ -133,11 +115,11 @@ public:
|
||||
void
|
||||
push_matrix() { m_stacks[ m_mode ].push_matrix(); }
|
||||
void
|
||||
pop_matrix() { m_stacks[ m_mode ].pop_matrix( m_upload ); }
|
||||
pop_matrix() { m_stacks[ m_mode ].pop_matrix(); }
|
||||
void
|
||||
load_identity() { m_stacks[ m_mode ].load_identity( m_upload ); }
|
||||
load_identity() { m_stacks[ m_mode ].load_identity(); }
|
||||
void
|
||||
load_matrix( glm::mat4 const &Matrix ) { m_stacks[ m_mode ].load_matrix( Matrix, m_upload ); }
|
||||
load_matrix( glm::mat4 const &Matrix ) { m_stacks[ m_mode ].load_matrix( Matrix ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
load_matrix( Type_ const *Matrix ) { load_matrix( glm::make_mat4( Matrix ) ); }
|
||||
@@ -149,8 +131,7 @@ public:
|
||||
glm::vec3(
|
||||
static_cast<float>( X ),
|
||||
static_cast<float>( Y ),
|
||||
static_cast<float>( Z ) ),
|
||||
m_upload ); }
|
||||
static_cast<float>( Z ) ) ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
translate( Type_ const X, Type_ const Y, Type_ const Z ) {
|
||||
@@ -158,8 +139,7 @@ public:
|
||||
glm::vec3(
|
||||
static_cast<float>( X ),
|
||||
static_cast<float>( Y ),
|
||||
static_cast<float>( Z ) ),
|
||||
m_upload ); }
|
||||
static_cast<float>( Z ) ) ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
scale( Type_ const X, Type_ const Y, Type_ const Z ) {
|
||||
@@ -167,14 +147,12 @@ public:
|
||||
glm::vec3(
|
||||
static_cast<float>( X ),
|
||||
static_cast<float>( Y ),
|
||||
static_cast<float>( Z ) ),
|
||||
m_upload ); }
|
||||
static_cast<float>( Z ) ) ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
multiply( Type_ const *Matrix ) {
|
||||
m_stacks[ m_mode ].multiply(
|
||||
glm::make_mat4( Matrix ),
|
||||
m_upload ); }
|
||||
glm::make_mat4( Matrix ) ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
ortho( Type_ const Left, Type_ const Right, Type_ const Bottom, Type_ const Top, Type_ const Znear, Type_ const Zfar ) {
|
||||
@@ -184,8 +162,7 @@ public:
|
||||
static_cast<float>( Bottom ),
|
||||
static_cast<float>( Top ),
|
||||
static_cast<float>( Znear ),
|
||||
static_cast<float>( Zfar ),
|
||||
m_upload ); }
|
||||
static_cast<float>( Zfar ) ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
perspective( Type_ const Fovy, Type_ const Aspect, Type_ const Znear, Type_ const Zfar ) {
|
||||
@@ -193,8 +170,7 @@ public:
|
||||
static_cast<float>( glm::radians( Fovy ) ),
|
||||
static_cast<float>( Aspect ),
|
||||
static_cast<float>( Znear ),
|
||||
static_cast<float>( Zfar ),
|
||||
m_upload ); }
|
||||
static_cast<float>( Zfar ) ); }
|
||||
template <typename Type_>
|
||||
void
|
||||
look_at( Type_ const Eyex, Type_ const Eyey, Type_ const Eyez, Type_ const Centerx, Type_ const Centery, Type_ const Centerz, Type_ const Upx, Type_ const Upy, Type_ const Upz ) {
|
||||
@@ -210,14 +186,12 @@ public:
|
||||
glm::vec3(
|
||||
static_cast<float>( Upx ),
|
||||
static_cast<float>( Upy ),
|
||||
static_cast<float>( Upz ) ),
|
||||
m_upload ); }
|
||||
static_cast<float>( Upz ) ) ); }
|
||||
|
||||
private:
|
||||
// members:
|
||||
stack_mode m_mode{ stack_mode::gl_projection };
|
||||
openglstack_array m_stacks;
|
||||
bool m_upload { true };
|
||||
};
|
||||
|
||||
extern opengl_matrices OpenGLMatrices;
|
||||
|
||||
@@ -42,7 +42,8 @@ void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
|
||||
|
||||
void screenshot_manager::make_screenshot()
|
||||
{
|
||||
auto img = new char[Global.fb_size.x * Global.fb_size.y * 4];
|
||||
// rows are tightly packed RGB: the renderer sets GL_PACK_ALIGNMENT to 1
|
||||
auto img = new char[Global.fb_size.x * Global.fb_size.y * 3];
|
||||
glReadPixels(0, 0, Global.fb_size.x, Global.fb_size.y, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
|
||||
//m7t: use pbo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user