added android build and curl error checking

This commit is contained in:
ohsqueezy 2023-05-10 03:04:46 -04:00
parent bdadda618f
commit 5cf39db71e
10 changed files with 3637 additions and 39 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ gunkiss
*.data
*.wasm
gunkiss.js
build/

View File

@ -88,12 +88,12 @@ $(SRC_DIR)Pudding.o : $(SRC_H_FILES) $(SB_H_FILES)
# Linux build #
###############
gunkiss : CFLAGS = -g -Wall -Wextra -O1 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) $(SDL_CFLAGS) -I$(HOME)/local/zbar/include \
gunkiss : CFLAGS = -g -Wall -Wextra -O1 -c -I$(SB_LIB_DIR) -I$(SB_SRC_DIR) $(SDL_CFLAGS) \
-I $(HOME)/local/opencv/include/opencv4 -I $(HOME)/ext/software/emsdk/upstream/emscripten/system/include
gunkiss : CXXFLAGS = $(CFLAGS) --std=c++17
gunkiss : LFLAGS = $(SDL_LFLAGS) -Wl,--enable-new-dtags -lpthread -lGL -lGLESv2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lstdc++fs -lcurl \
-L$(HOME)/local/opencv/lib -Wl,-rpath,$(HOME)/local/opencv/lib -lopencv_videoio -lopencv_core -lopencv_highgui -lopencv_imgproc \
-l opencv_barcode -L$(HOME)/local/zbar/lib -Wl,-rpath,$(HOME)/local/zbar/lib -lzbar
-l opencv_barcode
gunkiss : $(GLEW_DIR)glew.o $(addprefix $(SDLGFX2_DIR),SDL2_rotozoom.o SDL2_gfxPrimitives.o) \
$(SB_O_FILES) $(SRC_O_FILES)
$(CREATE_FONT_SYMLINK)
@ -107,10 +107,10 @@ gunkiss : $(GLEW_DIR)glew.o $(addprefix $(SDLGFX2_DIR),SDL2_rotozoom.o SDL2_gfxP
EMSCRIPTENHOME = $(HOME)/ext/software/emsdk/upstream/emscripten
EMSCRIPTEN_CFLAGS = -O0 -Wall -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS="['png', 'jpg']" -s USE_SDL_TTF=2 -s USE_SDL_MIXER=2 \
--no-heap-copy -I $(SB_LIB_DIR) -I $(SB_SRC_DIR) -I $(HOME)/local/zbar/include -I $(HOME)/local/opencv/include/opencv4
--no-heap-copy -I $(SB_LIB_DIR) -I $(SB_SRC_DIR) -I $(HOME)/local/opencv/include/opencv4
EMSCRIPTEN_LFLAGS = -s MIN_WEBGL_VERSION=2 -s EXPORTED_FUNCTIONS="['_main', '_malloc']" -s ALLOW_MEMORY_GROWTH=1 -s FULL_ES3=1 \
-sLLD_REPORT_UNDEFINED -s FETCH --bind $(wildcard $(addprefix $(HOME)/ext/software/opencv-4.6.0/build_wasm_contrib/lib/,*.a)) \
$(wildcard $(addprefix $(HOME)/ext/software/opencv-4.6.0/build_wasm_contrib/3rdparty/lib/,*.a)) $(HOME)/ext/software/ZBar/zbar/.libs/libzbar.a \
$(wildcard $(addprefix $(HOME)/ext/software/opencv-4.6.0/build_wasm_contrib/3rdparty/lib/,*.a)) \
-sNO_DISABLE_EXCEPTION_CATCHING
EMSCRIPTEN_PRELOADS = --preload-file "BPmono.ttf"@/ --preload-file "config.json"@/ --preload-file "resource/"@/"resource/" \
--preload-file "src/shaders/"@/"src/shaders/"
@ -123,6 +123,78 @@ gunkiss.js : $(addprefix $(SDLGFX2_DIR),SDL2_rotozoom.o SDL2_gfxPrimitives.o) $(
$(CREATE_FONT_SYMLINK)
$(CXX) $^ $(CXXFLAGS) $(EMSCRIPTEN_LFLAGS) $(EMSCRIPTEN_PRELOADS) -o gunkiss.js
#################
# Android build #
#################
# Detailed info on how this build target was originally created for the fill_screen demo is in README.md at the root of the repository. It
# requires the Android SDK and the source packages for SDL. The paths below should be edited to match the local system. Icon creation requires
# Imagemagick's convert tool from <https://imagemagick.org/>. OpenCV Android SDK is also required (see the main SPACEBOX README for how to
# build).
OPENCV_ANDROID_SDK := $(HOME)/ext/software/opencv-4.7.0/build_android/OpenCV-android-sdk
CURL_ANDROID := $(HOME)/ext/software/libcurl-android
ANDROID_LIBRARIES_MK := src/AndroidLibraries.mk
SDL_SRC := $(HOME)/ext/software/SDL2-2.26.3
SDL_IMAGE_SRC := $(HOME)/ext/software/SDL2_image-2.6.2-android
SDL_MIXER_SRC := $(HOME)/ext/software/SDL2_mixer-2.6.2-android
SDL_TTF_SRC := $(HOME)/ext/software/SDL2_ttf-2.20.1-android
SDL_ANDROID_PROJECT := $(SDL_SRC)/android-project
ANDROID_MK := app/jni/src/Android.mk
ANDROID_APP_MK := app/jni/Application.mk
ANDROID_MANIFEST := app/src/main/AndroidManifest.xml
ANDROID_SDK := $(HOME)/local/Android
ANDROID_PACKAGE := ooo.shampoo.foam
ANDROID_BUILD_DIR := build/android/$(ANDROID_PACKAGE)
ANDROID_CLASS := Pudding
ANDROID_CLASS_DIR := app/src/main/java/$(subst .,/,$(ANDROID_PACKAGE))
# The skeleton for the Android build is based on the SDL android-project. The libraries are symlinked in. If the script that rewrites the skeleton
# has changed, start with a fresh skeleton. Use the SPACEBOX revise skeleton script to edit the SDL android-project parameters. Then add OpenCV to
# the android-project include and library paths.
$(ANDROID_BUILD_DIR): $(SDL_SRC)/android-project/ $(SB_SRC_DIR)/android/revise_skeleton.sh
-mkdir -p $(ANDROID_BUILD_DIR)
rsync -ar $(SDL_SRC)/android-project/ $(ANDROID_BUILD_DIR)
ln -nsf $(SDL_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL
ln -nsf $(SDL_IMAGE_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_image
ln -nsf $(SDL_MIXER_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_mixer
ln -nsf $(SDL_TTF_SRC) $(ANDROID_BUILD_DIR)/app/jni/SDL2_ttf
$(SB_SRC_DIR)/android/revise_skeleton.sh $(ANDROID_PACKAGE) $(ANDROID_BUILD_DIR) $(ANDROID_MANIFEST) $(ANDROID_APP_MK) $(ANDROID_MK) $(ANDROID_CLASS) \
$(ANDROID_APP_NAME) $(ANDROID_MIN_TARGET) $(ANDROID_NDK) "Gunkiss" "21" "24.0.8215888" $(SB_SRC_DIR) $(SB_LIB_DIR) $(SRC_DIR)
ln -nsf $(OPENCV_ANDROID_SDK)/sdk/native/libs $(ANDROID_BUILD_DIR)/app/jni/src/opencv
ln -nsf $(CURL_ANDROID)/jni/build/curl $(ANDROID_BUILD_DIR)/app/jni/src/curl
ln -nsf $(CURL_ANDROID)/jni/build/openssl $(ANDROID_BUILD_DIR)/app/jni/src/openssl
sed -i "s/^APP_CPPFLAGS.*/& -nostartfiles/" "$(ANDROID_BUILD_DIR)/$(ANDROID_APP_MK)"
sed -i 's/^LOCAL_SHARED_LIBRARIES.*/& tbb opencv_world curl ssl crypto/' "$(ANDROID_BUILD_DIR)/$(ANDROID_MK)"
sed -i "s/org.libsdl.app/$(ANDROID_PACKAGE)/" "$(ANDROID_BUILD_DIR)/app/build.gradle" "$(ANDROID_BUILD_DIR)/$(ANDROID_MANIFEST)"
sed -i '10i\<uses-permission android:name="android.permission.CAMERA" />\n\
<uses-feature android:name="android.hardware.camera" />\n\
<uses-feature android:name="android.hardware.autofocus" />\n\
<uses-permission android:name="android.permission.INTERNET" />' "$(ANDROID_BUILD_DIR)/$(ANDROID_MANIFEST)"
sed -i "3i\OPENCV_ANDROID_SDK := $(OPENCV_ANDROID_SDK)" "$(ANDROID_BUILD_DIR)/$(ANDROID_MK)"
sed -i "4i\CURL_ANDROID := $(CURL_ANDROID)" "$(ANDROID_BUILD_DIR)/$(ANDROID_MK)"
sed -i -e "4r $(ANDROID_LIBRARIES_MK)" "$(ANDROID_BUILD_DIR)/$(ANDROID_MK)"
# Extend the SDLActivity class
$(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)/$(ANDROID_CLASS).java: $(SB_SRC_DIR)/android/main_class.sh
$(SB_SRC_DIR)/android/main_class.sh $(ANDROID_PACKAGE) $(ANDROID_CLASS) $(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)
# Generate icon
$(ANDROID_BUILD_DIR)/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: $(SB_SRC_DIR)/android/generate_icon.sh $(SB_DIR)/icon
$(SB_SRC_DIR)/android/generate_icon.sh $(ANDROID_BUILD_DIR) "$(SB_DIR)/icon/foreground.png" "$(SB_DIR)/icon/background.png"
# Custom assets
$(ANDROID_BUILD_DIR)/app/src/main/assets: config.json config_android.json $(shell find resource/) $(shell find src/shaders)
-mkdir -p $(ANDROID_BUILD_DIR)/app/src/main/assets
rsync -ar --relative config.json config_android.json resource src/shaders $(ANDROID_BUILD_DIR)/app/src/main/assets
# Add OpenCV libraries to the gradle project, then run gradle and generate an APK
$(ANDROID_BUILD_DIR)/app-debug.apk: $(ANDROID_BUILD_DIR) $(ANDROID_BUILD_DIR)/$(ANDROID_CLASS_DIR)/$(ANDROID_CLASS).java \
$(ANDROID_BUILD_DIR)/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml $(ANDROID_BUILD_DIR)/app/src/main/assets
ANDROID_SDK_ROOT=$(ANDROID_SDK) $(ANDROID_BUILD_DIR)/gradlew -p $(ANDROID_BUILD_DIR) build
ln -nsf app/build/outputs/apk/debug/app-debug.apk $(ANDROID_BUILD_DIR)
ln -nsf app/build/outputs/apk/debug/app-release-unsigned.apk $(ANDROID_BUILD_DIR)
#########################
# Clean up object files #
#########################
@ -142,6 +214,6 @@ clean-all : clean
# 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
PATH_TO_COMPILEDB = $(HOME)/ext/software/compiledb/bin/compiledb
compiledb :
-$(PATH_TO_COMPILEDB) -n make linux -k
-$(PATH_TO_COMPILEDB) -n make gunkiss -k

View File

@ -29,7 +29,7 @@
{
"screenshot-directory": "local/screenshots",
"video-directory": "local/video",
"enabled": false,
"enabled": true,
"write-mp4": true,
"video-frame-length": 33.333,
"max-video-memory": 2000,
@ -55,7 +55,7 @@
"scan":
{
"enabled": true,
"json-save": false,
"json-save": true,
"json-save-directory": "local/scans",
"barcode": "",
"capture-device": "/dev/video0",
@ -65,12 +65,13 @@
"sharpen": true,
"brighten": false,
"contour-color-decodable": [255, 255, 0],
"contour-color-undecodable": [255, 0, 255]
"contour-color-undecodable": [255, 0, 255],
"certificate-authorities-file": "resource/cacert.pem"
},
"api":
{
"user-agent": "Custom pudding creation game under development at https://mario.shampoo.ooo",
"user-agent": "Custom pudding creation game under development at https://shampoo.ooo",
"nutritionix-app-id": "ea0f2e7e",
"nutritionix-app-key": "39218dde526dd3349daa028deda518ae",
"edamam-app-id": "c23b139f",
@ -114,6 +115,23 @@
"arrow-button-location": [0.75, 0.0],
"arrow-button-scale": 0.3,
"arrow-button-label": "arrow",
"pop-up-viewport-height": 0.6
"pop-up-viewport-height": 1.0
},
"textures":
{
"tiles": [
"resource/tile/puddingtile.jpg",
"resource/tile/rat1tile.jpg",
"resource/tile/teapot.jpg",
"resource/tile/utensil1.jpg",
"resource/tile/vase.jpg"
],
"buttons": [
"resource/button/arrow.png",
"resource/button/home.png",
"resource/button/inventory.png",
"resource/button/scan.png"
]
}
}

21
config_android.json Normal file
View File

@ -0,0 +1,21 @@
{
"display":
{
"render driver": "opengles2"
},
"recording":
{
"enabled": false
},
"log":
{
"enabled": false
},
"scan":
{
"json-save": false
}
}

2
lib/sb

@ -1 +1 @@
Subproject commit a8126605e87903c598ee2781c4ce8395a9294e96
Subproject commit 8c086ba16178044ca61534ac2a0a4e5b68f54fee

3372
resource/cacert.pem Normal file

File diff suppressed because it is too large Load Diff

29
src/AndroidLibraries.mk Normal file
View File

@ -0,0 +1,29 @@
# Insert contents into the Android.mk file in jni/src folder for this SDL project after the CLEAR_VARS line.
# See main Makefile Android build target for the rule which includes these contents.
include $(CLEAR_VARS)
LOCAL_MODULE := tbb
LOCAL_SRC_FILES := opencv/$(TARGET_ARCH_ABI)/libtbb.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_world
LOCAL_SRC_FILES := opencv/$(TARGET_ARCH_ABI)/libopencv_world.so
LOCAL_EXPORT_C_INCLUDES := $(OPENCV_ANDROID_SDK)/sdk/native/jni/include
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := crypto
LOCAL_SRC_FILES := openssl/$(TARGET_ARCH_ABI)/lib/libcrypto.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ssl
LOCAL_SRC_FILES := openssl/$(TARGET_ARCH_ABI)/lib/libssl.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := curl
LOCAL_SRC_FILES := curl/$(TARGET_ARCH_ABI)/lib/libcurl.so
LOCAL_EXPORT_C_INCLUDES := $(CURL_ANDROID)/jni/curl/include
include $(PREBUILT_SHARED_LIBRARY)

View File

@ -13,6 +13,9 @@
/* including so we can use GLuint type */
#if defined(__EMSCRIPTEN__)
#include <GL/glew.h>
#elif defined(__ANDROID__) || defined(ANDROID)
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#else
#include "glew/glew.h"
#endif

View File

@ -12,17 +12,12 @@
to predict the stock market with supernatural accuracy.
*/
#include "Pudding.hpp"
/* Launch the Pudding instance's mainloop */
int main()
{
Pudding pudding = Pudding();
pudding.run();
pudding.quit();
return 0;
}
#if defined(__ANDROID__) || defined(ANDROID)
#include <android/asset_manager_jni.h>
#endif
#include "Pudding.hpp"
#ifdef __EMSCRIPTEN__
void flag_frame()
@ -39,6 +34,9 @@ void set_heap_offset(int offset)
/* Initialize a Pudding instance */
Pudding::Pudding()
{
/* Allocate storage for curl error string */
curl_error.resize(CURL_ERROR_SIZE);
#ifndef __EMSCRIPTEN__
/* Initialize cURL and store result. Initialize the multi request handler. */
curl_init_result = curl_global_init(CURL_GLOBAL_DEFAULT);
@ -54,14 +52,29 @@ Pudding::Pudding()
}
#endif
#if defined(__ANDROID__) || defined(ANDROID)
/* Copy CA bundle from the APK assets folder to internal storage. */
if (SDL_AndroidGetInternalStoragePath() != nullptr)
{
/* Copy the certificates into the internal storage. If successfully copied, save the path. */
if (!fs::exists(ca_bundle_path = sb::copy_file(configuration()["scan"]["certificate-authorities-file"], SDL_AndroidGetInternalStoragePath())))
{
sb::Log::log("Could not copy certificate authorities file, SSL peer verification will be disabled.");
}
}
else
{
sb::Log::sdl_error("Could not access Android internal storage, SSL peer verification will be disabled.");
}
SDL_SetHint(SDL_HINT_ORIENTATIONS, "Portrait");
#endif
/* subscribe to command events */
get_delegate().subscribe(&Pudding::respond, this);
get_delegate().subscribe(&Pudding::respond, this, SDL_MOUSEMOTION);
get_delegate().subscribe(&Pudding::respond, this, SDL_MOUSEBUTTONDOWN);
/* initialize a zbar image scanner for reading barcodes of any format */
image_scanner.set_config(zbar::ZBAR_NONE, zbar::ZBAR_CFG_ENABLE, 1);
/* set up pudding model */
nlohmann::json pudding = configuration()["pudding"];
load_pudding_model(pudding["top-radius"], pudding["base-radius"], pudding["ring-vertex-count"], pudding["layer-count"],
@ -72,9 +85,14 @@ Pudding::Pudding()
/* Add a texture to the camera Plane for storing frame image data */
camera_view.texture(sb::Texture());
glm::mat4 flip = glm::mat4(1);
flip[1][1] = -1;
camera_view.transformation(flip);
/* Flip and rotate the image */
glm::mat4 transform = glm::mat4(1);
transform[1][1] = -1;
#if defined(__ANDROID__) || defined(ANDROID)
transform = glm::rotate(3.0f * glm::half_pi<float>(), glm::vec3(0.0f, 0.0f, 1.0f)) * transform;
#endif
camera_view.transformation(transform);
/* Load background tiles */
load_tiles();
@ -267,7 +285,7 @@ void Pudding::load_gl_context()
/* Read every jpg in the folder at tile path into a GL texture and associate with the background object. */
void Pudding::load_tiles()
{
for (fs::path path : sb::glob(configuration()["resource"]["tile-path"].get<fs::path>() / ".*.jpg"))
for (fs::path path : configuration()["textures"]["tiles"])
{
sb::Texture texture {path};
texture.load();
@ -278,7 +296,7 @@ void Pudding::load_tiles()
/* Load every png in the button path as a Texture and add to a map. */
void Pudding::load_pads()
{
for (fs::path path : sb::glob(configuration()["resource"]["button-path"].get<fs::path>() / ".*.png"))
for (fs::path path : configuration()["textures"]["buttons"])
{
labels[path.stem()] = sb::Texture(path);
labels[path.stem()].load();
@ -327,8 +345,11 @@ void Pudding::open_camera()
}
}
/* Generate a texture the size of the camera's resolution. */
camera_view.texture().generate({capture.get(cv::CAP_PROP_FRAME_WIDTH), capture.get(cv::CAP_PROP_FRAME_HEIGHT)});
/* This is necessary for Android */
capture.set(cv::CAP_PROP_FOURCC, (('R' & 0x000000FF) | (('G' << 8) & 0x0000FF00) | (('B' << 16) & 0x00FF0000) | (('3' << 24) & 0xFF000000)));
/* Generate a texture the size of the camera's resolution. Using GL_RGB8 (instead of GL_RGBA8) seems to be necessary on Android. */
camera_view.texture().generate({capture.get(cv::CAP_PROP_FRAME_WIDTH), capture.get(cv::CAP_PROP_FRAME_HEIGHT)}, GL_RGB8);
/* Create and detach a thread which will read frame data */
std::thread camera_thread(&Pudding::capture_frame, this);
@ -873,6 +894,38 @@ void Pudding::web_get_bytes(std::string url, const web_callback& callback, const
}
curl_easy_setopt(curl_easy_handle, CURLOPT_HTTPHEADER, list);
/* Add error string buffer */
curl_easy_setopt(curl_easy_handle, CURLOPT_ERRORBUFFER, curl_error.data());
#if defined(__ANDROID__) || defined(ANDROID)
/* CA certificates bundle path must be specified in Android. */
CURLcode res;
bool success = false;
std::ostringstream message;
if (fs::exists(ca_bundle_path))
{
res = curl_easy_setopt(curl_easy_handle, CURLOPT_CAINFO, ca_bundle_path.c_str());
if (res == CURLE_OK)
{
message << "Set curl handle's CURLOPT_CAINFO to " << ca_bundle_path;
sb::Log::log(message);
success = true;
}
else
{
message << "Setting curl handle's CURLOPT_CAINFO failed " << curl_easy_strerror(res);
}
}
/* Fallback to turning off SSL peer verification if the certificates file isn't available. */
if (!success)
{
message << "Turning off SSL peer verification";
sb::Log::log(message, sb::Log::WARN);
curl_easy_setopt(curl_easy_handle, CURLOPT_SSL_VERIFYPEER, 0);
}
#endif
/* Add the easy handle to the multi handle, so it can be processed asynchronously in the update loop */
curl_multi_add_handle(curl_multi_handle.get(), curl_easy_handle);
}
@ -1113,6 +1166,9 @@ void Pudding::update()
/* Pixels from Emscripten are RGBA */
GLenum pixel_format = GL_RGBA;
#elif defined(__ANDROID__) || defined(ANDROID)
/* Pixels from cv::VideoCapture are RGB on Android */
GLenum pixel_format = GL_RGB;
#else
/* Pixels from cv::VideoCapture are BGR */
GLenum pixel_format = GL_BGR;
@ -1174,12 +1230,15 @@ void Pudding::update()
color_components = configuration()["scan"]["contour-color-undecodable"].get<std::vector<std::uint8_t>>();
}
cv::Scalar color = cv::Scalar(color_components[0], color_components[1], color_components[2], 255);
/* GL_BGR is not available on Android */
#if !defined(__ANDROID__) && !defined(ANDROID)
if (pixel_format == GL_BGR)
{
std::uint8_t save = color[0];
color[0] = color[2];
color[2] = save;
}
#endif
cv::drawContours(camera_frame, input, 0, color, 2);
for (const cv::Point& point : contours)
{
@ -1361,8 +1420,17 @@ void Pudding::update()
message_queue = curl_multi_info_read(curl_multi_handle.get(), &message_count);
if (message_queue && (message_queue->msg == CURLMSG_DONE))
{
std::uint32_t response_code;
Request* request;
curl_easy_getinfo(message_queue->easy_handle, CURLINFO_RESPONSE_CODE, &response_code);
curl_easy_getinfo(message_queue->easy_handle, CURLINFO_PRIVATE, &request);
std::ostringstream message;
message << request->url() << " returned HTTP response " << response_code;
if (response_code != 200)
{
message << ": " << curl_error;
}
sb::Log::log(message);
request->respond();
curl_multi_remove_handle(curl_multi_handle.get(), message_queue->easy_handle);
curl_easy_cleanup(message_queue->easy_handle);
@ -1411,6 +1479,9 @@ void Pudding::update()
camera_button.translation({-1.0f * interface["main-button-double-x"].get<float>(), interface["main-button-y"]});
}
incoming_item = Item();
/* Close camera view */
camera_switch.disconnect();
}
}
@ -1569,3 +1640,12 @@ EMSCRIPTEN_BINDINGS(my_module)
function("set_heap_offset", &set_heap_offset);
}
#endif
/* Launch the Pudding instance's mainloop */
int main()
{
Pudding pudding = Pudding();
pudding.run();
pudding.quit();
return 0;
}

View File

@ -25,6 +25,9 @@
#include <functional>
#include <chrono>
/* Include Game.hpp before any other SDL-related headers because it defines SDL_MAIN_HANDLED */
#include "Game.hpp"
/* cURL and cv::VideoCapture are not available for Emscripten, so use alternatives for Emscripten builds */
#if defined(__EMSCRIPTEN__)
#include <emscripten/fetch.h>
@ -36,17 +39,14 @@ using namespace emscripten;
#include "opencv2/highgui.hpp"
#endif
#include "SDL.h"
#include "SDL_image.h"
#include "sdl2-gfx/SDL2_gfxPrimitives.h"
#include "json/json.hpp"
#include "glm/glm.hpp"
#include "glm/gtx/matrix_decompose.hpp"
#include "glm/gtc/matrix_access.hpp"
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/barcode.hpp"
#include "zbar.h"
#include "Game.hpp"
#include "Color.hpp"
#include "extension.hpp"
#include "filesystem.hpp"
@ -317,7 +317,7 @@ private:
/* Member variables */
std::shared_ptr<SDL_Cursor> poke;
std::string current_barcode, previous_barcode, current_config_barcode;
std::string current_barcode, previous_barcode, current_config_barcode, curl_error;
std::vector<Item> items;
Item incoming_item;
sb::Carousel item_carousel;
@ -328,8 +328,7 @@ private:
nullptr, curl_multi_cleanup);
CURLcode curl_init_result;
#endif
cv::Mat camera_frame, contrasted_frame, sharpened_frame, zbar_frame, blurred, low_contrast_mask;
zbar::ImageScanner image_scanner;
cv::Mat camera_frame, contrasted_frame, sharpened_frame, blurred, low_contrast_mask;
std::map<std::string, std::map<std::string, GLuint>> uniform;
GLuint flat_program, mvp_program;
glm::mat4 projection, model {1.0f}, mvp;
@ -343,6 +342,7 @@ private:
Pad camera_button, previous_button, next_button, inventory_button;
Box viewport, main_viewport, pop_up_viewport;
std::vector<Request*> requests;
fs::path ca_bundle_path;
/* Storage for barcode scanning module */
cv::Ptr<cv::barcode::BarcodeDetector> barcode_detector = cv::makePtr<cv::barcode::BarcodeDetector>();
@ -513,4 +513,6 @@ private:
/* Allow a box object to be passed to glViewport instead of four vertices. */
void glViewport(Box);
int main();
#endif