Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AdamSimpson/PiBrot
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSimpson committed Aug 12, 2014
2 parents 69883de + 73bdc9a commit 02fefe4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
20 changes: 9 additions & 11 deletions egl_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -207,14 +208,14 @@ void handle_key(gl_t *state, struct input_event *event)
{
switch(event->code)
{
case KEY_ESC:
case KEY_TAB:
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;
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 1 addition & 2 deletions egl_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ THE SOFTWARE.

#include "bcm_host.h"
#include "renderer.h"
#include "controls.h"

typedef struct gl_t {
uint32_t screen_width;
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion rectangle_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions start_menu_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,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
Expand Down

0 comments on commit 02fefe4

Please sign in to comment.