summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2019-01-29 16:49:35 +0100
committerGravatar jonas <himself@jonasgunz.de> 2019-01-29 16:49:35 +0100
commitcf5bf15232c19dda330f7ccab7737f828460f001 (patch)
tree08210c5391d78a98dfb3c9d59ad018ecd331414e
parentda2b8fc6673076d3fc600d275f5e5c8e95b54cac (diff)
downloadtermgl-cf5bf15232c19dda330f7ccab7737f828460f001.tar.gz
Makefile now creates dynamic library Package
main.cpp is now test.cpp and contains a test routine. Build with make test
-rw-r--r--.travis.yml2
-rw-r--r--Makefile33
-rw-r--r--Readme.md13
-rw-r--r--main.cpp256
-rw-r--r--test.cpp139
5 files changed, 177 insertions, 266 deletions
diff --git a/.travis.yml b/.travis.yml
index 338aebd..c51e18b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,2 +1,2 @@
language: cpp
-script: make
+script: make && make test
diff --git a/Makefile b/Makefile
index a91b1d8..ae3da54 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,25 @@
CC = /usr/bin/g++
-CFLAGS = -Wall -g -std=c++11
+CFLAGS = -Wall -std=c++11 -shared -fPIC
+DEBUGFLAGS = -Wall -g -std=c++11
LDFLAGS =
-OUTPUT = Engine
+SONAME = engine
BUILDDIR = build
#VERSION
VERSION = 0
PATCHLEVEL = 3
+OUTPUT = lib$(SONAME).so.$(VERSION).$(PATCHLEVEL)
-OBJ = main.o cObject.o cObjectHandler.o cRender.o cInput.o cWiremesh.o
+OBJ = cObject.o cObjectHandler.o cRender.o cInput.o cWiremesh.o
-debug: genversion $(OBJ)
+build: genversion $(OBJ)
mkdir -p $(BUILDDIR)
- $(CC) $(CFLAGS) -o $(BUILDDIR)/$(OUTPUT) $(OBJ) $(LDFLAGS)
+ mkdir -p $(BUILDDIR)/lib
+ mkdir -p $(BUILDDIR)/inc
+ $(CC) $(CFLAGS) -o $(BUILDDIR)/lib/$(OUTPUT) $(OBJ) $(LDFLAGS) -Wl,-soname=lib$(SONAME).so.$(VERSION)
+ ln -sf $(OUTPUT) $(BUILDDIR)/lib/lib$(SONAME).so.$(VERSION)
+ ln -sf $(OUTPUT) $(BUILDDIR)/lib/lib$(SONAME).so
+ cp c*.h $(BUILDDIR)/inc
+ cp version.h $(BUILDDIR)/inc
%.o: %.cpp
@echo
@@ -20,15 +28,17 @@ debug: genversion $(OBJ)
@echo
$(CC) $(CFLAGS) -c $<
-all: clean debug
+
+
+all: clean build
.PHONY: clean
clean:
- rm -df $(BUILDDIR)/$(OUTPUT) $(OBJ) version.h
+ rm -df $(OBJ) test.o version.h
+ rm -R $(BUILDDIR)
-run: debug
- ./$(BUILDDIR)/$(OUTPUT)
+run: test
genversion:
@echo Building Version
@@ -39,3 +49,8 @@ genversion:
@echo "#define BRANCH \"`git status -bs | grep '##'`\"" >> version.h
@echo "#define DATE \"`date +'%d.%m.20%y'`\"" >> version.h
@echo "#define TIME \"`date +'%H:%M:%S'`\"" >> version.h
+
+test: genversion test.o $(OBJ)
+ mkdir -p $(BUILDDIR)/test
+ $(CC) $(DEBUGFLAGS) -o $(BUILDDIR)/test/test test.o $(OBJ) $(LDFLAGS)
+ ./$(BUILDDIR)/test/test test
diff --git a/Readme.md b/Readme.md
index 46b5e0a..e20ef28 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1 +1,14 @@
[![Build Status](https://travis-ci.org/kompetenzbolzen/engine.svg?branch=master)](https://travis-ci.org/kompetenzbolzen/engine)
+
+# Compiling
+
+engine should compile just fine with just the c++ standard librarys.
+Required Packages:
+ g++
+ make
+
+this creates two folders in ./build/: lib and inc, wich hold the library and the headers respectively. these can then be copied into your projects directory.
+
+#Using
+Compile your program with linkerflags:
+ -L./lib -lengine -lstdc+
diff --git a/main.cpp b/main.cpp
deleted file mode 100644
index 4f440b6..0000000
--- a/main.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-#include <unistd.h>
-#include <string>
-
-#include "version.h"
-
-#include "cRender.h"
-#include "cObject.h"
-#include "cObjectHandler.h"
-#include "cInput.h"
-#include "cWiremesh.h"
-
-//#include "testobject.h"
-
-int main()
-{
- cRender render(' ', _COL_DEFAULT, 30,30);
- cObjectHandler handler(&render);
- cObject ver(45,1);
- cWiremesh obj;
-
- cInput input;
-
- render.render();
-
- /*int iobj = handler.createObject((cObject*)&obj);
- handler.moveObject(iobj, {40,10}, _MOVE_ABSOLUTE);*/
-
- ver.drawPoint('v', {0,0}, true, _COL_WHITE);
- ver.drawPoint(VERSION + 48, {1,0}, true, _COL_WHITE);
- ver.drawPoint('.', {2,0}, true, _COL_WHITE);
- ver.drawPoint(PATCHLEVEL + 48, {3,0}, true, _COL_WHITE);
- ver.drawText(DATE, {32,0}, _COL_WHITE);
- ver.drawText(BRANCH, {5,0}, _COL_WHITE);
- int iver = handler.createObject(&ver);
- handler.moveObject(iver, {0,0}, _MOVE_ABSOLUTE);
-
- int x = 30;
- int y = 30;
- int z = 30;
-
- obj.addVector({0,0,z}, {x,0,0}, '+', _COL_RED);
- obj.addVector({0,0,z}, {0,y,0}, '+', _COL_RED);
- obj.addVector({0,y,z}, {x,0,0}, '+', _COL_RED);
- obj.addVector({x,0,z}, {0,y,0}, '+', _COL_RED);
-
- obj.addVector({0,0,0}, {0,0,z}, ':', _COL_RED);
- obj.addVector({x,0,0}, {0,0,z}, ':', _COL_RED);
- obj.addVector({0,y,0}, {0,0,z}, ':', _COL_RED);
- obj.addVector({x,y,0}, {0,0,z}, ':', _COL_RED);
-
- obj.addVector({0,0,0}, {x,0,0}, ',', _COL_RED);
- obj.addVector({0,0,0}, {0,y,0}, ',', _COL_RED);
- obj.addVector({0,y,0}, {x,0,0}, ',', _COL_RED);
- obj.addVector({x,0,0}, {0,y,0}, ',', _COL_RED);
- int imesh = handler.createWiremesh(&obj);
-
- while(1)
- {
- sInputEvent ie = input.poll();
-
- if(ie.type != _EVENT_NULL)
- {
- if(ie.type == _EVENT_KEY)
- {
- switch (ie.c)
- {
- case 'A'://up
- handler.moveWiremesh(imesh,{0,-1,0}, _MOVE_RELATIVE);
- break;
- case 'B'://down
- handler.moveWiremesh(imesh,{0,1,0}, _MOVE_RELATIVE);
- break;
- case 'C'://right
- handler.moveWiremesh(imesh,{1,0,0}, _MOVE_RELATIVE);
- break;
- case 'D'://left
- handler.moveWiremesh(imesh,{-1,0,0}, _MOVE_RELATIVE);
- break;
- };
- }
- else if (ie.type == _EVENT_MOUSE)
- {
- if(ie.b == 0)
- handler.clickEvent({ie.x, ie.y}, 0);
- }
- else if (ie.type == _EVENT_CHAR)
- {
- //handler.charEvent(ie.c);
- switch(ie.c)
- {
- case 'w':
- handler.rotateWiremesh(imesh,{-10,0,0});
- break;
- case 's':
- handler.rotateWiremesh(imesh,{10,0,0});
- break;
- case 'a':
- handler.rotateWiremesh(imesh,{0,-10,0});
- break;
- case 'd':
- handler.rotateWiremesh(imesh,{0,10,0});
- break;
- case 'q':
- handler.rotateWiremesh(imesh,{0,0,-10});
- break;
- case 'e':
- handler.rotateWiremesh(imesh,{0,0,10});
- break;
- };
- }
- else if (ie.type == _EVENT_TERM)
- {
- return 0;
- }
-
- }
- handler.write();
- render.render();
-
- usleep(10*1000);
- }
-
-
- /*cRender a(' ', _COL_DEFAULT, 20,20);
- cInput in;
- a.render();
-
- sPos size = a.getSize();
- sPos pos = {size.x / 2, size.y / 2};
-
- while(1)
- {
- sInputEvent ie = in.poll();
- if(ie.type != _EVENT_NULL)
- {
- if(ie.type == _EVENT_KEY)
- {
- switch (ie.c)
- {
- case 'A':
- pos.y--;
- break;
- case 'B':
- pos.y++;
- break;
- case 'C':
- pos.x++;
- break;
- case 'D':
- pos.x--;
- break;
- };
- }
- else if (ie.type == _EVENT_MOUSE)
- {
- pos.x = ie.x;
- pos.y = ie.y;
- }
- else if (ie.type == _EVENT_TERM)
- {
- return 0;
- }
-
- a.clear();
- a.drawPoint('X', pos, true, _COL_GREEN);
- a.render();
-
- usleep(10*1000);
- }
- }*/
-
- /*unsigned long int framecounter = 0;
- cRender a(' ', _COL_DEFAULT, 10,10);
- a.render();
-
- sPos pos = {0,10};
- int dirX = 1;
- int dirY = -1;
-
- while(1)
- {
- pos.x += 2 * dirX;
- pos.y += 1 * dirY;
-
- if(pos.x >= a.getSize().x) {
- pos.x = a.getSize().x;
- dirX *= -1;
- }
- if(pos.x <= 0) {
- pos.x = 0;
- dirX *= -1;
- }
-
- if(pos.y >= a.getSize().y) {
- pos.y = a.getSize().y;
- dirY *= -1;
- }
- if(pos.y <= 0) {
- pos.y = 0;
- dirY *= -1;
- }
-
- a.clear();
- a.drawPoint('X', pos, true, _COL_GREEN);
- a.drawText(to_string(framecounter), {0,0}, _COL_RED);
- a.render();
-
- framecounter++;
- //cin.get();
- //usleep(100*1000);
- if(framecounter >= 1000)
- break;
- }*/
-
- /*cObjectHandler b(&a);
- cObject x(1,1);
-
- int i = b.createObject(&x);
- int dir1 = 1;
- int dir2 = -1;
- int cntr = 0;
-
- a.clear(true);
- b.moveObject(i, {0,30}, _MOVE_ABSOULUTE);
- x.drawPoint('X', {0,0}, true,_COL_GREEN);
-
- while(1)
- {
- b.moveObject(i, {2 * dir1, 1 * dir2}, _MOVE_RELATIVE);
-
- b.write();
- a.drawText(to_string(framecounter), {0,0}, _COL_RED);
- a.render();
-
- if(x.getPosition().x <= 0)
- dir1 *= -1;
- else if(x.getPosition().x >= a.getSize().x)
- {
- dir1 *= -1;
- x.setPosition({a.getSize().x, x.getPosition().y});
- }
-
- if(x.getPosition().y <= 0)
- dir2 *= -1;
- else if(x.getPosition().y >= a.getSize().y)
- {
- dir2 *= -1;
- x.setPosition({x.getPosition().x, a.getSize().y});
- }
-
- framecounter++;
- //cin.get();
- usleep(100*1000);
- }*/
- return 0;
-}
diff --git a/test.cpp b/test.cpp
new file mode 100644
index 0000000..0eada2d
--- /dev/null
+++ b/test.cpp
@@ -0,0 +1,139 @@
+#include <unistd.h>
+#include <string>
+
+#include "version.h"
+
+#include "cRender.h"
+#include "cObject.h"
+#include "cObjectHandler.h"
+#include "cInput.h"
+#include "cWiremesh.h"
+
+//#include "testobject.h"
+
+int main(int argc, char* argv[])
+{
+ cRender render(' ', _COL_DEFAULT, 30,30);
+ cObjectHandler handler(&render);
+ cObject ver(45,1);
+ cWiremesh obj;
+
+ cInput input;
+
+ unsigned int framecounter = 0;
+ bool loop = true;
+
+ if(argc > 1)
+ {
+ loop = false;
+ }
+
+ render.render();
+
+ ver.drawPoint('v', {0,0}, true, _COL_WHITE);
+ ver.drawPoint(VERSION + 48, {1,0}, true, _COL_WHITE);
+ ver.drawPoint('.', {2,0}, true, _COL_WHITE);
+ ver.drawPoint(PATCHLEVEL + 48, {3,0}, true, _COL_WHITE);
+ ver.drawText(DATE, {32,0}, _COL_WHITE);
+ ver.drawText(BRANCH, {5,0}, _COL_WHITE);
+ int iver = handler.createObject(&ver);
+ handler.moveObject(iver, {0,0}, _MOVE_ABSOLUTE);
+
+ int x = 15;
+ int y = 15;
+ int z = 30;
+
+ obj.addVector({-x,-y,z}, {2*x,0,0}, '+', _COL_RED);
+ obj.addVector({-x,-y,z}, {0,2*y,0}, '+', _COL_RED);
+ obj.addVector({-x,y,z}, {2*x,0,0}, '+', _COL_RED);
+ obj.addVector({x,-y,z}, {0,2*y,0}, '+', _COL_RED);
+
+ obj.addVector({-x,-y,0}, {0,0,z}, ':', _COL_RED);
+ obj.addVector({x,-y,0}, {0,0,z}, ':', _COL_RED);
+ obj.addVector({-x,y,0}, {0,0,z}, ':', _COL_RED);
+ obj.addVector({x,y,0}, {0,0,z}, ':', _COL_RED);
+
+ obj.addVector({-x,-y,0}, {2*x,0,0}, ',', _COL_RED);
+ obj.addVector({-x,-y,0}, {0,2*y,0}, ',', _COL_RED);
+ obj.addVector({-x,y,0}, {2*x,0,0}, ',', _COL_RED);
+ obj.addVector({x,-x,0}, {0,2*y,0}, ',', _COL_RED);
+ int imesh = handler.createWiremesh(&obj);
+
+ sPos middle = render.getSize();
+ middle.x /= 2;
+ middle.y /= 2;
+
+ handler.moveWiremesh(imesh,{middle.x,middle.y,0}, _MOVE_ABSOLUTE);
+
+ while( loop || framecounter < 1000)
+ {
+ sInputEvent ie = input.poll();
+
+ if(ie.type != _EVENT_NULL)
+ {
+ if(ie.type == _EVENT_KEY)
+ {
+ switch (ie.c)
+ {
+ case 'A'://up
+ handler.moveWiremesh(imesh,{0,-1,0}, _MOVE_RELATIVE);
+ break;
+ case 'B'://down
+ handler.moveWiremesh(imesh,{0,1,0}, _MOVE_RELATIVE);
+ break;
+ case 'C'://right
+ handler.moveWiremesh(imesh,{1,0,0}, _MOVE_RELATIVE);
+ break;
+ case 'D'://left
+ handler.moveWiremesh(imesh,{-1,0,0}, _MOVE_RELATIVE);
+ break;
+ };
+ }
+ else if (ie.type == _EVENT_MOUSE)
+ {
+ if(ie.b == 0)
+ handler.clickEvent({ie.x, ie.y}, 0);
+ }
+ else if (ie.type == _EVENT_CHAR)
+ {
+ //handler.charEvent(ie.c);
+ switch(ie.c)
+ {
+ case 'w':
+ handler.rotateWiremesh(imesh,{-10,0,0});
+ break;
+ case 's':
+ handler.rotateWiremesh(imesh,{10,0,0});
+ break;
+ case 'a':
+ handler.rotateWiremesh(imesh,{0,-10,0});
+ break;
+ case 'd':
+ handler.rotateWiremesh(imesh,{0,10,0});
+ break;
+ case 'q':
+ handler.rotateWiremesh(imesh,{0,0,-10});
+ break;
+ case 'e':
+ handler.rotateWiremesh(imesh,{0,0,10});
+ break;
+ };
+ }
+ else if (ie.type == _EVENT_TERM)
+ {
+ return 0;
+ }
+ }
+
+ handler.rotateWiremesh(imesh,{1,1,1});
+
+ handler.write();
+ render.render();
+ framecounter++;
+
+ if(loop)
+ usleep(10*1000);
+ }
+
+ return 0;
+}