From 97839753c5173869473dd2e3f3490a4219694d77 Mon Sep 17 00:00:00 2001 From: Adam Simpson Date: Thu, 22 May 2014 10:05:51 +0000 Subject: [PATCH 1/2] exit menu working on pi --- Makefile | 13 +++++++------ egl_utils.c | 20 +++++++++----------- egl_utils.h | 3 +-- rectangle_gl.c | 2 +- start_menu_gl.c | 4 ++-- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 3d23c17..945f5f6 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,24 @@ all: pibrot +PIS=pi2 pi3 pi4 pi5 pi6 pi7 pi8 pi9 pi1 LDFLAGS+=-L$(SDKSTAGE)/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lbcm_host -lvcos -lvchiq_arm -lpthread -lrt -L../libs/ilclient -L../libs/vgfont INCLUDES+=-I$(SDKSTAGE)/opt/vc/include/ -I$(SDKSTAGE)/opt/vc/include/interface/vcos/pthreads -I$(SDKSTAGE)/opt/vc/include/interface/vmcs_host/linux -I./ -I../libs/ilclient -I../libs/vgfont -CCFLAGS+= -mfloat-abi=hard -mfpu=vfp -ffast-math -O3 +CCFLAGS+= -DRASPI -mfloat-abi=hard -mfpu=vfp -ffast-math -O3 .PHONY: clean pibrot: pibrot.c communication.c egl_utils.c fractal.c multi_tex.c mkdir -p bin - mpicc -O3 $(CCFLAGS) $(INCLUDES) $(LDFLAGS) ogl_utils.c renderer.c communication.c egl_utils.c image_gl.c lodepng.c cursor_gl.c start_menu_gl.c exit_menu_gl.c fractal.c multi_tex.c -o bin/pibrot + mpicc -O3 $(CCFLAGS) $(INCLUDES) $(LDFLAGS) ogl_utils.c rectangle_gl.c renderer.c communication.c egl_utils.c image_gl.c lodepng.c cursor_gl.c start_menu_gl.c exit_menu_gl.c fractal.c multi_tex.c -o bin/pibrot run: copy cd $(HOME) && mpirun --host 192.168.3.100,192.168.3.101,192.168.3.102,192.168.3.103 -n 4 ./pibrot && cd PiBrot copy: - scp ./bin/pibrot pi0:~/ - scp ./bin/pibrot pi1:~/ - scp ./bin/pibrot pi2:~/ - scp ./bin/pibrot pi3:~/ + @for pi in $(PIS);\ + do \ + scp ./bin/pibrot $$pi:~/; \ + done clean: rm -rf *.o diff --git a/egl_utils.c b/egl_utils.c index 7721337..8e37d20 100644 --- a/egl_utils.c +++ b/egl_utils.c @@ -56,7 +56,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "egl_utils.h" #include "linux/input.h" #include "renderer.h" -#include "controls.h" +#include "exit_menu_gl.h" +#include "start_menu_gl.h" bool window_should_close(gl_t *state) { @@ -207,14 +208,14 @@ void handle_key(gl_t *state, struct input_event *event) { switch(event->code) { - case KEY_ESC: + case KEY_BACK: toggle_quit_mode(render_state); break; - case GLFW_KEY_A: + case KEY_A: if(!render_state->started) check_start_race(render_state); if(render_state->quit_mode) - check_exit_with_selected_program(render_state, window); + check_exit_with_selected_program(render_state, state); break; } } @@ -294,9 +295,6 @@ void process_controller_events(gl_t *state, int controller_fd) bytes = read(controller_fd, events, sizeof(events)); if(bytes > 0) { - // Let renderer know of activity - set_activity_time(render_state); - length = bytes/sizeof(struct input_event); // Process events based on type @@ -340,18 +338,18 @@ void pixel_to_gl(gl_t *state, int pixel_x, int pixel_y, float *gl_x, float *gl_y } // Exit and set return value for specific program if one selected -void check_exit_with_selected_program(render_t *render_state, GLFWwindow* window) +void check_exit_with_selected_program(render_t *render_state, gl_t *gl_state) { if(render_state->exit_menu_state->mandelbrot_state->selected) { - glfwSetWindowShouldClose(window, GL_TRUE); + gl_state->window_should_close = true; render_state->return_value = 10; } else if (render_state->exit_menu_state->sph_state->selected) { - glfwSetWindowShouldClose(window, GL_TRUE); + gl_state->window_should_close = true; render_state->return_value = 20; } else if (render_state->exit_menu_state->terminal_state->selected) { - glfwSetWindowShouldClose(window, GL_TRUE); + gl_state->window_should_close = true; render_state->return_value = 0; } } diff --git a/egl_utils.h b/egl_utils.h index a19f43e..6bbf55a 100644 --- a/egl_utils.h +++ b/egl_utils.h @@ -34,7 +34,6 @@ THE SOFTWARE. #include "bcm_host.h" #include "renderer.h" -#include "controls.h" typedef struct gl_t { uint32_t screen_width; @@ -68,7 +67,7 @@ void handle_mouse(gl_t *state, struct input_event *event); void handle_joystick(gl_t *state, struct input_event *event); bool window_should_close(gl_t *state); void pixel_to_gl(gl_t *state, int pixel_x, int pixel_y, float *gl_x, float *gl_y); -void check_exit_with_selected_program(render_t *render_state, GLFWwindow* window); +void check_exit_with_selected_program(render_t *render_state, gl_t *gl_state); void toggle_quit_mode(render_t *state); void check_start_race(render_t *render_state); diff --git a/rectangle_gl.c b/rectangle_gl.c index 1fb88ba..8ee199d 100644 --- a/rectangle_gl.c +++ b/rectangle_gl.c @@ -113,7 +113,7 @@ void create_rectangle_program(rectangle_t *state) // Compile frag shader GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); #ifdef RASPI - compile_shader(fragmentShader, "shaders/rectangle_es.frag"); + compile_shader(fragmentShader, "SPH/shaders/rectangle_es.frag"); #else compile_shader(fragmentShader, "shaders/rectangle.frag"); #endif diff --git a/start_menu_gl.c b/start_menu_gl.c index 82a48b9..7265bcd 100644 --- a/start_menu_gl.c +++ b/start_menu_gl.c @@ -37,8 +37,8 @@ void init_start_menu(start_menu_t *state, gl_t *gl_state) // Initialize cursor state->cursor_state = malloc(sizeof(cursor_t)); - int cursor_width = 30; - int cursor_height = 40; + int cursor_width = 120; + int cursor_height = 160; #ifdef RASPI init_cursor(state->cursor_state, gl_state, "PiBrot/images/cursor.png", cursor_width, cursor_height); #else From 73bdc9a47cdf3fdad7ee37780d0c3048bd296331 Mon Sep 17 00:00:00 2001 From: Adam Simpson Date: Thu, 22 May 2014 09:18:25 +0000 Subject: [PATCH 2/2] Fixing pi button --- egl_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egl_utils.c b/egl_utils.c index 8e37d20..d04c964 100644 --- a/egl_utils.c +++ b/egl_utils.c @@ -208,7 +208,7 @@ void handle_key(gl_t *state, struct input_event *event) { switch(event->code) { - case KEY_BACK: + case KEY_TAB: toggle_quit_mode(render_state); break; case KEY_A: