Skip to content

Commit a7a6563

Browse files
cmaughansamaaron
authored andcommitted
Pi fixes
1 parent 711f76d commit a7a6563

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

app/cmake/config.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#cmakedefine APP_ROOT "${APP_ROOT}"
22
#cmakedefine QT_OLD_API ${QT_OLD_API}
3+
#cmakedefine RASPBERRY_PI ${RASPBERRY_PI}
34

app/gui/imgui/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ target_include_directories(${APP_NAME}
7272
${CMAKE_BINARY_DIR}
7373
)
7474

75+
# Extras for compiling on PI: Use ES2
76+
if (RASPBERRY_PI)
77+
target_compile_definitions(${APP_NAME} PRIVATE
78+
IMGUI_IMPL_OPENGL_ES2)
79+
80+
target_link_directories(${APP_NAME}
81+
PRIVATE
82+
/opt/vc/lib
83+
)
84+
endif()
85+
7586
target_link_libraries (${APP_NAME}
7687
PRIVATE
7788
SonicPi::API

app/gui/imgui/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ using namespace gl;
4040
#include <glbinding/gl/gl.h>
4141
using namespace gl;
4242
#else
43-
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
43+
#include <GLES2/gl2.h> // Use GL ES 3
44+
//#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
4445
#endif
4546

4647
namespace
@@ -81,9 +82,16 @@ int main(int, char**)
8182
// GL 3.0 + GLSL 130
8283
const char* glsl_version = "#version 130";
8384
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
85+
#ifdef RASPBERRY_PI
86+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
87+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
88+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
89+
#else
8490
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
8591
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
8692
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
93+
#endif
94+
8795
#endif
8896

8997
// Create window with graphics context
@@ -171,7 +179,7 @@ int main(int, char**)
171179

172180
// Setup Platform/Renderer backends
173181
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
174-
ImGui_ImplOpenGL3_Init(glsl_version);
182+
ImGui_ImplOpenGL3_Init();
175183

176184
// Load Fonts
177185
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.

app/pi-config.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -e # Quit script on error
3+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
config=""
5+
6+
if [ "$1" = "--config" ]; then
7+
case $2 in
8+
Release|Debug|RelWithDebInfo|MinSizeRel)
9+
config="$2"
10+
;;
11+
*)
12+
echo "`basename $0`: Error: invalid configuration: '${2}'" 1>&2
13+
echo "Valid configurations: Release, Debug, RelWithDebInfo, MinSizeRel" 1>&2
14+
exit 1
15+
;;
16+
esac
17+
elif [ ! -z $1 ]; then
18+
echo "`basename $0`: Error: invalid parameter: '${1}'" 1>&2
19+
echo "Usage: `basename $0` [--config <Release|Debug|RelWithDebInfo|MinSizeRel>]" 1>&2
20+
exit 1
21+
fi
22+
23+
echo "Creating build directory..."
24+
mkdir -p "${SCRIPT_DIR}/build"
25+
26+
echo "Generating makefiles..."
27+
cd "${SCRIPT_DIR}/build"
28+
cmake -G "Unix Makefiles" -DRASPBERRY_PI=1 -DCMAKE_BUILD_TYPE=\"$config\" ..
29+
30+
cd "${SCRIPT_DIR}"

app/raspbian-setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
sudo apt update
3+
sudo apt install snapd
4+
sudo snap install cmake --classic
5+
sudo apt remove cmake
6+
echo "Remember to reboot to get the new cmake!"

0 commit comments

Comments
 (0)