# All of the sources participating in the build are defined here
-include sources.mk
+-include src/sdl/subdir.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
USER_OBJS :=
-LIBS :=
+LIBS := -lSDL
# Every subdirectory with source files must be described here
SUBDIRS := \
+src/sdl \
src \
--- /dev/null
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+CPP_SRCS += \
+../src/sdl/InitSDL.cpp \
+../src/sdl/InitScreen.cpp
+
+OBJS += \
+./src/sdl/InitSDL.o \
+./src/sdl/InitScreen.o
+
+CPP_DEPS += \
+./src/sdl/InitSDL.d \
+./src/sdl/InitScreen.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/sdl/%.o: ../src/sdl/%.cpp
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C++ Compiler'
+ g++ -I/usr/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
src/%.o: ../src/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
- g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ g++ -I/usr/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
# All of the sources participating in the build are defined here
-include sources.mk
+-include src/sdl/subdir.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
USER_OBJS :=
-LIBS :=
+LIBS := -lSDL
# Every subdirectory with source files must be described here
SUBDIRS := \
+src/sdl \
src \
--- /dev/null
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+CPP_SRCS += \
+../src/sdl/InitSDL.cpp \
+../src/sdl/InitScreen.cpp
+
+OBJS += \
+./src/sdl/InitSDL.o \
+./src/sdl/InitScreen.o
+
+CPP_DEPS += \
+./src/sdl/InitSDL.d \
+./src/sdl/InitScreen.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/sdl/%.o: ../src/sdl/%.cpp
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C++ Compiler'
+ g++ -I/usr/include/SDL -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
src/%.o: ../src/%.cpp
@echo 'Building file: $<'
@echo 'Invoking: GCC C++ Compiler'
- g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ g++ -I/usr/include/SDL -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '
* Author: holy
*/
+#include "sdl/InitScreen.h"
+#include "sdl/InitSDL.h"
+
+#include <exception>
+#include <iostream>
+
+using sdl::InitScreen;
+using sdl::InitSDL;
+
+using std::cerr;
+using std::cout;
+using std::endl;
+using std::exception;
+
int main(int argc, char **argv) {
- return 0;
+ const int width = 800;
+ const int height = 480;
+
+ try {
+ InitSDL sdl;
+ InitScreen screen(width, height);
+
+ return 0;
+ } catch (exception &e) {
+ cerr << "exception in main(): " << e.what() << endl;
+ return 1;
+ }
}
--- /dev/null
+/*
+ * InitSDL.cpp
+ *
+ * Created on: Apr 22, 2012
+ * Author: holy
+ */
+
+#include "InitSDL.h"
+
+#include <stdexcept>
+
+using std::runtime_error;
+
+
+namespace sdl {
+
+InitSDL::InitSDL(Uint32 flags) {
+ if (SDL_Init(flags) != 0) {
+ throw runtime_error("failed to initialize SDL");
+ }
+}
+
+InitSDL::~InitSDL(void) {
+ SDL_Quit();
+}
+
+}
--- /dev/null
+/*
+ * InitSDL.h
+ *
+ * Created on: Apr 22, 2012
+ * Author: holy
+ */
+
+#ifndef SDL_INITSDL_H_
+#define SDL_INITSDL_H_
+
+#include <SDL/SDL.h>
+
+
+namespace sdl {
+
+class InitSDL {
+
+public:
+ explicit InitSDL(Uint32 flags = SDL_INIT_EVERYTHING);
+ virtual ~InitSDL(void);
+private:
+ InitSDL(const InitSDL &);
+ InitSDL &operator =(const InitSDL &);
+
+};
+
+}
+
+#endif /* SDL_INITSDL_H_ */
--- /dev/null
+/*
+ * InitScreen.cpp
+ *
+ * Created on: Apr 22, 2012
+ * Author: holy
+ */
+
+#include "InitScreen.h"
+
+#include <stdexcept>
+
+using std::runtime_error;
+
+
+namespace sdl {
+
+InitScreen::InitScreen(int width, int height, int bpp, Sint32 flags)
+: screen(SDL_SetVideoMode(width, height, bpp, flags)) {
+ if (!screen) {
+ throw runtime_error("failed to open screen");
+ }
+}
+
+InitScreen::~InitScreen(void) {
+
+}
+
+}
--- /dev/null
+/*
+ * InitScreen.h
+ *
+ * Created on: Apr 22, 2012
+ * Author: holy
+ */
+
+#ifndef SDL_INITSCREEN_H_
+#define SDL_INITSCREEN_H_
+
+#include <SDL/SDL.h>
+
+namespace sdl {
+
+class InitScreen {
+
+public:
+ InitScreen(int width, int height, int bpp = 32, Sint32 flags = SDL_HWSURFACE | SDL_DOUBLEBUF);
+ virtual ~InitScreen(void);
+private:
+ InitScreen(const InitScreen &);
+ InitScreen &operator =(const InitScreen &);
+
+public:
+ SDL_Surface *Screen(void) { return screen; };
+ const SDL_Surface *Screen(void) const { return screen; };
+
+ void Flip(void) { SDL_Flip(screen); };
+
+private:
+ SDL_Surface *screen;
+
+};
+
+}
+
+#endif /* SDL_INITSCREEN_H_ */