mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
change texture data type to unsigned char
This commit is contained in:
14
Texture.cpp
14
Texture.cpp
@@ -56,7 +56,7 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
|||||||
// we don't want BGR(A), reverse it
|
// we don't want BGR(A), reverse it
|
||||||
if (data_format == GL_BGR)
|
if (data_format == GL_BGR)
|
||||||
{
|
{
|
||||||
std::vector<char> reverse;
|
std::vector<unsigned char> reverse;
|
||||||
reverse.resize(data.size());
|
reverse.resize(data.size());
|
||||||
|
|
||||||
for (int y = 0; y < data_height; y++)
|
for (int y = 0; y < data_height; y++)
|
||||||
@@ -73,7 +73,7 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
|||||||
}
|
}
|
||||||
else if (data_format == GL_BGRA)
|
else if (data_format == GL_BGRA)
|
||||||
{
|
{
|
||||||
std::vector<char> reverse;
|
std::vector<unsigned char> reverse;
|
||||||
reverse.resize(data.size());
|
reverse.resize(data.size());
|
||||||
|
|
||||||
for (int y = 0; y < data_height; y++)
|
for (int y = 0; y < data_height; y++)
|
||||||
@@ -125,7 +125,7 @@ void opengl_texture::gles_match_internalformat(GLuint internalformat)
|
|||||||
if (!in_c || !out_c)
|
if (!in_c || !out_c)
|
||||||
return; // conversion not supported
|
return; // conversion not supported
|
||||||
|
|
||||||
std::vector<char> out;
|
std::vector<unsigned char> out;
|
||||||
out.resize(data_width * data_height * out_c);
|
out.resize(data_width * data_height * out_c);
|
||||||
|
|
||||||
for (int y = 0; y < data_height; y++)
|
for (int y = 0; y < data_height; y++)
|
||||||
@@ -290,11 +290,11 @@ opengl_texture::make_request() {
|
|||||||
void
|
void
|
||||||
opengl_texture::load_BMP() {
|
opengl_texture::load_BMP() {
|
||||||
|
|
||||||
std::ifstream file( name + type, std::ios::binary ); file.unsetf( std::ios::skipws );
|
std::basic_ifstream<unsigned char> file( name + type, std::ios::binary ); file.unsetf( std::ios::skipws );
|
||||||
|
|
||||||
BITMAPFILEHEADER header;
|
BITMAPFILEHEADER header;
|
||||||
|
|
||||||
file.read( (char *)&header, sizeof( BITMAPFILEHEADER ) );
|
file.read( (unsigned char *)&header, sizeof( BITMAPFILEHEADER ) );
|
||||||
if( file.eof() ) {
|
if( file.eof() ) {
|
||||||
|
|
||||||
data_state = resource_state::failed;
|
data_state = resource_state::failed;
|
||||||
@@ -307,7 +307,7 @@ opengl_texture::load_BMP() {
|
|||||||
if( infosize > sizeof( info ) ) {
|
if( infosize > sizeof( info ) ) {
|
||||||
WriteLog( "Warning - BMP header is larger than expected, possible format difference.", logtype::texture );
|
WriteLog( "Warning - BMP header is larger than expected, possible format difference.", logtype::texture );
|
||||||
}
|
}
|
||||||
file.read( (char *)&info, std::min( (size_t)infosize, sizeof( info ) ) );
|
file.read( (unsigned char *)&info, std::min( (size_t)infosize, sizeof( info ) ) );
|
||||||
|
|
||||||
data_width = info.bmiHeader.biWidth;
|
data_width = info.bmiHeader.biWidth;
|
||||||
data_height = info.bmiHeader.biHeight;
|
data_height = info.bmiHeader.biHeight;
|
||||||
@@ -995,7 +995,7 @@ opengl_texture::create() {
|
|||||||
if( ( true == Global.ResourceMove )
|
if( ( true == Global.ResourceMove )
|
||||||
|| ( false == Global.ResourceSweep ) ) {
|
|| ( false == Global.ResourceSweep ) ) {
|
||||||
// if garbage collection is disabled we don't expect having to upload the texture more than once
|
// if garbage collection is disabled we don't expect having to upload the texture more than once
|
||||||
data = std::vector<char>();
|
data = std::vector<unsigned char>();
|
||||||
data_state = resource_state::none;
|
data_state = resource_state::none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ private:
|
|||||||
bool is_rendertarget = false; // is used as postfx rendertarget, without loaded data
|
bool is_rendertarget = false; // is used as postfx rendertarget, without loaded data
|
||||||
int samples = 1;
|
int samples = 1;
|
||||||
|
|
||||||
std::vector<char> data; // texture data (stored GL-style, bottom-left origin)
|
std::vector<unsigned char> data; // texture data (stored GL-style, bottom-left origin)
|
||||||
resource_state data_state{ resource_state::none }; // current state of texture data
|
resource_state data_state{ resource_state::none }; // current state of texture data
|
||||||
int data_width{ 0 },
|
int data_width{ 0 },
|
||||||
data_height{ 0 },
|
data_height{ 0 },
|
||||||
@@ -154,7 +154,7 @@ private:
|
|||||||
// reduces provided data image to half of original size, using basic 2x2 average
|
// reduces provided data image to half of original size, using basic 2x2 average
|
||||||
template <typename Colortype_>
|
template <typename Colortype_>
|
||||||
void
|
void
|
||||||
downsample( std::size_t const Width, std::size_t const Height, char *Imagedata ) {
|
downsample( std::size_t const Width, std::size_t const Height, unsigned char *Imagedata ) {
|
||||||
|
|
||||||
Colortype_ *destination = reinterpret_cast<Colortype_*>( Imagedata );
|
Colortype_ *destination = reinterpret_cast<Colortype_*>( Imagedata );
|
||||||
Colortype_ *sampler = reinterpret_cast<Colortype_*>( Imagedata );
|
Colortype_ *sampler = reinterpret_cast<Colortype_*>( Imagedata );
|
||||||
|
|||||||
Reference in New Issue
Block a user