summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstefonzo <stevester.robinson@gmail.com>2022-02-06 20:47:58 -0600
committerstefonzo <stevester.robinson@gmail.com>2022-02-06 20:47:58 -0600
commit4ebd9b8cf553359ebef8c8f8b2128e7b120bb251 (patch)
treedb12692d5f36498e896c74d76323433ca28a69b3
initial commit
-rw-r--r--.gitignore3
-rw-r--r--Makefile7
-rw-r--r--main.cpp7
-rw-r--r--simple.cpp42
-rw-r--r--simple.hpp41
5 files changed, 100 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3d2846d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*~
+a.out
+simple_test
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0f9bb3c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,7 @@
+OBJS = main.cpp simple.cpp
+CC = g++
+COMPILER_FLAGS = -w -I/usr/local/include/SDL2/SDL_ttf.h
+LINKER_FLAGS = -lSDL2 -lSDL2_ttf -lSDL2_image
+OBJ_NAME = simple_test
+all: $(OBJS)
+ $(CC) $(OBJS) $(COMPILER_FLAGS) $(LINKER_FLAGS) -o $(OBJ_NAME)
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..3b2b2fa
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+using namespace std;
+
+int main() {
+ return 0;
+}
diff --git a/simple.cpp b/simple.cpp
new file mode 100644
index 0000000..5f5ab05
--- /dev/null
+++ b/simple.cpp
@@ -0,0 +1,42 @@
+#include "simple.hpp"
+namespace simple {
+ simple::simple() {
+ startSDL();
+ }
+ simple::~simple() {
+ closeSDL();
+ }
+ void simple::startSDL() {
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
+ printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
+ } else {
+ mainWindow = SDL_CreateWindow("tbd", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 500, 500, SDL_WINDOW_SHOWN);
+ if (mainWindow == NULL) {
+ printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
+ } else {
+ mainRenderer = SDL_CreateRenderer(mainWindow, -1, SDL_RENDERER_ACCELERATED);
+ if (mainRenderer == NULL) {
+ printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
+ } else {
+ SDL_SetRenderDrawColor(mainRenderer, 0, 0, 0, 0);
+ int imgFlags = IMG_INIT_PNG;
+ if (!(IMG_Init(imgFlags) & imgFlags)) {
+ printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
+ } else {
+ if (TTF_Init() == -1) {
+ printf("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError());
+ }
+ }
+ }
+ }
+ }
+ }
+ void simple::closeSDL() {
+ SDL_DestroyRenderer(mainRenderer);
+ SDL_DestroyWindow(mainWindow);
+ mainWindow = NULL;
+ TTF_Quit();
+ IMG_Quit();
+ SDL_Quit();
+ }
+}
diff --git a/simple.hpp b/simple.hpp
new file mode 100644
index 0000000..8c25770
--- /dev/null
+++ b/simple.hpp
@@ -0,0 +1,41 @@
+#ifndef SIMPLE_h
+#define SIMPLE_h
+#include <stdio.h>
+#include <SDL2/SDL.h>
+#include <SDL2/SDL_ttf.h>
+#include <SDL2/SDL_image.h>
+
+/*
+TODO:
+ -image loading
+ -texture quads
+ -ttf
+ -buttons/text input?
+ -timing
+ -events?
+*/
+
+namespace simple {
+ class simple {
+ private:
+ SDL_Renderer* mainRenderer;
+ SDL_Window* mainWindow;
+ public:
+ simple();
+ ~simple();
+ void startSDL();
+ void closeSDL();
+ };
+ //ttfs will be included in the texture class
+ class texture {
+ private:
+ int textureWidth;
+ int textureHeight;
+ int fontWidth;
+ int fontHeight;
+ public:
+ texture();
+ ~texture();
+ };
+}
+#endif