MCPcopy Create free account
hub / github.com/DFHack/dfhack / create_texture

Function create_texture

library/modules/Textures.cpp:118–127  ·  view source on GitHub ↗

create new surface with RGBA32 format and pixels as data

Source from the content-addressed store, hash-verified

116
117// create new surface with RGBA32 format and pixels as data
118SDL_Surface* create_texture(std::vector<uint32_t>& pixels, int texture_px_w, int texture_px_h) {
119 auto surface = DFSDL_CreateRGBSurfaceWithFormat(0, texture_px_w, texture_px_h, 32,
120 SDL_PixelFormatEnum::SDL_PIXELFORMAT_RGBA32);
121 auto canvas_length = static_cast<size_t>(texture_px_w * texture_px_h);
122 for (size_t i = 0; i < pixels.size() && i < canvas_length; i++) {
123 uint32_t* p = (uint32_t*)surface->pixels + i;
124 *p = pixels[i];
125 }
126 return surface;
127}
128
129// convert single surface into tiles according w/h
130// register tiles in texture raws and return handles

Callers 2

createTileMethod · 0.85
createTilesetMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected