Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/engine/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,12 @@ void CGameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& cha

case CG_R_GENERATETEXTURE:
IPC::HandleMsg<Render::GenerateTextureMsg>(channel, std::move(reader), [this] (std::vector<byte> data, int x, int y, qhandle_t& handle) {
// Limit max size to avoid int overflow issues
if (x <= 0 || y <= 0 || x > 16384 || y > 16384 || size_t(x * y * 4) != data.size()) {
Log::Warn("GenerateTextureMsg: bad dimensions or size: %dx%d / %d bytes", x, y, data.size());
handle = 0;
return;
}
handle = re.GenerateTexture(data.data(), x, y);
});
break;
Expand Down
16 changes: 4 additions & 12 deletions src/engine/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3184,26 +3184,18 @@ void RE_GetTextureSize( int textureID, int *width, int *height )
}
}

// This code is used to upload images produced by the game (like GUI elements produced by libRocket in Unvanquished)
int numTextures = 0;

// This code is used to upload images produced by the game (like glyphs produced by RMLUI in Unvanquished)
qhandle_t RE_GenerateTexture( const byte *pic, int width, int height )
{
size_t size = width * height;

if ( !size ) {
Log::Warn("RE_GenerateTexture: image size %dx%d is 0", width, height );
return 0;
}

R_SyncRenderThread();

const char *name = va( "rocket%d", numTextures++ );
std::string name = Str::Format( "$generatedTexture%d", tr.numGeneratedTextures++ );

imageParams_t imageParams = {};
imageParams.bits = IF_NOPICMIP;
imageParams.filterType = filterType_t::FT_LINEAR;
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;

return RE_RegisterShaderFromImage( name, R_CreateImage( name, &pic, width, height, 1, imageParams ) );
return RE_RegisterShaderFromImage(
name.c_str(), R_CreateImage( name.c_str(), &pic, width, height, 1, imageParams ) );
}
2 changes: 2 additions & 0 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2849,6 +2849,8 @@ enum class ssaoMode {

std::vector<image_t *> images;

unsigned numGeneratedTextures;

int numFBOs;
FBO_t *fbos[ MAX_FBOS ];

Expand Down