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

Method cSurface

Source/Surface.cpp:28–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include "Utils/stb_image.h"
27
28cSurface::cSurface( size_t pWidth, size_t pHeight ) {
29 mIsLoadedImage = false;
30 mWidth = pWidth;
31 mHeight = pHeight;
32 mPaletteAdjusting = false;
33
34 // Create the screen buffer
35 mSDLSurface = SDL_CreateRGBSurface( 0, (int) pWidth, (int) pHeight, 32, 0xFF << 16, 0xFF << 8, 0xFF, 0 );
36 mTexture = 0;
37
38 if (!mSDLSurface) {
39 g_Debugger->Error("SDLSurface not initialised");
40 exit(1);
41 }
42 if (g_Window->GetRenderer()) {
43 mTexture = SDL_CreateTexture((SDL_Renderer*)g_Window->GetRenderer(), SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, (int)pWidth, (int)pHeight);
44
45 SDL_SetTextureBlendMode(mTexture, SDL_BLENDMODE_ADD);
46 SDL_SetTextureAlphaMod(mTexture, 0xFF);
47 SDL_SetTextureColorMod(mTexture, 0xFF, 0xFF, 0xFF);
48 }
49 mSurfaceBuffer = new uint8[ mWidth * mHeight ];
50 mSurfaceBufferSaved = new uint8[ mWidth * mHeight ];
51 mSurfaceBufferSize = mWidth * mHeight;
52
53 clearBuffer();
54 clearSDLSurface();
55}
56
57cSurface::cSurface(const cDimension& pDimension) : cSurface(pDimension.mWidth, pDimension.mHeight) {
58

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.80
GetRendererMethod · 0.80

Tested by

no test coverage detected