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