Add GL version command-line option
parent
8f02acdf09
commit
ce74626805
|
@ -1,5 +1,6 @@
|
|||
#include "GameWindow.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <sstream>
|
||||
|
||||
#include <al.h>
|
||||
|
@ -18,6 +19,7 @@
|
|||
#include "render/gl/Debug.hpp"
|
||||
#include "util/Log.hpp"
|
||||
#include "util/MemoryTracker.hpp"
|
||||
#include "util/StringUtil.hpp"
|
||||
|
||||
namespace diggler {
|
||||
|
||||
|
@ -50,10 +52,28 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||
|
||||
m_w = 640; m_h = 480;
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API /*GLFW_OPENGL_ES_API*/);
|
||||
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
if (GlobalProperties::GfxOverrides != nullptr) {
|
||||
for (const std::string &opt : Util::StringUtil::explode(GlobalProperties::GfxOverrides, ',')) {
|
||||
if (opt.size() == 4 && opt[0] == 'g' && opt[1] == 'l' &&
|
||||
isdigit(opt[2]) && isdigit(opt[3])) {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, opt[2] - '0');
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, opt[3] - '0');
|
||||
} else if (opt.size() == 6 && opt[0] == 'g' && opt[1] == 'l' &&
|
||||
opt[2] == 'e' && opt[3] == 's' && isdigit(opt[4]) && isdigit(opt[5])) {
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, opt[4] - '0');
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, opt[5] - '0');
|
||||
} else if (opt == "fwd") {
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
} else if (opt == "compat") {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
|
||||
} else if (opt == "core") {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere
|
||||
//glfwWindowHint(GLFW_STENCIL_BITS, 8);
|
||||
|
||||
|
|
|
@ -15,5 +15,6 @@ bool GlobalProperties::IsSoundEnabled = true;
|
|||
|
||||
int GlobalProperties::UIScale = 2;
|
||||
|
||||
char *GlobalProperties::GfxOverrides = nullptr;
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace GlobalProperties {
|
|||
extern bool IsSoundEnabled;
|
||||
|
||||
extern int UIScale;
|
||||
|
||||
extern char *GfxOverrides;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
string host = GlobalProperties::DefaultServerHost;
|
||||
int port = GlobalProperties::DefaultServerPort;
|
||||
for (int i=1; i < argc; i++) {
|
||||
for (int i=1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "-h") == 0 ||
|
||||
strcmp(argv[i], "--help") == 0) {
|
||||
showHelp(argv);
|
||||
|
@ -95,6 +95,8 @@ int main(int argc, char **argv) {
|
|||
GlobalProperties::PlayerName = argv[++i];
|
||||
Log(Info, TAG) << "Player's name set to " << GlobalProperties::PlayerName;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-g") == 0) {
|
||||
GlobalProperties::GfxOverrides = argv[++i];
|
||||
} else {
|
||||
// For now, assume it's the server address
|
||||
host = argv[i];
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
namespace diggler {
|
||||
namespace Util {
|
||||
|
||||
std::vector<std::string> explode(const std::string &s, char delim) {
|
||||
std::vector<std::string> StringUtil::explode(const std::string &s, char delim) {
|
||||
std::vector<std::string> result;
|
||||
std::istringstream iss(s);
|
||||
for (std::string token; std::getline(iss, token, delim); ) {
|
||||
|
@ -15,7 +15,7 @@ std::vector<std::string> explode(const std::string &s, char delim) {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::u32string> explode(const std::u32string &s, char32_t delim) {
|
||||
std::vector<std::u32string> StringUtil::explode(const std::u32string &s, char32_t delim) {
|
||||
std::vector<std::u32string> result;
|
||||
std::basic_istringstream<char32_t> iss(s);
|
||||
for (std::u32string token; std::getline(iss, token, delim); ) {
|
||||
|
|
Loading…
Reference in New Issue