MCPcopy Create free account
hub / github.com/TurningWheel/Barony / putPixel

Function putPixel

src/draw.cpp:1037–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1035-------------------------------------------------------------------------------*/
1036
1037void putPixel(SDL_Surface* surface, int x, int y, Uint32 pixel)
1038{
1039 int bpp = surface->format->BytesPerPixel;
1040 // Here p is the address to the pixel we want to set
1041 Uint8* p = (Uint8*)surface->pixels + y * surface->pitch + x * bpp;
1042
1043 switch (bpp)
1044 {
1045 case 1:
1046 *p = pixel;
1047 break;
1048
1049 case 2:
1050 *(Uint16*)p = pixel;
1051 break;
1052
1053 case 3:
1054 if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
1055 {
1056 p[0] = (pixel >> 16) & 0xff;
1057 p[1] = (pixel >> 8) & 0xff;
1058 p[2] = pixel & 0xff;
1059 }
1060 else
1061 {
1062 p[0] = pixel & 0xff;
1063 p[1] = (pixel >> 8) & 0xff;
1064 p[2] = (pixel >> 16) & 0xff;
1065 }
1066 break;
1067
1068 case 4:
1069 *(Uint32*)p = pixel;
1070 break;
1071 }
1072}
1073
1074/*-------------------------------------------------------------------------------
1075

Callers 5

flipSurfaceFunction · 0.85
scaleSurfaceFunction · 0.85
drawMinimapFunction · 0.85
renderMethod · 0.85
updateIndicatorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected