12 #ifndef GLVIS_RENDERER_HPP
13 #define GLVIS_RENDERER_HPP
18 #include <unordered_map>
22 #include "../material.hpp"
23 #include "../palettes.hpp"
28 using namespace resource;
31 #ifdef GLVIS_MS_LINEWIDTH
46 std::array<Light, LIGHTS_MAX>
lights;
73 : position(pos), color(c) { }
75 : position(pos), color(c) { }
86 : offset(t_off), color(t_color), text(std::move(txt)) { }
120 const static int SAMPLER_COLOR = 0;
121 const static int SAMPLER_ALPHA = 1;
125 glActiveTexture(GL_TEXTURE0 + tex_unit);
126 glBindTexture(GL_TEXTURE_2D, passthrough_texture);
130 glActiveTexture(GL_TEXTURE0 + tex_unit);
131 glBindTexture(GL_TEXTURE_2D, tex_id);
136 static bool useLegacyTextureFmts();
145 virtual DeviceType getType() = 0;
147 void setViewport(GLsizei w, GLsizei h);
149 void getViewport(GLint (&vp)[4]);
156 virtual void setTransformMatrices(glm::mat4 model_view, glm::mat4 projection);
159 virtual void setNumLights(
int i) = 0;
161 virtual void setMaterial(
Material mat) = 0;
163 virtual void setPointLight(
int i,
Light lt) = 0;
165 virtual void setAmbientLight(
const std::array<float, 4>& amb) = 0;
167 virtual void setClipPlaneUse(
bool enable) = 0;
169 virtual void setClipPlaneEqn(
const std::array<double, 4>& eqn) = 0;
176 virtual void bufferToDevice(
TextBuffer& t_buf) = 0;
178 virtual void drawDeviceBuffer(
int hnd) = 0;
179 virtual void drawDeviceBuffer(
const TextBuffer& t_buf) = 0;
198 unique_ptr<GLDevice> device;
201 GLuint color_tex, alpha_tex, font_tex;
205 bool feat_use_fbo_antialias;
214 template<
typename TDevice>
217 device.reset(
new TDevice());
218 device->setLineWidth(
line_w);
223 template<
typename TDevice>
226 device.reset(
new TDevice(dev));
237 void setAntialiasing(
bool aa_status);
241 if (msaa_samples < samples)
243 std::cerr <<
"GL_MAX_SAMPLES = " << msaa_samples
244 <<
" but requested " << samples <<
"x MSAA. ";
245 std::cerr <<
"Setting antialiasing mode to "
246 << msaa_samples <<
"x MSAA." << endl;
250 msaa_samples = samples;
255 void setLineWidth(
float w);
257 void setLineWidthMS(
float w);
260 void setClearColor(
float r,
float g,
float b,
float a) { glClearColor(r, g, b, a); }
261 void setViewport(GLsizei w, GLsizei h) { device->setViewport(w, h); }
271 #endif // GLVIS_RENDERER_HPP
void setLineWidth(float w)
void setDevice(TDevice &&dev)
void setClearColor(float r, float g, float b, float a)
void setSamplesMSAA(int samples)
TextureHandle passthrough_texture
void setViewport(GLsizei w, GLsizei h)
void setPalette(PaletteState *pal)
void setAlphaTexture(GLuint tex_h)
FeedbackText(glm::vec3 t_off, glm::vec4 t_color, std::string txt)
void attachTexture(int tex_unit, int tex_id)
std::array< float, 4 > light_amb_scene
vector< FeedbackText > text
std::array< Light, LIGHTS_MAX > lights
virtual void exitXfbMode()
std::array< float, 4 > static_color
FeedbackVertex(glm::vec4 pos, glm::vec4 c)
void setFontTexture(GLuint tex_h)
void setStaticColor(const std::array< float, 4 > &rgba)
void detachTexture(int tex_unit)
vector< FeedbackVertex > lines
vector< pair< RenderParams, GlDrawable * > > RenderQueue
bool contains_translucent
void setColorTexture(GLuint tex_h)
vector< GlDrawable * > needs_buffering
vector< FeedbackVertex > triangles
std::array< float, 4 > static_color
virtual void initXfbMode()
const float LINE_WIDTH_AA
std::array< double, 4 > clip_plane_eqn
FeedbackVertex(glm::vec3 pos, glm::vec4 c)