MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / draw

Method draw

Source/Surface.cpp:207–243  ·  view source on GitHub ↗

* Draw the Surface Buffer to SDLSurface, using the surface palette */

Source from the content-addressed store, hash-verified

205 * Draw the Surface Buffer to SDLSurface, using the surface palette
206 */
207void cSurface::draw(const int16 pSkipX, const int16 pSkipY) {
208 if (mIsLoadedImage)
209 return;
210
211 const uint8_t* bufferCurrent = mSurfaceBuffer;
212 const uint8_t* const bufferEnd = mSurfaceBuffer + mSurfaceBufferSize;
213 uint32_t* bufferTarget = reinterpret_cast<uint32_t*>(mSDLSurface->pixels);
214 const int width = mSDLSurface->w, height = mSDLSurface->h;
215
216 clearSDLSurface(0);
217
218 // Skip 'skipY' rows of pixels
219 bufferCurrent += width * pSkipY;
220 bufferTarget += width * pSkipY;
221
222 for (int y = pSkipY; y < height; ++y) {
223 // Skip first 'skipX' pixels
224 bufferCurrent += pSkipX;
225 bufferTarget += pSkipX;
226
227 // Process remaining pixels
228 for (int x = pSkipX; x < width; ++x) {
229 if (bufferCurrent >= bufferEnd) break;
230
231 uint8_t currentPixel = *bufferCurrent++;
232 if (currentPixel) {
233 *bufferTarget = (currentPixel < g_MaxColors) ? mPaletteSDL[currentPixel] : 0;
234 }
235
236 ++bufferTarget;
237 }
238 }
239
240 if (mTexture) {
241 SDL_UpdateTexture(mTexture, NULL, mSDLSurface->pixels, mSDLSurface->pitch);
242 }
243}
244
245void cSurface::copyFrom(const cSurface* pFrom) {
246

Callers 4

CycleMethod · 0.80
Phase_PausedMethod · 0.80
Draw_Phase_PausedMethod · 0.80
Video_SurfaceRenderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected