diff --git a/Makefile b/Makefile index 213bfcda2957ccce7b0a6512fded9141edc9ff06..2d5a564050ff090c8e68257633c8fa5fb29a87bf 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ CPP_SOURCES = src/app.cpp src.cpp/context.cpp OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o))) vpath %.cpp $(sort $(dir $(CPP_SOURCES))) vpath %.cpp examples +vpath %.cpp assignment OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) vpath %.c $(sort $(dir $(C_SOURCES))) @@ -31,26 +32,35 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(ECHO) compiling $< clang -c $(CFLAGS) $< -o $@ -all: $(BUILD_DIR)/splat $(BUILD_DIR)/shapes $(BUILD_DIR)/sprite +all: $(BUILD_DIR)/splat $(BUILD_DIR)/shapes $(BUILD_DIR)/sprite $(BUILD_DIR)/assignment $(BUILD_DIR)/splat: $(OBJECTS) $(BUILD_DIR)/splat.o Makefile $(ECHO) linking $< $(CC) -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL -o $@ $(OBJECTS) build/splat.o # $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(BUILD_DIR)/splat.o + install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib ./osx/runtime/libSDL2-2.0.0.dylib $(BUILD_DIR)/splat $(ECHO) success $(BUILD_DIR)/shapes: $(OBJECTS) $(BUILD_DIR)/shapes.o Makefile $(ECHO) linking $< $(CC) -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL -o $@ $(OBJECTS) build/shapes.o + install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib ./osx/runtime/libSDL2-2.0.0.dylib $(BUILD_DIR)/shapes # $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(BUILD_DIR)/splat.o $(ECHO) success $(BUILD_DIR)/sprite: $(OBJECTS) $(BUILD_DIR)/sprite.o Makefile $(ECHO) linking $< $(CC) -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL -o $@ $(OBJECTS) build/sprite.o + install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib ./osx/runtime/libSDL2-2.0.0.dylib $(BUILD_DIR)/sprite # $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(BUILD_DIR)/splat.o $(ECHO) success +$(BUILD_DIR)/assignment: $(OBJECTS) $(BUILD_DIR)/assignment.o Makefile + $(ECHO) linking $< + $(CC) -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL -o $@ $(OBJECTS) build/assignment.o + install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib ./osx/runtime/libSDL2-2.0.0.dylib $(BUILD_DIR)/assignment + $(ECHO) success + ####################################### # clean up ####################################### @@ -62,5 +72,4 @@ clean: ####################################### -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - .PHONY: clean all \ No newline at end of file diff --git a/assignment/assignment.cpp b/assignment/assignment.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23e5607c2c9d61ddac0f637a94b584d4b30a553e --- /dev/null +++ b/assignment/assignment.cpp @@ -0,0 +1,75 @@ +#include <iostream> +#include <iomanip> +#include <vector> +#include <cstring> +#include <tuple> + +#include <context.hpp> +#include <app.hpp> + +using namespace std; + +const int width = 640; +const int height = 480; + +class MyApp: public uwe::App { +private: +public: + MyApp(int width, int height, std::string title); + ~MyApp(); + + void begin() override; + void update() override; + void draw() override; + + void key_pressed(uwe::Scancode scancode, bool repeat) override; + + void mouse_pressed(int x, int y, uwe::Button button) override; + void mouse_released(int x, int y, uwe::Button button) override; + void mouse_moved(int x, int y) override; +}; + +MyApp::MyApp(int width, int height, std::string title) { + init(width, height, title); +} + +MyApp::~MyApp() { + +} + +void MyApp::begin() { + +} + +void MyApp::update() { + +} + +void MyApp::key_pressed(uwe::Scancode scancode, bool repeat) { + switch (scancode) { + default: { + // nothing see here + } + } +} + +void MyApp::mouse_pressed(int x, int y, uwe::Button button) { +} + +void MyApp::mouse_released(int x, int y, uwe::Button button) { +} + +void MyApp::mouse_moved(int x, int y) { +} + +void MyApp::draw() { + clear(uwe::Colour::black()); +} + +int main(int argc, char *argv[]) { + uwe::App* app = new MyApp{width, height, "Assignment"}; + + app->run(); + + return 0; +} \ No newline at end of file