void OpenGLImageHelper::copySurfaceToImage(const Image *const image, const int x, const int y, SDL_Surface *surface) const { if (!surface || !image) return; SDL_Surface *const oldSurface = surface; surface = convertSurface(surface, surface->w, surface->h); if (!surface) return; // +++ probably need combine // mglTextureSubImage2D and mglTextureSubImage2DEXT if (mglTextureSubImage2D) { mglTextureSubImage2D(image->mGLImage, 0, x, y, surface->w, surface->h, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); } else { mglTextureSubImage2DEXT(image->mGLImage, mTextureType, 0, x, y, surface->w, surface->h, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); } if (surface != oldSurface) MSDL_FreeSurface(surface); }
void OpenGLImageHelper::copySurfaceToImage(const Image *const image, const int x, const int y, SDL_Surface *surface) const { if (!surface || !image) return; SDL_Surface *const oldSurface = surface; surface = convertSurface(surface, surface->w, surface->h); mglTextureSubImage2D(image->mGLImage, mTextureType, 0, x, y, surface->w, surface->h, GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels); if (surface != oldSurface) MSDL_FreeSurface(surface); }