portrait resolution
This commit is contained in:
parent
081681bfe7
commit
ffede89153
26
Makefile
26
Makefile
|
@ -79,7 +79,7 @@ $(SRC_DIR)Pudding.o : $(SRC_H_FILES) $(SB_H_FILES)
|
|||
|
||||
linux : CC = clang
|
||||
linux : CPPC = clang++
|
||||
linux : CFLAGS = -g -Wall -Wextra -Og -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) $(SDL_CFLAGS) -I$(HOME)/local/zbar/include \
|
||||
linux : CFLAGS = -g -Wall -Wextra -O0 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) $(SDL_CFLAGS) -I$(HOME)/local/zbar/include \
|
||||
-I$(HOME)/local/opencv/include/opencv4
|
||||
linux : CPP_FLAGS = $(CFLAGS) --std=c++17
|
||||
linux : LFLAGS = $(SDL_LFLAGS) -lpthread -lGL -lGLESv2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lcurl -lstdc++fs \
|
||||
|
@ -94,18 +94,32 @@ linux : $(GLEW_DIR)glew.o $(addprefix $(SDLGFX2_DIR),SDL2_rotozoom.o SDL2_gfxPri
|
|||
# Clean up object files #
|
||||
#########################
|
||||
|
||||
.PHONY : clean
|
||||
clean :
|
||||
-rm $(SRC_DIR)*.o
|
||||
|
||||
.PHONY : clean-all
|
||||
clean-all :
|
||||
-find . -iname "*.o" -exec rm {} \;
|
||||
|
||||
#
|
||||
#############
|
||||
# compiledb #
|
||||
#############
|
||||
|
||||
# Generate a clang JSON compilation database file. This can be useful for example for code completion. It requires a
|
||||
# compiledb binary (https://pypi.org/project/compiledb/). It should be generated manually every time a file is added,
|
||||
# renamed, or the compilation flags change. The generated database is based on the Linux build.
|
||||
|
||||
PATH_TO_COMPILEDB = $(HOME)/.local/bin/compiledb
|
||||
compiledb :
|
||||
-$(PATH_TO_COMPILEDB) -n make linux -k
|
||||
|
||||
#####################
|
||||
# cross compilation #
|
||||
#####################
|
||||
|
||||
# WARNING: untested
|
||||
|
||||
# Below assignments and targets are necessary for cross-compiling to Android, web (via emscripten), Windows (via mingw),
|
||||
# and OS/X. Cross-compilation targets have not been tested in a while and won't compile without significant changes.
|
||||
#
|
||||
# and OS/X, but cross-compilation targets have not been tested in a while and won't compile without significant changes.
|
||||
|
||||
BUILDDIR := build
|
||||
EXT_SRC_ROOT := /home/frank/ext/software
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
{
|
||||
"print-video-memory-size": ["CTRL", "v"],
|
||||
"print-frame-length-history": ["CTRL", "SHIFT", "h"],
|
||||
"toggle-camera": ["CTRL", "c"]
|
||||
"toggle-camera": ["CTRL", "c"],
|
||||
"toggle-item": ["CTRL", "i"]
|
||||
},
|
||||
"recording":
|
||||
{
|
||||
|
@ -43,7 +44,7 @@
|
|||
{
|
||||
"json-save": true,
|
||||
"json-save-directory": "local/scans",
|
||||
"barcode": "2430373621232",
|
||||
"barcode": "071146005280",
|
||||
"capture-device": "/dev/video0"
|
||||
},
|
||||
"api":
|
||||
|
|
2
lib/sb
2
lib/sb
|
@ -1 +1 @@
|
|||
Subproject commit ada139c26fa88bbf15763dcfc269973924201b0a
|
||||
Subproject commit 18f83968f3f2b7480d7557e18946f51706dda6b6
|
|
@ -3,8 +3,8 @@
|
|||
//`````````````\\ + a game by @ohsqueezy (ohsqueezy.itch.io) & @sleepin (instagram.com/sleepin)
|
||||
//~~~~~~~~~~~~~~~\\ + code is licensed for copy, modification and redistribution (git.nugget.fun/pudding)
|
||||
//=================\\
|
||||
// \\
|
||||
//-G--U--N--K--I--S--S-\\ 😀 Thank you for choosing Puddendo for your business 😀
|
||||
/// \\\
|
||||
///G-*U-*N-*K-*I-*S-*S\\\ 😀 Thank you for choosing Puddendo for your business 😀
|
||||
//_______________________\\
|
||||
```````````````````````````
|
||||
|
||||
|
@ -283,6 +283,10 @@ void Pudding::respond(SDL_Event& event)
|
|||
initialize_camera();
|
||||
}
|
||||
}
|
||||
else if (get_delegate().compare(event, "toggle-item"))
|
||||
{
|
||||
show_item = !show_item;
|
||||
}
|
||||
}
|
||||
|
||||
/* Build an Item object by submitting the upc parameter to multiple APIs and taking
|
||||
|
@ -617,9 +621,16 @@ Item& Pudding::get_current_item()
|
|||
return items[current_item_index];
|
||||
}
|
||||
|
||||
/* Returns true if item display is toggled on and there is at least one item to display */
|
||||
bool Pudding::item_display_active() const
|
||||
{
|
||||
return show_item && items.size() > 0;
|
||||
}
|
||||
|
||||
/* Update parameters and draw the screen */
|
||||
void Pudding::update()
|
||||
{
|
||||
/* if the config is set to refresh automatically, there may be a new barcode available */
|
||||
if (current_config_barcode != get_configuration()["scan"]["barcode"])
|
||||
{
|
||||
current_config_barcode = get_configuration()["scan"]["barcode"];
|
||||
|
@ -629,13 +640,13 @@ void Pudding::update()
|
|||
log(message.str());
|
||||
}
|
||||
/* viewport box will be used to tell GL where to draw */
|
||||
Box viewport_box = window_box();
|
||||
Box viewport_box = window_box(true);
|
||||
/* shrink viewport if item texture or camera will be displayed */
|
||||
if (items.size() > 0 || capture.isOpened())
|
||||
if (item_display_active() || capture.isOpened())
|
||||
{
|
||||
viewport_box.right(window_box().cx(), true);
|
||||
viewport_box.drag_bottom(0.3f * viewport_box.height());
|
||||
}
|
||||
glViewport(viewport_box.left(), viewport_box.top(), viewport_box.width(), viewport_box.height());
|
||||
glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height());
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -661,7 +672,7 @@ void Pudding::update()
|
|||
/* calculate the transformation matrix for displaying pudding in viewport */
|
||||
model = glm::rotate(model, weight(get_configuration()["pudding"]["rotation-speed"].get<float>()), Y_UNIT_NORMAL_3D);
|
||||
projection = glm::perspective(
|
||||
glm::radians(viewport_box.width() > viewport_box.height() ? 40.0f : 45.0f), viewport_box.aspect(), 0.1f, 100.0f);
|
||||
glm::radians(40.0f * 1 / viewport_box.aspect()), viewport_box.aspect(), 0.1f, 100.0f);
|
||||
mvp = projection * VIEW_MATRIX * model;
|
||||
/* pass the mvp matrix to the shader */
|
||||
glUniformMatrix4fv(mvp_id, 1, GL_FALSE, &mvp[0][0]);
|
||||
|
@ -671,10 +682,12 @@ void Pudding::update()
|
|||
glEnableVertexAttribArray(2);
|
||||
if (items.size() == 0)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glEnableVertexAttribArray(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glEnableVertexAttribArray(4);
|
||||
GLuint pudding_texture_location = glGetUniformLocation(mvp_program, "pudding_texture");
|
||||
glUniform1i(pudding_texture_location, 0);
|
||||
|
@ -682,11 +695,10 @@ void Pudding::update()
|
|||
glBindTexture(GL_TEXTURE_2D, *get_current_item().get_active_image_texture().get());
|
||||
}
|
||||
/* draw pudding model */
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDrawArrays(GL_TRIANGLES, 0, pudding_vertices.size());
|
||||
/* only do more drawing if items are downloaded or camera is enabled */
|
||||
if (items.size() > 0 || capture.isOpened())
|
||||
if (item_display_active() || capture.isOpened())
|
||||
{
|
||||
/* switch to flat shader for item and camera */
|
||||
glUseProgram(flat_program);
|
||||
|
@ -700,20 +712,21 @@ void Pudding::update()
|
|||
GLint base_texture_location = glGetUniformLocation(flat_program, "base_texture");
|
||||
glUniform1i(base_texture_location, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
/* move viewport to the right side of screen */
|
||||
viewport_box.left(window_box().cx());
|
||||
/* 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);
|
||||
/* draw the current item image if items have been downloaded */
|
||||
if (items.size() > 0)
|
||||
/* draw the current item image if we're supposed to */
|
||||
if (item_display_active())
|
||||
{
|
||||
/* shrink viewport to half size if camera will also be displayed */
|
||||
if (capture.isOpened())
|
||||
{
|
||||
viewport_box.top(window_box().cy(), true);
|
||||
viewport_box.left(viewport_box.cx(), true);
|
||||
}
|
||||
glViewport(viewport_box.left(), viewport_box.top(), viewport_box.width(), viewport_box.height());
|
||||
glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height());
|
||||
glBindTexture(GL_TEXTURE_2D, *get_current_item().get_active_image_texture().get());
|
||||
/* draws rectangle vertices and rectangle texture using UV coords */
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
@ -722,12 +735,12 @@ void Pudding::update()
|
|||
if (capture.isOpened())
|
||||
{
|
||||
capture.read(capture_frame);
|
||||
viewport_box.top(window_box().top());
|
||||
viewport_box.left(window_box(true).left());
|
||||
if (!capture_frame.empty())
|
||||
{
|
||||
/* rotate the opencv matrix 180 to work with opengl coords */
|
||||
cv::flip(capture_frame, capture_frame, -1);
|
||||
glViewport(viewport_box.left(), viewport_box.top(), viewport_box.width(), viewport_box.height());
|
||||
glViewport(viewport_box.left(), viewport_box.bottom(), viewport_box.width(), viewport_box.height());
|
||||
/* bind texture, binding it to accept pixel data and to GLSL sampler */
|
||||
glBindTexture(GL_TEXTURE_2D, video_capture_texture_id);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, capture_frame.cols, capture_frame.rows, GL_BGR, GL_UNSIGNED_BYTE, capture_frame.ptr());
|
||||
|
|
|
@ -50,6 +50,7 @@ private:
|
|||
glm::mat4 projection, model = glm::mat4(1.0f), mvp;
|
||||
std::vector<glm::vec3> pudding_vertices, pudding_colors;
|
||||
std::vector<glm::vec2> pudding_uv;
|
||||
bool show_item;
|
||||
|
||||
void set_pudding_model(float, float, int, int = 1, float = -1, float = 1, float = 0.3f);
|
||||
void load_gl_context();
|
||||
|
@ -64,6 +65,7 @@ private:
|
|||
static size_t curl_write_response(std::uint8_t*, size_t, size_t, std::vector<std::uint8_t>*);
|
||||
std::shared_ptr<GLuint> texture_from_image_url(const std::string&);
|
||||
static void destroy_texture(GLuint*);
|
||||
bool item_display_active() const;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in New Issue