mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-08 17:48:46 -10:00
This adds support for rendering models using thick lines (that means lines wider than 1 pixel) which is required by the hardpoint HUD gauge. This feature was present before the switch to OpenGL code and had to be removed since the core profile does not support rendering lines wider than 1 pixel. This uses a geometry shader for converting all the triangles from a model to 3 quads along the triangle lines which are as thick as set by the model renderer. Geometry shaders are quite slow if they generate a lot of geometry (and this generates 4 times the usual amount of geometry in the shader) so it's probably not a very fast rendering operation but it is only needed once per frame so it shouldn't be too bad. I also added support for the RenderDoc API since I needed that for debugging and it might be useful in the future. It will only become active if RenderDoc is actually attached to the process so in most cases the new code will do nothing.
84 lines
1.2 KiB
C++
84 lines
1.2 KiB
C++
|
|
#include "renderdoc.h"
|
|
#include "renderdoc_app.h"
|
|
|
|
#include "globalincs/pstypes.h"
|
|
|
|
#ifdef SCP_UNIX
|
|
#include <dlfcn.h>
|
|
#endif
|
|
|
|
namespace {
|
|
bool api_loaded = false;
|
|
RENDERDOC_API_1_1_1* api = nullptr;
|
|
|
|
pRENDERDOC_GetAPI load_getAPI() {
|
|
#ifdef SCP_UNIX
|
|
auto handle = dlopen("librenderdoc.so", RTLD_NOLOAD);
|
|
auto symbol = dlsym(handle, "RENDERDOC_GetAPI");
|
|
|
|
if (handle != nullptr) {
|
|
dlclose(handle);
|
|
}
|
|
|
|
return (pRENDERDOC_GetAPI)symbol;
|
|
#else
|
|
// Renderdoc API loading is not implemented for this platform yet!
|
|
return nullptr;
|
|
#endif
|
|
}
|
|
|
|
}
|
|
|
|
namespace renderdoc {
|
|
|
|
bool loadApi() {
|
|
if (api_loaded) {
|
|
return true;
|
|
}
|
|
|
|
auto getAPI = load_getAPI();
|
|
|
|
if (getAPI == nullptr) {
|
|
return false;
|
|
}
|
|
|
|
auto res = getAPI(eRENDERDOC_API_Version_1_1_1, reinterpret_cast<void**>(&api));
|
|
|
|
if (res != 1) {
|
|
return false;
|
|
}
|
|
|
|
api_loaded = true;
|
|
|
|
return true;
|
|
}
|
|
|
|
void triggerCapture() {
|
|
if (!api_loaded) {
|
|
// Do nothing if API is not available
|
|
return;
|
|
}
|
|
|
|
api->TriggerCapture();
|
|
}
|
|
void startCapture() {
|
|
if (api_loaded) {
|
|
api->StartFrameCapture(nullptr, nullptr);
|
|
}
|
|
}
|
|
bool isCapturing() {
|
|
if (api_loaded) {
|
|
return api->IsFrameCapturing() == 1;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
void endCapture() {
|
|
if (api_loaded) {
|
|
api->EndFrameCapture(nullptr, nullptr);
|
|
}
|
|
}
|
|
|
|
}
|