72 Image(data, width, height),
81 Image(name, data, width, height),
134 if (rect.
right() < 0 || rect.
x >
static_cast<int32_t
>(target->w) ||
135 rect.
bottom() < 0 || rect.
y >
static_cast<int32_t
>(target->h)) {
212 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
213 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
215 GLint internalFormat = GL_RGBA8;
217 internalFormat = GL_COMPRESSED_RGBA;
224 int32_t bpp_target = target->format->BitsPerPixel;
225 int32_t bpp_source =
m_surface->format->BitsPerPixel;
227 if (bpp_target == 16 && bpp_source == 32) {
231 for (
uint32_t y = 0; y < height; ++y) {
232 for (
uint32_t x = 0; x < width; ++x) {
233 uint32_t pos = (y * pitch) + (x * 4);
255 internalFormat = GL_RGBA4;
260 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, oglbuffer);
269 memcpy(oglbuffer, data, width * height * 4 *
sizeof(
uint8_t));
271 for (
uint32_t y = 0; y < height; ++y) {
272 for (
uint32_t x = 0; x < width * 4; x += 4) {
275 uint8_t r = oglbuffer[gid + 0];
276 uint8_t g = oglbuffer[gid + 1];
277 uint8_t b = oglbuffer[gid + 2];
281 oglbuffer[gid + 3] = 0;
288 0, GL_RGBA, GL_UNSIGNED_BYTE, oglbuffer);
295 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
302 for (
uint32_t y = 0; y < height; ++y) {
303 for (
uint32_t x = 0; x < width; ++x) {
304 uint32_t pos = (y * pitch) + (x * 4);
318 oglbuffer[(y*
m_chunk_size_w) + x] = r | (g << 8) | (b << 16) | (a<<24);
324 0, GL_RGBA, GL_UNSIGNED_BYTE, static_cast<GLvoid*>(oglbuffer));
339 m_tex_coords[0] =
static_cast<GLfloat
>(region.
x) / static_cast<GLfloat>(width);
340 m_tex_coords[1] =
static_cast<GLfloat
>(region.
y) / static_cast<GLfloat>(height);
341 m_tex_coords[2] =
static_cast<GLfloat
>(region.
x + region.
w) / static_cast<GLfloat>(width);
342 m_tex_coords[3] =
static_cast<GLfloat
>(region.
y + region.
h) / static_cast<GLfloat>(height);
394 glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, img->
getWidth(), img->
getHeight(),
395 GL_RGBA, GL_UNSIGNED_BYTE, img->
getSurface()->pixels);
virtual ImagePtr create(IResourceLoader *loader=0)
Creates a blank Image but does not load it immediately.
Implements an Image using experimental OpenGL.
void reset(SDL_Surface *surface)
Resets the image to default values (including the x and y shift values), frees the current surface an...
virtual void addImageToArray(uint32_t id, const Rect &rec, float const *st, uint8_t alpha, uint8_t const *rgba)=0
Add the Image data to the array.
void generateGLSharedTexture(const GLeImage *shared, const Rect ®ion)
Abstract interface for all the renderbackends.
T * get() const
allows direct access to underlying pointer
const GLfloat * getTexCoords() const
virtual ResourceState getState()
virtual void setSurface(SDL_Surface *surface)
This frees the current suface and replaces it with the surface passed in the parameter (which can be ...
T h
Height of the rectangle.
void cleanup()
Frees allocated memory and calls resetGlImage.
unsigned nextPow2(unsigned x)
Returns the next higher power of 2 based on the passed argument.
virtual void useSharedImage(const ImagePtr &shared, const Rect ®ion)
After this call all image data will be taken from the given image and its subregion.
GLeImage(IResourceLoader *loader=0)
static RenderBackend * instance()
uint32_t getHeight() const
bool isColorKeyEnabled() const
Gets whether the colorkey feature is in use.
T bottom() const
The Y coordinate of the bottom edge.
SDL_Surface * getSurface()
virtual void copySubimage(uint32_t xoffset, uint32_t yoffset, const ImagePtr &img)
Copies given image into this one with respect to given offsets.
virtual void copySubimage(uint32_t xoffset, uint32_t yoffset, const ImagePtr &img)
Copies given image into this one with respect to given offsets.
const SDL_Color & getColorKey() const
Gets the global colorkey setting.
bool renderCheck(const Rect &rect, uint8_t alpha)
virtual void forceLoadInternal()
Forces to load the image into internal memory of GPU.
virtual const std::string & getName()
uint32_t getWidth() const
T right() const
The X coordinate of the right edge.
virtual void setState(const ResourceState &state)
virtual void render(const Rect &rect, uint8_t alpha=255, uint8_t const *rgb=0)
Renders itself to the current render target (main screen or attached destination image) at the rectan...
void resetGlimage()
Resets GLeImage variables.
SDL_Surface * getRenderTargetSurface()
Returns currently attached render surface.
void generateGLTexture()
Generates the GL Texture for use when rendering.
The main class of the OpenGL-based experimental renderer.
GLuint m_texId
Holds texture ids that are used to access textures in GL rendering context.
virtual void invalidate()
Invalidates the Image causing it to be reset or re-loaded.
T w
Width of the rectangle.
virtual void renderZ(const Rect &rect, float vertexZ, uint8_t alpha=255, bool forceNewBatch=false, uint8_t const *rgb=0)