Add movement and fix some compile bugs
This commit is contained in:
parent
226333eaf7
commit
998d0e3e15
6 changed files with 24 additions and 47 deletions
|
@ -7,7 +7,6 @@ SRCDIR=src
|
|||
all:
|
||||
$(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/display.c
|
||||
$(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/input.c
|
||||
$(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/event_callbacks.c
|
||||
$(CC) $(CFLAGS) $(GTKLIBS) -c $(SRCDIR)/main.c
|
||||
|
||||
$(CC) $(CFLAGS) $(LINKER_FLAGS) $(GTKLIBS) -o ledcube-edit main.o display.o input.o
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkgl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "input.h"
|
||||
#include "display.h"
|
||||
|
||||
void on_main_window_delete_event(GtkObject *object, gpointer userData) {
|
||||
|
@ -46,7 +48,22 @@ void on_drawing_area_realize(GtkWidget *widget, gpointer data) {
|
|||
gdk_gl_drawable_gl_end(glDrawable);
|
||||
}
|
||||
|
||||
void on_drawing_area_key_press_event(GtkWidget *widget, gpointer data) {
|
||||
g_print("pressed");
|
||||
void on_drawing_area_key_press_event(GtkWidget *widget, GdkEventKey *event) {
|
||||
switch (event->keyval) {
|
||||
case GDK_KEY_Left:
|
||||
moveCameraPosition(MOVE_SPEED);
|
||||
break;
|
||||
case GDK_KEY_Right:
|
||||
moveCameraPosition(MOVE_SPEED*-1);
|
||||
break;
|
||||
case GDK_KEY_Up:
|
||||
moveCameraAngle(MOVE_SPEED);
|
||||
break;
|
||||
case GDK_KEY_Down:
|
||||
moveCameraAngle(MOVE_SPEED*-1);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw_area(widget, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,33 +23,6 @@ void moveCameraAngle(float angle) {
|
|||
if (eyeAngle < 0) eyeAngle = 0;
|
||||
}
|
||||
|
||||
|
||||
void keyboard(unsigned char key, int x, int y) {
|
||||
switch (key) {
|
||||
case 27: // ESC
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void keyboard_special(int key, int x, int y) {
|
||||
switch (key) {
|
||||
case GLUT_KEY_LEFT:
|
||||
moveCameraPosition(MOVE_SPEED);
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
moveCameraPosition(MOVE_SPEED*-1);
|
||||
break;
|
||||
case GLUT_KEY_UP:
|
||||
moveCameraAngle(MOVE_SPEED);
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
moveCameraAngle(MOVE_SPEED*-1);
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
void mouse(int button, int state, int x, int y) {
|
||||
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
|
||||
int position, viewport[4];
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
void moveCameraPosition(float direction);
|
||||
void moveCameraAngle(float angle);
|
||||
|
||||
void keyboard(unsigned char key, int x, int y);
|
||||
void keyboard_special(int key, int x, int y);
|
||||
|
||||
void mouse(int button, int state, int x, int y);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -66,13 +66,13 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
xml = glade_xml_new("src/main_gui.glade", NULL, NULL);
|
||||
glade_xml_signal_autoconnect(xml);
|
||||
|
||||
window = glade_xml_get_widget(xml, "main_window");
|
||||
gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), TRUE);
|
||||
drawingArea = glade_xml_get_widget(xml, "drawing_area");
|
||||
gtk_widget_set_gl_capability(drawingArea, glConfig, NULL, TRUE, GDK_GL_RGBA_TYPE);
|
||||
|
||||
glade_xml_signal_autoconnect(xml);
|
||||
|
||||
gtk_widget_show(window);
|
||||
gtk_main();
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="border_width">7</property>
|
||||
<child>
|
||||
<widget class="GtkComboBoxEntry" id="combobox_port">
|
||||
<widget class="GtkLabel" id="connection_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">LED Cube is not connected</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -32,18 +33,6 @@
|
|||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="button_connect">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Connect to cube</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-connect</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkSeparatorToolItem" id="saparator">
|
||||
<property name="visible">True</property>
|
||||
|
@ -100,6 +89,8 @@
|
|||
<property name="width_request">500</property>
|
||||
<property name="height_request">500</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="events">GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
|
||||
<signal name="expose_event" handler="on_drawing_area_expose_event"/>
|
||||
<signal name="key_press_event" handler="on_drawing_area_key_press_event"/>
|
||||
<signal name="realize" handler="on_drawing_area_realize" after="yes"/>
|
||||
|
|
Loading…
Reference in a new issue