|
@@ -13,6 +13,7 @@ namespace render_texture_impl {
|
|
|
bool init_ok = false;
|
|
bool init_ok = false;
|
|
|
|
|
|
|
|
using pg_type = std::unique_ptr<smart_program>;
|
|
using pg_type = std::unique_ptr<smart_program>;
|
|
|
|
|
+ pg_type pg_bw; // render black/white texture
|
|
|
pg_type pg_rgb; // render rgb texture
|
|
pg_type pg_rgb; // render rgb texture
|
|
|
pg_type pg_rgba; // render rgba texture
|
|
pg_type pg_rgba; // render rgba texture
|
|
|
pg_type pg_rgb_d; // render rgb and depth texture
|
|
pg_type pg_rgb_d; // render rgb and depth texture
|
|
@@ -74,22 +75,46 @@ namespace render_texture_impl {
|
|
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
|
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // render bw texture
|
|
|
|
|
+ void ren_bw_only(const tex_render_info &info) {
|
|
|
|
|
+ auto &pg = pg_bw;
|
|
|
|
|
+ if (pg == nullptr) {
|
|
|
|
|
+ pg = std::unique_ptr<smart_program>(
|
|
|
|
|
+ smart_program::create("tex_bw",
|
|
|
|
|
+ {{GL_VERTEX_SHADER, "tex.vert"},
|
|
|
|
|
+ {GL_FRAGMENT_SHADER, "tex_bw.frag"}}));
|
|
|
|
|
+ }
|
|
|
|
|
+ assert(pg != nullptr);
|
|
|
|
|
+ pg->use();
|
|
|
|
|
+
|
|
|
|
|
+ pg->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
+
|
|
|
|
|
+ glActiveTexture(GL_TEXTURE0 + 0);
|
|
|
|
|
+ glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
|
|
|
+ pg->set_uniform_i("c_tex", 0);
|
|
|
|
|
+
|
|
|
|
|
+ glDisable(GL_DEPTH_TEST);
|
|
|
|
|
+ config_buffers(info);
|
|
|
|
|
+ draw();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// render rgb texture
|
|
// render rgb texture
|
|
|
void ren_rgb_only(const tex_render_info &info) {
|
|
void ren_rgb_only(const tex_render_info &info) {
|
|
|
- if (pg_rgb == nullptr) {
|
|
|
|
|
- pg_rgb = std::unique_ptr<smart_program>(
|
|
|
|
|
|
|
+ auto &pg = pg_rgb;
|
|
|
|
|
+ if (pg == nullptr) {
|
|
|
|
|
+ pg = std::unique_ptr<smart_program>(
|
|
|
smart_program::create("tex_rgb",
|
|
smart_program::create("tex_rgb",
|
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
|
{GL_FRAGMENT_SHADER, "tex_rgb.frag"}}));
|
|
{GL_FRAGMENT_SHADER, "tex_rgb.frag"}}));
|
|
|
}
|
|
}
|
|
|
- assert(pg_rgb != nullptr);
|
|
|
|
|
- pg_rgb->use();
|
|
|
|
|
|
|
+ assert(pg != nullptr);
|
|
|
|
|
+ pg->use();
|
|
|
|
|
|
|
|
- pg_rgb->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
|
|
+ pg->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
|
- pg_rgb->set_uniform_i("c_tex", 0);
|
|
|
|
|
|
|
+ pg->set_uniform_i("c_tex", 0);
|
|
|
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
config_buffers(info);
|
|
config_buffers(info);
|
|
@@ -97,20 +122,21 @@ namespace render_texture_impl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ren_rgba_only(const tex_render_info &info) {
|
|
void ren_rgba_only(const tex_render_info &info) {
|
|
|
- if (pg_rgba == nullptr) {
|
|
|
|
|
- pg_rgba = std::unique_ptr<smart_program>(
|
|
|
|
|
|
|
+ auto &pg = pg_rgba;
|
|
|
|
|
+ if (pg == nullptr) {
|
|
|
|
|
+ pg = std::unique_ptr<smart_program>(
|
|
|
smart_program::create("tex_rgba",
|
|
smart_program::create("tex_rgba",
|
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
|
{GL_FRAGMENT_SHADER, "tex_rgba.frag"}}));
|
|
{GL_FRAGMENT_SHADER, "tex_rgba.frag"}}));
|
|
|
}
|
|
}
|
|
|
- assert(pg_rgba != nullptr);
|
|
|
|
|
- pg_rgba->use();
|
|
|
|
|
|
|
+ assert(pg != nullptr);
|
|
|
|
|
+ pg->use();
|
|
|
|
|
|
|
|
- pg_rgba->set_uniform_f("opacity", info.color.opacity);
|
|
|
|
|
|
|
+ pg->set_uniform_f("opacity", info.color.opacity);
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
|
- pg_rgba->set_uniform_i("c_tex", 0);
|
|
|
|
|
|
|
+ pg->set_uniform_i("c_tex", 0);
|
|
|
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
config_buffers(info);
|
|
config_buffers(info);
|
|
@@ -118,23 +144,24 @@ namespace render_texture_impl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ren_rgb_d(const tex_render_info &info) {
|
|
void ren_rgb_d(const tex_render_info &info) {
|
|
|
- if (pg_rgb_d == nullptr) {
|
|
|
|
|
- pg_rgb_d = std::unique_ptr<smart_program>(
|
|
|
|
|
|
|
+ auto &pg = pg_rgb_d;
|
|
|
|
|
+ if (pg == nullptr) {
|
|
|
|
|
+ pg = std::unique_ptr<smart_program>(
|
|
|
smart_program::create("tex_rgb_d",
|
|
smart_program::create("tex_rgb_d",
|
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
|
{GL_FRAGMENT_SHADER, "tex_rgb_d.frag"}}));
|
|
{GL_FRAGMENT_SHADER, "tex_rgb_d.frag"}}));
|
|
|
}
|
|
}
|
|
|
- assert(pg_rgb_d != nullptr);
|
|
|
|
|
- pg_rgb_d->use();
|
|
|
|
|
|
|
+ assert(pg != nullptr);
|
|
|
|
|
+ pg->use();
|
|
|
|
|
|
|
|
- pg_rgb_d->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
|
|
+ pg->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
|
- pg_rgb_d->set_uniform_i("c_tex", 0);
|
|
|
|
|
|
|
+ pg->set_uniform_i("c_tex", 0);
|
|
|
glActiveTexture(GL_TEXTURE0 + 1);
|
|
glActiveTexture(GL_TEXTURE0 + 1);
|
|
|
glBindTexture(GL_TEXTURE_2D, info.depth.id);
|
|
glBindTexture(GL_TEXTURE_2D, info.depth.id);
|
|
|
- pg_rgb_d->set_uniform_i("d_tex", 1);
|
|
|
|
|
|
|
+ pg->set_uniform_i("d_tex", 1);
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
config_buffers(info);
|
|
config_buffers(info);
|
|
@@ -142,23 +169,24 @@ namespace render_texture_impl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ren_nv12_only(const tex_render_info &info) {
|
|
void ren_nv12_only(const tex_render_info &info) {
|
|
|
- if (pg_nv12 == nullptr) {
|
|
|
|
|
- pg_nv12 = std::unique_ptr<smart_program>(
|
|
|
|
|
|
|
+ auto &pg = pg_nv12;
|
|
|
|
|
+ if (pg == nullptr) {
|
|
|
|
|
+ pg = std::unique_ptr<smart_program>(
|
|
|
smart_program::create("tex_nv12",
|
|
smart_program::create("tex_nv12",
|
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
{{GL_VERTEX_SHADER, "tex.vert"},
|
|
|
{GL_FRAGMENT_SHADER, "tex_nv12.frag"}}));
|
|
{GL_FRAGMENT_SHADER, "tex_nv12.frag"}}));
|
|
|
}
|
|
}
|
|
|
- assert(pg_nv12 != nullptr);
|
|
|
|
|
- pg_nv12->use();
|
|
|
|
|
|
|
+ assert(pg != nullptr);
|
|
|
|
|
+ pg->use();
|
|
|
|
|
|
|
|
- pg_nv12->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
|
|
+ pg->set_uniform_f("alpha", info.color.alpha);
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
glActiveTexture(GL_TEXTURE0 + 0);
|
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id);
|
|
|
- pg_nv12->set_uniform_i("luma_tex", 0);
|
|
|
|
|
|
|
+ pg->set_uniform_i("luma_tex", 0);
|
|
|
glActiveTexture(GL_TEXTURE0 + 1);
|
|
glActiveTexture(GL_TEXTURE0 + 1);
|
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id_ext[0]);
|
|
glBindTexture(GL_TEXTURE_2D, info.color.id_ext[0]);
|
|
|
- pg_nv12->set_uniform_i("chroma_tex", 1);
|
|
|
|
|
|
|
+ pg->set_uniform_i("chroma_tex", 1);
|
|
|
|
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
config_buffers(info);
|
|
config_buffers(info);
|
|
@@ -167,6 +195,10 @@ namespace render_texture_impl {
|
|
|
|
|
|
|
|
void ren_c_only(const tex_render_info &info) {
|
|
void ren_c_only(const tex_render_info &info) {
|
|
|
switch (info.color.fmt) {
|
|
switch (info.color.fmt) {
|
|
|
|
|
+ case COLOR_BW: {
|
|
|
|
|
+ ren_bw_only(info);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
case COLOR_RGB: {
|
|
case COLOR_RGB: {
|
|
|
ren_rgb_only(info);
|
|
ren_rgb_only(info);
|
|
|
break;
|
|
break;
|