mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
use builtin opengl srgb gamma
This commit is contained in:
16
Texture.cpp
16
Texture.cpp
@@ -223,17 +223,17 @@ opengl_texture::load_DDS() {
|
|||||||
{
|
{
|
||||||
case FOURCC_DXT1:
|
case FOURCC_DXT1:
|
||||||
// DXT1's compression ratio is 8:1
|
// DXT1's compression ratio is 8:1
|
||||||
data_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
data_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FOURCC_DXT3:
|
case FOURCC_DXT3:
|
||||||
// DXT3's compression ratio is 4:1
|
// DXT3's compression ratio is 4:1
|
||||||
data_format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
data_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FOURCC_DXT5:
|
case FOURCC_DXT5:
|
||||||
// DXT5's compression ratio is 4:1
|
// DXT5's compression ratio is 4:1
|
||||||
data_format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
data_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -562,12 +562,12 @@ opengl_texture::create() {
|
|||||||
dataheight = data_height;
|
dataheight = data_height;
|
||||||
for( int maplevel = 0; maplevel < data_mapcount; ++maplevel ) {
|
for( int maplevel = 0; maplevel < data_mapcount; ++maplevel ) {
|
||||||
|
|
||||||
if( ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT )
|
if( ( data_format == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT )
|
||||||
|| ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT )
|
|| ( data_format == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT )
|
||||||
|| ( data_format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ) ) {
|
|| ( data_format == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT ) ) {
|
||||||
// compressed dds formats
|
// compressed dds formats
|
||||||
int const datablocksize =
|
int const datablocksize =
|
||||||
( data_format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ?
|
( data_format == GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT ?
|
||||||
8 :
|
8 :
|
||||||
16 );
|
16 );
|
||||||
|
|
||||||
@@ -585,7 +585,7 @@ opengl_texture::create() {
|
|||||||
else {
|
else {
|
||||||
// uncompressed texture data. have the gfx card do the compression as it sees fit
|
// uncompressed texture data. have the gfx card do the compression as it sees fit
|
||||||
::glTexImage2D(
|
::glTexImage2D(
|
||||||
GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA,
|
GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB_ALPHA,
|
||||||
data_width, data_height, 0,
|
data_width, data_height, 0,
|
||||||
data_format, GL_UNSIGNED_BYTE, (GLubyte *)&data[ 0 ] );
|
data_format, GL_UNSIGNED_BYTE, (GLubyte *)&data[ 0 ] );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,15 +325,15 @@ void DecompressDXT(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Dat
|
|||||||
{
|
{
|
||||||
switch (lImage.format)
|
switch (lImage.format)
|
||||||
{
|
{
|
||||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||||
DecompressDXT1(lImage, lCompData, Data);
|
DecompressDXT1(lImage, lCompData, Data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||||
DecompressDXT3(lImage, lCompData, Data);
|
DecompressDXT3(lImage, lCompData, Data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||||
DecompressDXT5(lImage, lCompData, Data);
|
DecompressDXT5(lImage, lCompData, Data);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -116,8 +116,7 @@ bool
|
|||||||
opengl_renderer::Render() {
|
opengl_renderer::Render() {
|
||||||
|
|
||||||
auto timestart = std::chrono::steady_clock::now();
|
auto timestart = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
glUseProgram(World.shader);
|
|
||||||
|
|
||||||
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
::glDepthFunc( GL_LEQUAL );
|
::glDepthFunc( GL_LEQUAL );
|
||||||
@@ -133,11 +132,14 @@ opengl_renderer::Render() {
|
|||||||
::glLoadIdentity();
|
::glLoadIdentity();
|
||||||
|
|
||||||
if( World.InitPerformed() ) {
|
if( World.InitPerformed() ) {
|
||||||
|
|
||||||
World.Camera.SetMatrix();
|
World.Camera.SetMatrix();
|
||||||
m_camera.update_frustum();
|
m_camera.update_frustum();
|
||||||
|
|
||||||
|
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||||
Render( &World.Environment );
|
Render( &World.Environment );
|
||||||
|
|
||||||
|
glUseProgram(World.shader);
|
||||||
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
World.Ground.Render( World.Camera.Pos );
|
World.Ground.Render( World.Camera.Pos );
|
||||||
|
|
||||||
glDebug("rendering cab");
|
glDebug("rendering cab");
|
||||||
@@ -148,6 +150,7 @@ opengl_renderer::Render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||||
UILayer.render();
|
UILayer.render();
|
||||||
|
|
||||||
glfwSwapBuffers( m_window );
|
glfwSwapBuffers( m_window );
|
||||||
|
|||||||
Reference in New Issue
Block a user