mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 06:55:02 +01:00
geometry shader changes
This commit is contained in:
@@ -202,6 +202,17 @@ void gl::shader::log_error(const std::string &str)
|
||||
gl::shader::shader(const std::string &filename)
|
||||
{
|
||||
name = filename;
|
||||
|
||||
GLuint type;
|
||||
if (strcend(filename, ".vert"))
|
||||
type = GL_VERTEX_SHADER;
|
||||
else if (strcend(filename, ".frag"))
|
||||
type = GL_FRAGMENT_SHADER;
|
||||
else if (strcend(filename, ".geom"))
|
||||
type = GL_GEOMETRY_SHADER;
|
||||
else
|
||||
throw shader_exception("unknown shader " + filename);
|
||||
|
||||
std::string str;
|
||||
if (!Global.gfx_usegles)
|
||||
{
|
||||
@@ -209,7 +220,13 @@ gl::shader::shader(const std::string &filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
str += "#version 300 es\n";
|
||||
if (type == GL_GEOMETRY_SHADER) {
|
||||
str += "#version 310 es\n";
|
||||
str += "#extension EXT_geometry_shader : require\n";
|
||||
}
|
||||
else {
|
||||
str += "#version 300 es\n";
|
||||
}
|
||||
str += "precision highp float;\n";
|
||||
str += "precision highp sampler2DShadow;\n";
|
||||
}
|
||||
@@ -223,16 +240,6 @@ gl::shader::shader(const std::string &filename)
|
||||
if (!cstr[0])
|
||||
throw shader_exception("cannot read shader: " + filename);
|
||||
|
||||
GLuint type;
|
||||
if (strcend(filename, ".vert"))
|
||||
type = GL_VERTEX_SHADER;
|
||||
else if (strcend(filename, ".frag"))
|
||||
type = GL_FRAGMENT_SHADER;
|
||||
else if (strcend(filename, ".geom"))
|
||||
type = GL_GEOMETRY_SHADER;
|
||||
else
|
||||
throw shader_exception("unknown shader " + filename);
|
||||
|
||||
**this = glCreateShader(type);
|
||||
glShaderSource(*this, 1, &cstr, 0);
|
||||
glCompileShader(*this);
|
||||
|
||||
@@ -3901,6 +3901,9 @@ bool opengl_renderer::Init_caps()
|
||||
|
||||
if (GLAD_GL_EXT_clip_control)
|
||||
WriteLog("EXT_clip_control supported!");
|
||||
|
||||
if (GLAD_GL_EXT_geometry_shader)
|
||||
WriteLog("EXT_geometry_shader supported!");
|
||||
}
|
||||
|
||||
glGetError();
|
||||
|
||||
@@ -16,11 +16,14 @@ ui::map_panel::map_panel() : ui_panel(LOC_STR(ui_map), false)
|
||||
|
||||
gl::shader vert("map.vert");
|
||||
gl::shader frag("map.frag");
|
||||
gl::shader poi_frag("map_poi.frag");
|
||||
gl::shader poi_geom("map_poi.geom");
|
||||
|
||||
m_track_shader = std::unique_ptr<gl::program>(new gl::program({vert, frag}));
|
||||
m_poi_shader = std::unique_ptr<gl::program>(new gl::program({vert, poi_frag, poi_geom}));
|
||||
m_icon_atlas = GfxRenderer.Fetch_Texture("map_icons");
|
||||
if (GLAD_GL_EXT_geometry_shader) {
|
||||
gl::shader poi_frag("map_poi.frag");
|
||||
gl::shader poi_geom("map_poi.geom");
|
||||
m_poi_shader = std::unique_ptr<gl::program>(new gl::program({vert, poi_frag, poi_geom}));
|
||||
m_icon_atlas = GfxRenderer.Fetch_Texture("map_icons");
|
||||
}
|
||||
|
||||
m_tex = std::make_unique<opengl_texture>();
|
||||
m_tex->alloc_rendertarget(GL_RGB8, GL_RGB, fb_size, fb_size);
|
||||
@@ -120,9 +123,11 @@ void ui::map_panel::render_map_texture(glm::mat4 transform, glm::vec2 surface_si
|
||||
scene_ubo->update(scene_ubs);
|
||||
GfxRenderer.Draw_Geometry(m_switch_handles.begin(), m_switch_handles.end());
|
||||
|
||||
GfxRenderer.Bind_Texture(0, m_icon_atlas);
|
||||
m_poi_shader->bind();
|
||||
scene_ubs.scene_extra = glm::vec3(1.0f / (surface_size / 200.0f), 1.0f);
|
||||
if (GLAD_GL_EXT_geometry_shader) {
|
||||
GfxRenderer.Bind_Texture(0, m_icon_atlas);
|
||||
m_poi_shader->bind();
|
||||
scene_ubs.scene_extra = glm::vec3(1.0f / (surface_size / 200.0f), 1.0f);
|
||||
}
|
||||
|
||||
scene_ubs.time = 1.0f;
|
||||
scene_ubo->update(scene_ubs);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "widgets/map_objects.h"
|
||||
|
||||
map::objects map::Objects;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "widgets/popup.h"
|
||||
|
||||
ui::popup::popup(ui_panel &panel) : m_parent(panel) {}
|
||||
|
||||
Reference in New Issue
Block a user