mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Support OpenGL 3 (#13321)
This commit is contained in:
parent
9cca12ff0b
commit
8093044f07
10 changed files with 26 additions and 22 deletions
|
@ -215,7 +215,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
|||
m_rendering_engine->get_raw_device()->
|
||||
setWindowCaption((utf8_to_wide(PROJECT_NAME_C) +
|
||||
L" " + utf8_to_wide(g_version_hash) +
|
||||
L" [" + wstrgettext("Main Menu") + L"]").c_str());
|
||||
L" [" + wstrgettext("Main Menu") + L"]" +
|
||||
L" [" + m_rendering_engine->getVideoDriver()->getName() + L"]" ).c_str());
|
||||
|
||||
try { // This is used for catching disconnects
|
||||
|
||||
|
|
|
@ -292,15 +292,16 @@ std::vector<video::E_DRIVER_TYPE> RenderingEngine::getSupportedVideoDrivers()
|
|||
// Order by preference (best first)
|
||||
static const video::E_DRIVER_TYPE glDrivers[] = {
|
||||
video::EDT_OPENGL,
|
||||
video::EDT_OPENGL3,
|
||||
video::EDT_OGLES2,
|
||||
video::EDT_OGLES1,
|
||||
video::EDT_NULL,
|
||||
};
|
||||
std::vector<video::E_DRIVER_TYPE> drivers;
|
||||
|
||||
for (u32 i = 0; i < ARRLEN(glDrivers); i++) {
|
||||
if (IrrlichtDevice::isDriverSupported(glDrivers[i]))
|
||||
drivers.push_back(glDrivers[i]);
|
||||
for (video::E_DRIVER_TYPE driver: glDrivers) {
|
||||
if (IrrlichtDevice::isDriverSupported(driver))
|
||||
drivers.push_back(driver);
|
||||
}
|
||||
|
||||
return drivers;
|
||||
|
@ -328,6 +329,7 @@ const VideoDriverInfo &RenderingEngine::getVideoDriverInfo(irr::video::E_DRIVER_
|
|||
static const std::unordered_map<int, VideoDriverInfo> driver_info_map = {
|
||||
{(int)video::EDT_NULL, {"null", "NULL Driver"}},
|
||||
{(int)video::EDT_OPENGL, {"opengl", "OpenGL"}},
|
||||
{(int)video::EDT_OPENGL3, {"opengl3", "OpenGL 3+"}},
|
||||
{(int)video::EDT_OGLES1, {"ogles1", "OpenGL ES1"}},
|
||||
{(int)video::EDT_OGLES2, {"ogles2", "OpenGL ES2"}},
|
||||
};
|
||||
|
|
|
@ -261,7 +261,7 @@ public:
|
|||
worldViewProj *= worldView;
|
||||
m_world_view_proj.set(*reinterpret_cast<float(*)[16]>(worldViewProj.pointer()), services);
|
||||
|
||||
if (driver->getDriverType() == video::EDT_OGLES2) {
|
||||
if (driver->getDriverType() == video::EDT_OGLES2 || driver->getDriverType() == video::EDT_OPENGL3) {
|
||||
core::matrix4 texture = driver->getTransform(video::ETS_TEXTURE_0);
|
||||
m_world_view.set(*reinterpret_cast<float(*)[16]>(worldView.pointer()), services);
|
||||
m_texture.set(*reinterpret_cast<float(*)[16]>(texture.pointer()), services);
|
||||
|
@ -594,17 +594,19 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
|
||||
|
||||
// Create shaders header
|
||||
bool use_gles = driver->getDriverType() == video::EDT_OGLES2;
|
||||
bool fully_programmable = driver->getDriverType() == video::EDT_OGLES2 || driver->getDriverType() == video::EDT_OPENGL3;
|
||||
std::stringstream shaders_header;
|
||||
shaders_header
|
||||
<< std::noboolalpha
|
||||
<< std::showpoint // for GLSL ES
|
||||
;
|
||||
std::string vertex_header, fragment_header, geometry_header;
|
||||
if (use_gles) {
|
||||
shaders_header << R"(
|
||||
#version 100
|
||||
)";
|
||||
if (fully_programmable) {
|
||||
if (driver->getDriverType() == video::EDT_OPENGL3) {
|
||||
shaders_header << "#version 150\n";
|
||||
} else {
|
||||
shaders_header << "#version 100\n";
|
||||
}
|
||||
vertex_header = R"(
|
||||
precision mediump float;
|
||||
|
||||
|
@ -658,7 +660,7 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
abort();
|
||||
}
|
||||
|
||||
bool use_discard = use_gles;
|
||||
bool use_discard = fully_programmable;
|
||||
// For renderers that should use discard instead of GL_ALPHA_TEST
|
||||
const char *renderer = reinterpret_cast<const char*>(GL.GetString(GL.RENDERER));
|
||||
if (strstr(renderer, "GC7000"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue