wip uniforms
This commit is contained in:
parent
e7152838d4
commit
50180bb999
|
@ -221,14 +221,16 @@ void Pudding::load_gl_context()
|
||||||
link_shader(mvp_program);
|
link_shader(mvp_program);
|
||||||
sb::Log::gl_errors("after linking");
|
sb::Log::gl_errors("after linking");
|
||||||
/* store uniform locations after linking */
|
/* store uniform locations after linking */
|
||||||
flat_texture_uniform_location = glGetUniformLocation(flat_program, "base_texture");
|
uniform["flat"]["texture"] = glGetUniformLocation(flat_program, "base_texture");
|
||||||
flat_time_uniform_location = glGetUniformLocation(flat_program, "time");
|
uniform["flat"]["time"] = glGetUniformLocation(flat_program, "time");
|
||||||
scroll_uniform_location = glGetUniformLocation(flat_program, "scroll");
|
scroll_uniform_location = glGetUniformLocation(flat_program, "scroll");
|
||||||
|
uniform["flat"]["blend"] = glGetUniformLocation(flat_program, "blend_min_hsv");
|
||||||
mvp_uniform_location = glGetUniformLocation(mvp_program, "mvp");
|
mvp_uniform_location = glGetUniformLocation(mvp_program, "mvp");
|
||||||
time_uniform_location = glGetUniformLocation(mvp_program, "time");
|
time_uniform_location = glGetUniformLocation(mvp_program, "time");
|
||||||
effect_uniform_location = glGetUniformLocation(mvp_program, "effect");
|
effect_uniform_location = glGetUniformLocation(mvp_program, "effect");
|
||||||
uv_transformation_uniform_location = glGetUniformLocation(mvp_program, "uv_transformation");
|
uv_transformation_uniform_location = glGetUniformLocation(mvp_program, "uv_transformation");
|
||||||
coordinate_bound_uniform_location = glGetUniformLocation(mvp_program, "coordinate_bound");
|
coordinate_bound_uniform_location = glGetUniformLocation(mvp_program, "coordinate_bound");
|
||||||
|
uniform["mvp"]["pudding texture"] = glGetUniformLocation(mvp_program, "pudding_texture");
|
||||||
sb::Log::gl_errors("after uniform locations");
|
sb::Log::gl_errors("after uniform locations");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,22 +745,21 @@ void Pudding::update()
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
/* switch to flat shader for background */
|
/* switch to flat shader for background */
|
||||||
glUseProgram(flat_program);
|
glUseProgram(flat_program);
|
||||||
glUniform1f(flat_time_uniform_location, time_seconds);
|
glUniform1f(uniform["flat"]["time"], time_seconds);
|
||||||
/* disable pudding attributes and enable rectangle attributes */
|
/* disable pudding attributes and enable rectangle attributes */
|
||||||
glDisableVertexAttribArray(pudding_attributes["position"]);
|
glDisableVertexAttribArray(pudding_attributes["position"]);
|
||||||
glDisableVertexAttribArray(pudding_attributes["color"]);
|
glDisableVertexAttribArray(pudding_attributes["color"]);
|
||||||
glDisableVertexAttribArray(pudding_attributes["uv"]);
|
glDisableVertexAttribArray(pudding_attributes["uv"]);
|
||||||
glEnableVertexAttribArray(rectangle_attributes["position"]);
|
glEnableVertexAttribArray(rectangle_attributes["position"]);
|
||||||
glEnableVertexAttribArray(rectangle_attributes["uv"]);
|
glEnableVertexAttribArray(rectangle_attributes["uv"]);
|
||||||
glUniform1i(flat_texture_uniform_location, 0);
|
glUniform1i(uniform["flat"]["texture"], 0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
tiles[current_tile_index].bind();
|
tiles[current_tile_index].bind();
|
||||||
/* set blend to modify white part of background, color passed is in HSV format */
|
/* set blend to modify white part of background, color passed is in HSV format */
|
||||||
GLint blend_min_hsv_location = glGetUniformLocation(flat_program, "blend_min_hsv");
|
glUniform3f(uniform["flat"]["blend"], 0.0f, 0.0f, 1.0f);
|
||||||
glUniform3f(blend_min_hsv_location, 0.0f, 0.0f, 1.0f);
|
|
||||||
glUniform1i(scroll_uniform_location, true);
|
glUniform1i(scroll_uniform_location, true);
|
||||||
/* draws rectangle vertices and rectangle texture using UV coords */
|
/* draws rectangle vertices and rectangle texture using UV coords */
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, rectangle_attributes["position"].count());
|
||||||
glUniform1i(scroll_uniform_location, false);
|
glUniform1i(scroll_uniform_location, false);
|
||||||
/* draw pudding model using MVP shader */
|
/* draw pudding model using MVP shader */
|
||||||
glUseProgram(mvp_program);
|
glUseProgram(mvp_program);
|
||||||
|
@ -784,8 +785,7 @@ void Pudding::update()
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glEnableVertexAttribArray(pudding_attributes["color"]);
|
glEnableVertexAttribArray(pudding_attributes["color"]);
|
||||||
glEnableVertexAttribArray(pudding_attributes["uv"]);
|
glEnableVertexAttribArray(pudding_attributes["uv"]);
|
||||||
GLuint pudding_texture_location = glGetUniformLocation(mvp_program, "pudding_texture");
|
glUniform1i(uniform["mvp"]["pudding texture"], 0);
|
||||||
glUniform1i(pudding_texture_location, 0);
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
get_current_item().get_active_image_texture().bind();
|
get_current_item().get_active_image_texture().bind();
|
||||||
}
|
}
|
||||||
|
@ -816,14 +816,13 @@ void Pudding::update()
|
||||||
glEnableVertexAttribArray(rectangle_attributes["uv"].index());
|
glEnableVertexAttribArray(rectangle_attributes["uv"].index());
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
/* just need to set these once since we're drawing one texture per viewport */
|
/* just need to set these once since we're drawing one texture per viewport */
|
||||||
glUniform1i(flat_texture_uniform_location, 0);
|
glUniform1i(uniform["flat"]["texture"], 0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
/* move viewport to the bottom of screen */
|
/* move viewport to the bottom of screen */
|
||||||
viewport_box.top(viewport_box.bottom(), true);
|
viewport_box.top(viewport_box.bottom(), true);
|
||||||
viewport_box.bottom(window_box(true).bottom(), true);
|
viewport_box.bottom(window_box(true).bottom(), true);
|
||||||
/* reset blend to display the original texture colors */
|
/* reset blend to display the original texture colors */
|
||||||
GLint blend_min_location = glGetUniformLocation(flat_program, "blend_min_hsv");
|
glUniform3f(uniform["flat"]["blend"], 0.0f, 0.0f, 1.0f);
|
||||||
glUniform3f(blend_min_location, 1, 0, 1);
|
|
||||||
/* draw the current item image if we're supposed to */
|
/* draw the current item image if we're supposed to */
|
||||||
if (item_display_active())
|
if (item_display_active())
|
||||||
{
|
{
|
||||||
|
@ -835,7 +834,7 @@ void Pudding::update()
|
||||||
glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height());
|
glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height());
|
||||||
get_current_item().get_active_image_texture().bind();
|
get_current_item().get_active_image_texture().bind();
|
||||||
/* draws rectangle vertices and rectangle texture using UV coords */
|
/* draws rectangle vertices and rectangle texture using UV coords */
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, rectangle_attributes["position"].count());
|
||||||
}
|
}
|
||||||
/* draw the camera if the camera has been opened */
|
/* draw the camera if the camera has been opened */
|
||||||
if (capture.isOpened())
|
if (capture.isOpened())
|
||||||
|
@ -845,11 +844,11 @@ void Pudding::update()
|
||||||
/* bind texture for drawing */
|
/* bind texture for drawing */
|
||||||
capture_texture.bind();
|
capture_texture.bind();
|
||||||
/* draws rectangle vertices and rectangle texture using UV coords */
|
/* draws rectangle vertices and rectangle texture using UV coords */
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, rectangle_attributes["position"].count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_GL_SwapWindow(get_window());
|
SDL_GL_SwapWindow(get_window());
|
||||||
sb::Log::gl_errors();
|
sb::Log::gl_errors("after update loop");
|
||||||
/* add a new item if a new barcode was scanned or entered */
|
/* add a new item if a new barcode was scanned or entered */
|
||||||
if (current_barcode != previous_barcode)
|
if (current_barcode != previous_barcode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,9 +81,10 @@ private:
|
||||||
current_tile_index = 0;
|
current_tile_index = 0;
|
||||||
cv::VideoCapture capture;
|
cv::VideoCapture capture;
|
||||||
zbar::ImageScanner image_scanner;
|
zbar::ImageScanner image_scanner;
|
||||||
|
std::map<std::string, std::map<std::string, GLuint>> uniform;
|
||||||
GLuint flat_program, mvp_program, mvp_uniform_location, time_uniform_location, effect_uniform_location,
|
GLuint flat_program, mvp_program, mvp_uniform_location, time_uniform_location, effect_uniform_location,
|
||||||
uv_transformation_uniform_location, flat_texture_uniform_location, coordinate_bound_uniform_location,
|
uv_transformation_uniform_location, coordinate_bound_uniform_location,
|
||||||
flat_time_uniform_location, scroll_uniform_location;
|
scroll_uniform_location;
|
||||||
glm::mat4 projection, model = glm::mat4(1.0f), mvp;
|
glm::mat4 projection, model = glm::mat4(1.0f), mvp;
|
||||||
std::map<std::string, sb::Attributes> rectangle_attributes, pudding_attributes = {
|
std::map<std::string, sb::Attributes> rectangle_attributes, pudding_attributes = {
|
||||||
{"position", sb::Attributes()},
|
{"position", sb::Attributes()},
|
||||||
|
@ -129,6 +130,11 @@ public:
|
||||||
|
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::map<std::string, sb::Attributes> attributes;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Plane : public Model
|
class Plane : public Model
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
/* _______________ +---------------------------------------------------------------------------------------+
|
/* _______________ ,----------------------------------------------------------------.
|
||||||
//~~~~~~~~~~~~~\\ | a game by @ohsqueezy & @sleepin |
|
//`````````````\\ \ \
|
||||||
//```````````````\\ | [ohsqueezy.itch.io] [instagram.com/sleepin] |
|
//~~~~~~~~~~~~~~~\\ \ by @ohsqueezy & @sleepin \
|
||||||
//_0_0_0_0_0_0_0_0_\\ | |
|
//=================\\ \ [ohsqueezy.itch.io] [sleepin.itch.io] \
|
||||||
//_/_/_/_/___\_\_\_\_\\ | with code licensed for copy, modification and redistribution [git.nugget.fun/pudding] |
|
// \\ \ \
|
||||||
//GGGUUUNNNKKKIIISSSSSS\\ | |
|
// \\ \ code released under the zlib license [git.nugget.fun/pudding] \
|
||||||
//_/__/__/__/_\__\__\__\_\\ | 😀 Thank you for choosing Puddendo for your business 😀 |
|
// ☆ GUNKISS ☆ \\ \ \
|
||||||
+---------------------------------------------------------------------------------------+ */
|
//_________________________\\ `---------------------------------------------------------------*/
|
||||||
|
|
||||||
#version 130
|
#version 130
|
||||||
|
|
||||||
in vec2 uv;
|
in vec2 uv;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
/* _______________ +---------------------------------------------------------------------------------------+
|
/* _______________ ,----------------------------------------------------------------.
|
||||||
//~~~~~~~~~~~~~\\ | a game by @ohsqueezy & @sleepin |
|
//`````````````\\ \ \
|
||||||
//```````````````\\ | [ohsqueezy.itch.io] [instagram.com/sleepin] |
|
//~~~~~~~~~~~~~~~\\ \ by @ohsqueezy & @sleepin \
|
||||||
//_0_0_0_0_0_0_0_0_\\ | |
|
//=================\\ \ [ohsqueezy.itch.io] [sleepin.itch.io] \
|
||||||
//_/_/_/_/___\_\_\_\_\\ | with code licensed for copy, modification and redistribution [git.nugget.fun/pudding] |
|
// \\ \ \
|
||||||
//GGGUUUNNNKKKIIISSSSSS\\ | |
|
// \\ \ code released under the zlib license [git.nugget.fun/pudding] \
|
||||||
//_/__/__/__/_\__\__\__\_\\ | 😀 Thank you for choosing Puddendo for your business 😀 |
|
// ☆ GUNKISS ☆ \\ \ \
|
||||||
+---------------------------------------------------------------------------------------+ */
|
//_________________________\\ `---------------------------------------------------------------*/
|
||||||
|
|
||||||
#version 130
|
#version 130
|
||||||
|
|
||||||
in vec2 in_position;
|
in vec2 in_position;
|
||||||
|
|
Loading…
Reference in New Issue