diff --git a/include/eepp/audio/csoundstream.hpp b/include/eepp/audio/csoundstream.hpp index f36f3ddfb..711e54a3b 100755 --- a/include/eepp/audio/csoundstream.hpp +++ b/include/eepp/audio/csoundstream.hpp @@ -81,7 +81,6 @@ class EE_API cSoundStream : private cThread, private cSound { */ void Loop( const bool& Loop); - /** Tell whether or not the stream is looping * @return True if the music is looping, false otherwise */ diff --git a/include/eepp/graphics/ctexture.hpp b/include/eepp/graphics/ctexture.hpp index 203ca7f69..e709bd235 100755 --- a/include/eepp/graphics/ctexture.hpp +++ b/include/eepp/graphics/ctexture.hpp @@ -82,6 +82,21 @@ class EE_API cTexture : public cImage { /** Copy an image inside the texture */ void CopyImage( cImage * Img, const eeUint& x, const eeUint& y ); + /** @brief Update a part of the texture from an array of pixels + ** The size of the @a pixel array must match the @a width and + ** @a height arguments. + ** No additional check is performed on the size of the pixel + ** array or the bounds of the area to update, passing invalid + ** arguments will lead to an undefined behaviour. + ** This function does nothing if @a pixels is null or if the + ** texture was not previously created. + ** @param pixels Array of pixels to copy to the texture + ** @param width Width of the pixel region contained in @a pixels + ** @param height Height of the pixel region contained in @a pixels + ** @param x X offset in the texture where to copy the source pixels + ** @param y Y offset in the texture where to copy the source pixels */ + void Update( const Uint8* pixels, Uint32 width, Uint32 height, Uint32 x = 0, Uint32 y = 0, EE_PIXEL_FORMAT pf = PF_RGBA ); + /** Flip the texture ( rotate the texture 90ยบ ). Warning: This is flipped in memory, a real flipping. */ void Flip(); diff --git a/include/eepp/graphics/renders.hpp b/include/eepp/graphics/renders.hpp index a6432acba..02057155a 100755 --- a/include/eepp/graphics/renders.hpp +++ b/include/eepp/graphics/renders.hpp @@ -154,6 +154,16 @@ enum EE_TEXTURE_SOURCE { TEX_SRC_PREVIOUS }; +/** @enum EE_PIXEL_FORMAT Pixel formats to write into a texture image. */ +enum EE_PIXEL_FORMAT { + PF_RED = 0x1903, + PF_RG = 0x8227, + PF_RGB = 0x1907, + PF_BGR = 0x80E0, + PF_RGBA = 0x1908, + PF_BGRA = 0x80E1 +}; + }} #endif diff --git a/src/eepp/audio/caudiodevice.cpp b/src/eepp/audio/caudiodevice.cpp index f4abe9074..ee52b03e3 100755 --- a/src/eepp/audio/caudiodevice.cpp +++ b/src/eepp/audio/caudiodevice.cpp @@ -81,16 +81,22 @@ bool cAudioDevice::IsExtensionSupported( const std::string& extension ) { int cAudioDevice::GetFormatFromChannelCount( unsigned int ChannelCount ) { EnsureALInit(); + int format = 0; + switch ( ChannelCount ) { - case 1 : return AL_FORMAT_MONO16; - case 2 : return AL_FORMAT_STEREO16; - case 4 : return alGetEnumValue("AL_FORMAT_QUAD16"); - case 6 : return alGetEnumValue("AL_FORMAT_51CHN16"); - case 7 : return alGetEnumValue("AL_FORMAT_61CHN16"); - case 8 : return alGetEnumValue("AL_FORMAT_71CHN16"); + case 1 : format = AL_FORMAT_MONO16; break; + case 2 : format = AL_FORMAT_STEREO16; break; + case 4 : format = alGetEnumValue("AL_FORMAT_QUAD16"); break; + case 6 : format = alGetEnumValue("AL_FORMAT_51CHN16"); break; + case 7 : format = alGetEnumValue("AL_FORMAT_61CHN16"); break; + case 8 : format = alGetEnumValue("AL_FORMAT_71CHN16"); break; + default: format = 0; } - return 0; + if ( -1 == format ) + format = 0; + + return format; } bool cAudioDevice::IsAvailable() { diff --git a/src/eepp/graphics/ctexture.cpp b/src/eepp/graphics/ctexture.cpp index 89da1485a..4b41d4c78 100755 --- a/src/eepp/graphics/ctexture.cpp +++ b/src/eepp/graphics/ctexture.cpp @@ -382,6 +382,21 @@ void cTexture::Reload() { } } +void cTexture::Update( const Uint8* pixels, Uint32 width, Uint32 height, Uint32 x, Uint32 y, EE_PIXEL_FORMAT pf ) { + if ( NULL != pixels && mTexture && x + width <= mWidth && y + height <= mHeight ) { + GLint PreviousTexture; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture); + + if ( mTexture != PreviousTexture ) + glBindTexture( GL_TEXTURE_2D, mTexture ); + + glTexSubImage2D( GL_TEXTURE_2D, 0, x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels ); + + if ( mTexture != PreviousTexture ) + glBindTexture(GL_TEXTURE_2D, PreviousTexture); + } +} + const Uint32& cTexture::HashName() const { return mId; }