Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
OpenGL: Print more debug info at init time
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Feb 21, 2024
1 parent c484ad1 commit b7ef60d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
19 changes: 18 additions & 1 deletion source/Irrlicht/OpenGL/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()

// print renderer information
VendorName = GL.GetString(GL_VENDOR);
os::Printer::log(VendorName.c_str(), ELL_INFORMATION);
os::Printer::log("Vendor", VendorName.c_str(), ELL_INFORMATION);

Version = getVersionFromOpenGL();
}
Expand All @@ -222,6 +222,7 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
{
initVersion();
initFeatures();
printTextureFormats();

// reset cache handler
delete CacheHandler;
Expand Down Expand Up @@ -276,6 +277,22 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
return true;
}

void COpenGL3DriverBase::printTextureFormats()
{
char buf[128];
for (u32 i = 0; i < static_cast<u32>(ECF_UNKNOWN); i++) {
auto &info = TextureFormats[i];
if (!info.InternalFormat) {
snprintf_irr(buf, sizeof(buf), "%s -> unsupported", ColorFormatNames[i]);
} else {
snprintf_irr(buf, sizeof(buf), "%s -> %#06x %#06x %#06x%s",
ColorFormatNames[i], info.InternalFormat, info.PixelFormat,
info.PixelType, info.Converter ? " (c)" : "");
}
os::Printer::log(buf, ELL_DEBUG);
}
}

void COpenGL3DriverBase::loadShaderData(const io::path& vertexShaderName, const io::path& fragmentShaderName, c8** vertexShaderData, c8** fragmentShaderData)
{
io::path vsPath(OGLES2ShaderPath);
Expand Down
3 changes: 2 additions & 1 deletion source/Irrlicht/OpenGL/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ namespace video
COpenGL3CacheHandler* getCacheHandler() const;

protected:
//! inits the opengl-es driver
virtual bool genericDriverInit(const core::dimension2d<u32>& screenSize, bool stencilBuffer);

void initVersion();
Expand Down Expand Up @@ -401,6 +400,8 @@ namespace video

IContextManager* ContextManager;

void printTextureFormats();

void addDummyMaterial(E_MATERIAL_TYPE type);

unsigned QuadIndexCount;
Expand Down
14 changes: 10 additions & 4 deletions source/Irrlicht/OpenGL/ExtensionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
#include "irrString.h"
#include "SMaterial.h"
#include "fast_atof.h"
#include "os.h"
#include <mt_opengl.h>

// FIXME: this basically duplicates what mt_opengl.h already does

namespace irr
{
namespace video
Expand All @@ -24,26 +27,29 @@ namespace video
pos = next + 1;
}
addExtension(pos);
updateLegacyExtensionList();
extensionsLoaded();
}

void COpenGL3ExtensionHandler::initExtensionsNew()
{
int ext_count = GetInteger(GL_NUM_EXTENSIONS);
for (int k = 0; k < ext_count; k++)
addExtension(reinterpret_cast<const char *>(GL.GetStringi(GL_EXTENSIONS, k)));
updateLegacyExtensionList();
extensionsLoaded();
}

void COpenGL3ExtensionHandler::addExtension(std::string name) {
void COpenGL3ExtensionHandler::addExtension(std::string &&name) {
Extensions.emplace(std::move(name));
}

bool COpenGL3ExtensionHandler::queryExtension(const std::string &name) const noexcept {
return Extensions.find(name) != Extensions.end();
}

void COpenGL3ExtensionHandler::updateLegacyExtensionList() {
void COpenGL3ExtensionHandler::extensionsLoaded() {
os::Printer::log((std::string("Loaded ") + std::to_string(Extensions.size()) + " extensions:").c_str(), ELL_DEBUG);
for (const auto &it : Extensions)
os::Printer::log((std::string(" ") + it).c_str(), ELL_DEBUG);
for (size_t j = 0; j < IRR_OGLES_Feature_Count; ++j)
FeatureAvailable[j] = queryExtension(getFeatureString(j));
}
Expand Down
4 changes: 2 additions & 2 deletions source/Irrlicht/OpenGL/ExtensionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ namespace video
bool BlendMinMaxSupported = false;

private:
void addExtension(std::string name);
void updateLegacyExtensionList();
void addExtension(std::string &&name);
void extensionsLoaded();

std::unordered_set<std::string> Extensions;
};
Expand Down

0 comments on commit b7ef60d

Please sign in to comment.