Browse Source

Namepsace in Dateien eingefuegt.

GL aus Rect/Color entfernt
Compiled als .so
Sebastian 11 years ago
parent
commit
45c8964c49
67 changed files with 591 additions and 356 deletions
  1. 1
    0
      .gitignore
  2. 28
    4
      Makefile
  3. 4
    0
      catmullromspline.cpp
  4. 2
    0
      catmullromspline.h
  5. 43
    0
      color.cpp
  6. 11
    7
      color.h
  7. 4
    0
      emath.cpp
  8. 4
    0
      emath.h
  9. 4
    0
      emath_opengl.cpp
  10. 5
    0
      emath_opengl.h
  11. 4
    0
      extstring.cpp
  12. 4
    0
      extstring.h
  13. 4
    0
      fpsmanager.cpp
  14. 4
    0
      fpsmanager.h
  15. 103
    0
      geotypes.cpp
  16. 70
    0
      geotypes.h
  17. 4
    0
      glcamera.cpp
  18. 4
    0
      glcamera.h
  19. 0
    39
      glcolor.cpp
  20. 6
    2
      gldrawhelper.cpp
  21. 5
    2
      gldrawhelper.h
  22. 4
    1
      glfontengine.cpp
  23. 6
    3
      glfontengine.h
  24. 6
    1
      glgui/button.cpp
  25. 5
    1
      glgui/button.h
  26. 6
    1
      glgui/textlabel.cpp
  27. 7
    3
      glgui/textlabel.h
  28. 7
    3
      glgui/window.cpp
  29. 6
    3
      glgui/window.h
  30. 5
    1
      glmenu/menuitem.cpp
  31. 4
    0
      glmenu/menuitem.h
  32. 4
    0
      glmenu/menuitems.cpp
  33. 4
    0
      glmenu/menuitems.h
  34. 4
    0
      glmenu/menumanager.cpp
  35. 3
    0
      glmenu/menumanager.h
  36. 4
    0
      glmenu/menumenu.cpp
  37. 4
    0
      glmenu/menumenu.h
  38. 0
    35
      glrect.cpp
  39. 4
    0
      glsdlscreen.cpp
  40. 4
    0
      glsdlscreen.h
  41. 5
    1
      gltexture.cpp
  42. 4
    0
      gltexture.h
  43. 0
    177
      main.cpp
  44. 4
    0
      matrix.cpp
  45. 3
    1
      matrix.h
  46. 4
    0
      model/loadobj.cpp
  47. 4
    0
      model/loadobj.h
  48. 6
    2
      model/model.cpp
  49. 8
    4
      model/model.h
  50. 4
    0
      model/modelloader.cpp
  51. 3
    0
      model/modelloader.h
  52. 16
    11
      punkt2d.cpp
  53. 10
    3
      punkt2d.h
  54. 24
    21
      punkt3d.cpp
  55. 14
    10
      punkt3d.h
  56. 4
    0
      quader.cpp
  57. 3
    0
      quader.h
  58. 4
    0
      quaternion.cpp
  59. 4
    0
      quaternion.h
  60. 40
    0
      rect.cpp
  61. 10
    6
      rect.h
  62. 4
    0
      rotationsmatrix.cpp
  63. 4
    0
      rotationsmatrix.h
  64. 4
    0
      sdlfuncs.cpp
  65. 4
    0
      sdlfuncs.h
  66. 0
    14
      testprog.cpp
  67. 0
    0
      testprog.h

+ 1
- 0
.gitignore View File

@@ -1,3 +1,4 @@
1 1
 *.o
2 2
 *.a
3
+libsegl.so.*
3 4
 testprog

+ 28
- 4
Makefile View File

@@ -1,18 +1,27 @@
1 1
 CC = g++
2 2
 AR = ar
3
-OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o glcolor.o gldrawhelper.o glfontengine.o glrect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o fpsmanager.o glcamera.o catmullromspline.o extstring.o quader.o
4
-OBJOPT = -Wall -c `sdl-config --cflags`
3
+OBJECTS = punkt3d.o punkt2d.o emath.o emath_opengl.o color.o gldrawhelper.o glfontengine.o rect.o gltexture.o matrix.o quaternion.o rotationsmatrix.o glsdlscreen.o sdlfuncs.o fpsmanager.o glcamera.o catmullromspline.o extstring.o quader.o
4
+OBJOPT = -Wall -c -DVERSION=$(VERSION) -O2 `sdl-config --cflags`
5
+WINOPT = -Wall -c -DVERSION=$(VERSION) -O2 -I/usr/i586-mingw32msvc/include -I/usr/i586-mingw32msvc/include/SDL
6
+LIBLINK = -lc -shared -Wl,-soname,$(LIBNAME).so.$(LIBVERSION)
7
+WINLINK = -L/usr/i586-mingw32msvc/lib /usr/i586-mingw32msvc/lib/SDL_image.lib -lmingw32 -shared -mwindows -lGL -lGLU -lSDL -lSDL_image /usr/i586-mingw32msvc/lib/SDL_image.lib /usr/i586-mingw32msvc/lib/SDL_image.dll
5 8
 SUBDIRS = glgui glmenu model
6 9
 SUBDIROBJECTS = glgui/*.o glmenu/*.o model/*.o
7
-VERSION = 0.0.1
10
+VERSION = 0.1.1
11
+LIBVERSION = 1
8 12
 LIBNAME = libsegl
13
+EXT = so.$(LIBVERSION)
14
+
15
+.PHONY: windows
9 16
 
10 17
 seglar: $(OBJECTS) subdirs
11 18
 	rm -f $(LIBNAME).a
12 19
 	$(AR) rcs $(LIBNAME).a $(OBJECTS) $(SUBDIROBJECTS)
13 20
 # 	ranlib $(LIBNAME).a
14 21
 
15
-segllib: $(OBJECTS) subdirs
22
+lib: LINKER = $(LINKER)
23
+lib: $(OBJECTS) subdirs
24
+	$(CC) -o $(LIBNAME).$(EXT) $(OBJECTS) $(SUBDIROBJECTS) $(LIBLINK)
16 25
 
17 26
 subdirs:
18 27
 	@for i in $(SUBDIRS); do $(MAKE) CC="$(CC)" AR="$(AR)" OBJOPT="$(OBJOPT)" -C  $$i; done
@@ -30,6 +39,21 @@ glmenu/glmenu.a:
30 39
 testprog: seglar testprog.o
31 40
 	g++ `sdl-config --libs` -lSDL_image -lGL -lGLU testprog.o -o testprog $(LIBNAME).a 
32 41
 
42
+winlib: CC = i586-mingw32msvc-g++
43
+winlib: AR = i586-mingw32msvc-ar
44
+winlib: OBJOPT = $(WINOPT)
45
+winlib: LIBLINK = $(WINLINK)
46
+winlib: export EXT = dll
47
+winlib: lib
48
+
49
+winar: CC = i586-mingw32msvc-g++
50
+winar: AR = i586-mingw32msvc-ar
51
+winar: OBJOPT = $(WINOPT)
52
+winar: LIBLINK = $(WINLINK)
53
+winar: export EXT = dll
54
+winar: seglar
55
+
56
+
33 57
 cleansubdirs:
34 58
 	@for i in $(SUBDIRS); do $(MAKE) clean -C  $$i; done
35 59
 

+ 4
- 0
catmullromspline.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "catmullromspline.h"
2 2
 
3
+namespace segl {
4
+
3 5
 CatmullRomSpline::CatmullRomSpline(float _s) {
4 6
 	cr = new Matrix(4, 4);
5 7
 	setS(_s);
@@ -99,3 +101,5 @@ void CatmullRomSpline::setS(float _s) {
99 101
 CatmullRomSpline::~CatmullRomSpline() {
100 102
 	delete(cr);
101 103
 }
104
+
105
+} // namespace segl

+ 2
- 0
catmullromspline.h View File

@@ -8,6 +8,7 @@
8 8
 #include "punkt2d.h"
9 9
 #include "punkt3d.h"
10 10
 
11
+namespace segl {
11 12
 
12 13
 class CatmullRomSpline {
13 14
 	private:
@@ -27,5 +28,6 @@ class CatmullRomSpline {
27 28
 		~CatmullRomSpline();
28 29
 };
29 30
 
31
+} // namespace segl
30 32
 
31 33
 #endif

+ 43
- 0
color.cpp View File

@@ -0,0 +1,43 @@
1
+#include "color.h"
2
+
3
+namespace segl {
4
+
5
+Color::Color() {
6
+	set(0.0f, 0.0f, 0.0f, 1.0f);
7
+	setalpha = true;
8
+}
9
+
10
+Color::Color(float _r, float _g, float _b, float _a) {
11
+	set(_r, _g, _b, _a);
12
+}
13
+
14
+Color::Color(const SDL_Color &c) {
15
+	set(c.r/255.0f, c.g/255.0f, c.b/255.0f);
16
+	setalpha = true;
17
+}
18
+
19
+void Color::set(float _r, float _g, float _b, float _a) {
20
+	r = _r;
21
+	g = _g;
22
+	b = _b;
23
+	a = _a;
24
+}
25
+
26
+SDL_Color Color::getSDLColor() {
27
+	SDL_Color c = {(Uint8)(r*255.0f), (Uint8)(g*255.0f), (Uint8)(b*255.0f), (Uint8)(a*255.0f)};
28
+	return c;
29
+}
30
+
31
+void Color::print(std::string m) {
32
+	std::cout << m << " Color: " << r << ", " << g << ", " << b << std::endl;
33
+}
34
+
35
+} // namespace segl
36
+
37
+void glColorGLC(segl::Color c) {
38
+	if(c.setalpha) {
39
+		glColor4f(c.r, c.g, c.b, c.a);
40
+	} else {
41
+		glColor3f(c.r, c.g, c.b);
42
+	}	
43
+}

glcolor.h → color.h View File

@@ -1,27 +1,31 @@
1
-#ifndef __GLCOLOR_H
2
-#define __GLCOLOR_H
1
+#ifndef __COLOR_H
2
+#define __COLOR_H
3 3
 
4 4
 #include <SDL.h>
5 5
 #include <SDL_opengl.h>
6 6
 #include <iostream>
7 7
 #include <string>
8 8
 
9
-class GLColor {
9
+namespace segl {
10
+
11
+class Color {
10 12
 	public:
11 13
 		float r, g, b, a;
12 14
 		bool setalpha;
13 15
 		
14 16
 		
15
-		GLColor();
16
-		GLColor(float _r, float _g, float _b, float _a=1.0f);
17
-		GLColor(const SDL_Color&);
17
+		Color();
18
+		Color(float _r, float _g, float _b, float _a=1.0f);
19
+		Color(const SDL_Color&);
18 20
 		
19 21
 		void set(float _r, float _g, float _b, float _a=1.0f);
20 22
 		SDL_Color getSDLColor();
21 23
 		void print(std::string m="");
22 24
 };
23 25
 
24
-void glColorGLC(GLColor c);
26
+} // namespace segl
27
+
28
+void glColorGLC(segl::Color c);
25 29
 // a) setalpha entscheiden lassen
26 30
 // b) zwei funktionen, eine setzt alpha mit in richtung 3f, 4f..
27 31
 

+ 4
- 0
emath.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "emath.h"
2 2
 
3
+namespace segl {
4
+
3 5
 // Trigonometrische Funktionen
4 6
 
5 7
 float deg2rad(float deg) {
@@ -34,3 +36,5 @@ float ssin(float c) {
34 36
 float scos(float c) {
35 37
 	return ssin(c+90.0f);
36 38
 }
39
+
40
+} // namespace segl

+ 4
- 0
emath.h View File

@@ -5,6 +5,7 @@
5 5
 #include <cmath>
6 6
 #include <SDL_opengl.h>
7 7
 
8
+namespace segl {
8 9
 
9 10
 float deg2rad(float deg);
10 11
 float rad2deg(float rad);
@@ -15,4 +16,7 @@ float rad2deg(float rad);
15 16
 float ssin(float);
16 17
 float scos(float);
17 18
 
19
+} // namespace segl
20
+
21
+
18 22
 #endif

+ 4
- 0
emath_opengl.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "emath_opengl.h"
2 2
 
3
+namespace segl {
4
+
3 5
 void rotFrom2VecTo2Vec(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d, Punkt3D *rvec, float *rvecdeg, Punkt3D *rvec2, float *rvecdeg2) {
4 6
 	Punkt3D rotvec, rotvec2, nullvec;
5 7
 	float rotvecdeg = 0.0f, rotvecdeg2 = 0.0f;
@@ -71,3 +73,5 @@ void rotvec2(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d, float *dega, Punkt3D *v
71 73
 	else
72 74
 		*vecb = c.kreuzprodukt(d);
73 75
 }
76
+
77
+} // namespace segl

+ 5
- 0
emath_opengl.h View File

@@ -7,7 +7,12 @@
7 7
 #include "rotationsmatrix.h"
8 8
 #include <SDL_opengl.h>
9 9
 
10
+namespace segl {
11
+
10 12
 void rotFrom2VecTo2Vec(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d, Punkt3D *, float *, Punkt3D *, float *);
11 13
 void rotFrom2VecTo2Vec(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d);
12 14
 void rotvec2(Punkt3D a, Punkt3D b, Punkt3D c, Punkt3D d, float *dega, Punkt3D *veca, float *degb, Punkt3D *vecb);
15
+
16
+} // namespace segl
17
+
13 18
 #endif

+ 4
- 0
extstring.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "extstring.h"
2 2
 
3
+namespace segl {
4
+
3 5
 int explode(std::string str, std::string delim, std::vector<std::string> *erg, bool clean) {
4 6
 	erg->clear();
5 7
 	
@@ -45,3 +47,5 @@ std::string basename(std::string str) {
45 47
 std::string rbasename(std::string str) {
46 48
 	return str.substr(0, str.rfind("/")+1);
47 49
 }
50
+
51
+} // namespace segl

+ 4
- 0
extstring.h View File

@@ -4,9 +4,13 @@
4 4
 #include <string>
5 5
 #include <vector>
6 6
 
7
+namespace segl {
8
+
7 9
 int explode(std::string str, std::string delim, std::vector<std::string> *erg, bool clean=false);
8 10
 std::string trim(std::string t);
9 11
 std::string basename(std::string str);
10 12
 std::string rbasename(std::string str);
11 13
 
14
+} // namespace segl
15
+
12 16
 #endif

+ 4
- 0
fpsmanager.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "fpsmanager.h"
2 2
 
3
+namespace segl {
4
+
3 5
 FPSManager::FPSManager(int _fps) {
4 6
 	setFPS(_fps);
5 7
 	frames = 0;
@@ -31,3 +33,5 @@ void FPSManager::delay() {
31 33
 float FPSManager::getFPS() {
32 34
 	return framerate;
33 35
 }
36
+
37
+} // namespace segl

+ 4
- 0
fpsmanager.h View File

@@ -3,6 +3,8 @@
3 3
 
4 4
 #include <SDL.h>
5 5
 
6
+namespace segl {
7
+
6 8
 class FPSManager {
7 9
 	private:
8 10
 		Uint32 lastticks;
@@ -17,4 +19,6 @@ class FPSManager {
17 19
 		float getFPS();
18 20
 };
19 21
 
22
+} // namespace segl
23
+
20 24
 #endif

+ 103
- 0
geotypes.cpp View File

@@ -0,0 +1,103 @@
1
+#include "geotypes.h"
2
+
3
+namespace segl {
4
+
5
+Sphere::Sphere(Punkt3D _pos, float _radius) {
6
+	pos = _pos;
7
+	radius = _radius;
8
+}
9
+
10
+Sphere::Sphere() {
11
+	radius = 1.0f;
12
+}
13
+
14
+bool Sphere::collision(const Sphere &s) {
15
+
16
+}
17
+
18
+bool Sphere::collision(const Ray &r) {
19
+
20
+}
21
+
22
+bool Sphere::collision(const Box & b) {
23
+
24
+}
25
+
26
+bool Sphere::collision(const Plane &p) {
27
+
28
+}
29
+
30
+Ray::Ray() {
31
+	dir.set(0.0f, 1.0f, 0.0f);
32
+}
33
+
34
+Ray::Ray(Punkt3D _pos, Punkt3D _dir) {
35
+	pos = _pos;
36
+	dir = _dir;
37
+}
38
+
39
+bool Ray::collision(const Sphere &s) {
40
+	return s.collision(*this);
41
+}
42
+
43
+bool Ray::collision(const Ray &r);
44
+bool Ray::collision(const Box & b);
45
+bool Ray::collision(const Plane &p);
46
+
47
+Box::Box() {
48
+	max.set(1.0f, 1.0f, 1.0f);
49
+}
50
+
51
+Box::Box(Punkt3D _min, Punkt3D _max) {
52
+	min = _min;
53
+	max = _max;
54
+}
55
+
56
+bool Box::collision(const Sphere &s) {
57
+	return s.collision(*this);
58
+}
59
+
60
+bool Box::collision(const Ray &r) {
61
+	return r.collision(*this);
62
+}
63
+
64
+bool Box::collision(const Box & b) {
65
+
66
+}
67
+
68
+bool Box::collision(const Plane &p) {
69
+
70
+}
71
+
72
+Plane::Plane() {
73
+	norm.set(0.0f, 1.0f, 0.0f);
74
+}
75
+
76
+Plane::Plane(Punkt3D _pos, Punkt3D _norm) {
77
+	pos = _pos;
78
+	norm = _norm;
79
+}
80
+
81
+Plane::Plane(float x, float y, float z, float a) {
82
+	// TODO: Implementation (if not too lazy)
83
+	norm.set(x, y, z);
84
+	norm.normalize();
85
+}
86
+
87
+bool Plane::collision(const Sphere &s) {
88
+	return s.collision(*this);
89
+}
90
+
91
+bool Plane::collision(const Ray &r) {
92
+	return r.collision(*this);
93
+}
94
+
95
+bool Plane::collision(const Box & b) {
96
+	return b.collision(*this);
97
+}
98
+
99
+bool Plane::collision(const Plane &p) {
100
+
101
+}
102
+
103
+} // namespace segl

+ 70
- 0
geotypes.h View File

@@ -0,0 +1,70 @@
1
+#ifndef __GEOTYPES_H
2
+#define __GEOTYPES_H
3
+
4
+#include "punkt3d.h"
5
+
6
+namespace segl {
7
+
8
+class Ray;
9
+class Box
10
+class Plane;
11
+
12
+
13
+class Sphere {
14
+	public:
15
+		Punkt3D pos;
16
+		float radius;
17
+		
18
+		Sphere(Punkt3D _pos, float radius);
19
+		Sphere();
20
+		
21
+		bool collision(const Sphere &s);
22
+		bool collision(const Ray &r);
23
+		bool collision(const Box & b);
24
+		bool collision(const Plane &p);
25
+};
26
+
27
+class Ray {
28
+	public:
29
+		Punkt3D pos;
30
+		Punkt3D dir;
31
+		
32
+		Ray();
33
+		Ray(Punkt3D _pos, Punkt3D _dir);
34
+		
35
+		bool collision(const Sphere &s);
36
+		bool collision(const Ray &r);
37
+		bool collision(const Box & b);
38
+		bool collision(const Plane &p);
39
+};
40
+
41
+class Box {
42
+	public:
43
+		Punkt3D min;
44
+		Punkt3D max;
45
+		
46
+		Box();
47
+		Box(Punkt3D _min, Punkt3D _max);
48
+		
49
+		bool collision(const Sphere &s);
50
+		bool collision(const Ray &r);
51
+		bool collision(const Box & b);
52
+		bool collision(const Plane &p);
53
+};
54
+
55
+class Plane {
56
+	public:
57
+		Punkt3D pos;
58
+		Punkt3D norm;
59
+		
60
+		Plane();
61
+		Plane(Punkt3D _pos, Punkt3D _norm);
62
+		Plane(float x, float y, float z, float a);
63
+		
64
+		bool collision(const Sphere &s);
65
+		bool collision(const Ray &r);
66
+		bool collision(const Box & b);
67
+		bool collision(const Plane &p);
68
+};
69
+
70
+} // namespace segl

+ 4
- 0
glcamera.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "glcamera.h"
2 2
 
3
+namespace segl {
4
+
3 5
 GLCamera::GLCamera() {
4 6
 	std_norm.set(0.0f, 1.0f, 0.0f);
5 7
 	std_dir.set(0.0f, 0.0f, -1.0f);
@@ -182,3 +184,5 @@ Punkt3D GLCamera::getPos() {
182 184
 GLCamera::~GLCamera() {
183 185
 	
184 186
 }
187
+
188
+} // namespace segl

+ 4
- 0
glcamera.h View File

@@ -8,6 +8,8 @@
8 8
 #include "emath_opengl.h"
9 9
 #include "punkt3d.h"
10 10
 
11
+namespace segl {
12
+
11 13
 class GLCamera {
12 14
 	private:
13 15
 		Punkt3D std_dir;
@@ -57,4 +59,6 @@ class GLCamera {
57 59
 		~GLCamera();
58 60
 };
59 61
 
62
+} // namespace segl {
63
+
60 64
 #endif

+ 0
- 39
glcolor.cpp View File

@@ -1,39 +0,0 @@
1
-#include "glcolor.h"
2
-
3
-GLColor::GLColor() {
4
-	set(0.0f, 0.0f, 0.0f, 1.0f);
5
-	setalpha = true;
6
-}
7
-
8
-GLColor::GLColor(float _r, float _g, float _b, float _a) {
9
-	set(_r, _g, _b, _a);
10
-}
11
-
12
-GLColor::GLColor(const SDL_Color &c) {
13
-	set(c.r/255.0f, c.g/255.0f, c.b/255.0f);
14
-	setalpha = true;
15
-}
16
-
17
-void GLColor::set(float _r, float _g, float _b, float _a) {
18
-	r = _r;
19
-	g = _g;
20
-	b = _b;
21
-	a = _a;
22
-}
23
-
24
-SDL_Color GLColor::getSDLColor() {
25
-	SDL_Color c = {(Uint8)(r*255.0f), (Uint8)(g*255), (Uint8)(b*255), (Uint8)(a*255)};
26
-	return c;
27
-}
28
-
29
-void GLColor::print(std::string m) {
30
-	std::cout << m << " Color: " << r << ", " << g << ", " << b << std::endl;
31
-}
32
-
33
-void glColorGLC(GLColor c) {
34
-	if(c.setalpha) {
35
-		glColor4f(c.r, c.g, c.b, c.a);
36
-	} else {
37
-		glColor3f(c.r, c.g, c.b);
38
-	}	
39
-}

+ 6
- 2
gldrawhelper.cpp View File

@@ -1,7 +1,9 @@
1 1
 #include "gldrawhelper.h"
2 2
 
3
-void GLDrawSDLRect(SDL_Rect *rect, GLRect *tex) {
4
-	GLRect tmptex;
3
+namespace segl {
4
+
5
+void GLDrawSDLRect(SDL_Rect *rect, Rect *tex) {
6
+	Rect tmptex;
5 7
 	if(tex) {
6 8
 		tmptex = *tex;
7 9
 	} else {
@@ -22,3 +24,5 @@ void GLDrawSDLRect(SDL_Rect *rect, GLRect *tex) {
22 24
 		glVertex2i(rect->x, rect->y);
23 25
 	glEnd();
24 26
 }
27
+
28
+} // namespace segl

+ 5
- 2
gldrawhelper.h View File

@@ -4,9 +4,12 @@
4 4
 #include <SDL.h>
5 5
 #include <SDL_opengl.h>
6 6
 
7
-#include "glrect.h"
7
+#include "rect.h"
8 8
 
9
-void GLDrawSDLRect(SDL_Rect *rect, GLRect *tex=0);
9
+namespace segl {
10 10
 
11
+void GLDrawSDLRect(SDL_Rect *rect, Rect *tex=0);
12
+
13
+} // namespace segl
11 14
 
12 15
 #endif

+ 4
- 1
glfontengine.cpp View File

@@ -1,5 +1,6 @@
1 1
 #include "glfontengine.h"
2 2
 
3
+namespace segl {
3 4
 
4 5
 bool GLFontEngine::addFont(std::string fontfile, std::string fontname) {
5 6
 	GLFont *tmp = new GLFont(fontfile, 0.685f);
@@ -80,7 +81,7 @@ void GLFontEngine::setColor(float _r, float _g, float _b, float _a) {
80 81
 	col.set(_r, _g, _b, _a);
81 82
 }
82 83
 
83
-void GLFontEngine::setColor(GLColor c) {
84
+void GLFontEngine::setColor(Color c) {
84 85
 	col = c;
85 86
 }
86 87
 
@@ -247,3 +248,5 @@ int GLFontEngine::getTextWidthbyInt(int length) {
247 248
 }
248 249
 
249 250
 std::map<std::string, GLFont*> GLFontEngine::fontpool;
251
+
252
+} // namespace segl

+ 6
- 3
glfontengine.h View File

@@ -11,7 +11,9 @@
11 11
 #include <SDL.h>
12 12
 #include <SDL_opengl.h>
13 13
 #include "gltexture.h"
14
-#include "glcolor.h"
14
+#include "color.h"
15
+
16
+namespace segl {
15 17
 
16 18
 class GLFont {
17 19
 	public:
@@ -32,7 +34,7 @@ class GLFontEngine {
32 34
 		
33 35
 		GLFont *font;
34 36
 		bool fontloaded;
35
-		GLColor col;
37
+		Color col;
36 38
 // 		float r, g, b, a;
37 39
 		int fsize;
38 40
 		
@@ -49,7 +51,7 @@ class GLFontEngine {
49 51
 		GLFontEngine(std::string);
50 52
 		bool fontSelect(std::string);
51 53
 		void setColor(float, float, float, float=1.0f);
52
-		void setColor(GLColor);
54
+		void setColor(Color);
53 55
 		
54 56
 		void renderText(std::string, SDL_Rect); // wrapper
55 57
 // 		void renderText(std::string, int x, int y, *SDL_Rect=0, bool center=false);
@@ -67,5 +69,6 @@ class GLFontEngine {
67 69
 		
68 70
 };
69 71
 
72
+} // namespace segl
70 73
 
71 74
 #endif

+ 6
- 1
glgui/button.cpp View File

@@ -1,11 +1,14 @@
1 1
 #include "button.h"
2 2
 
3
+namespace segl {
4
+
3 5
 GLGuiButton::GLGuiButton(int _eventid, int _x, int _y, bool _center, int _wrap) : GLGuiTextLabel(_x, _y, _center, _wrap) {
4 6
 	highlightable = true;
5 7
 	clickable = true;
6 8
 	eventid = _eventid;
7 9
 	highlightcol.set(1.0f, 0.0f, 0.0f, 1.0f);
8 10
 }
11
+
9 12
 GLGuiButton::GLGuiButton(int _eventid, std::string str, int _x, int _y, bool _center, int _wrap) : GLGuiTextLabel(str, _x, _y, _center, _wrap){
10 13
 	highlightable = true;
11 14
 	clickable = true;
@@ -14,7 +17,7 @@ GLGuiButton::GLGuiButton(int _eventid, std::string str, int _x, int _y, bool _ce
14 17
 }
15 18
 
16 19
 void GLGuiButton::onMouseOver(int m_x, int m_y) {
17
-	// Längste stelle finden, dann collision
20
+	// L�ngste stelle finden, dann collision
18 21
 }
19 22
 
20 23
 void GLGuiButton::onMouseClick(int m_x, int m_y, int m_button) {
@@ -23,3 +26,5 @@ void GLGuiButton::onMouseClick(int m_x, int m_y, int m_button) {
23 26
 	e.user.code = eventid;
24 27
 	SDL_PushEvent(&e);
25 28
 }
29
+
30
+} // namespace

+ 5
- 1
glgui/button.h View File

@@ -10,10 +10,12 @@
10 10
 
11 11
 #define GLGUI_BUTTONDOWN 		SDL_USEREVENT+10
12 12
 
13
+namespace segl {
14
+
13 15
 class GLGuiButton : public GLGuiTextLabel {
14 16
 	protected:
15 17
 		int eventid;
16
-		GLColor highlightcol;
18
+		Color highlightcol;
17 19
 		
18 20
 	public:
19 21
 		GLGuiButton(int _eventid, int _x, int _y, bool _center=false, int _wrap=0);
@@ -25,4 +27,6 @@ class GLGuiButton : public GLGuiTextLabel {
25 27
 		void onMouseClick(int m_x, int m_y, int m_button);
26 28
 };
27 29
 
30
+} // namespace {
31
+
28 32
 #endif

+ 6
- 1
glgui/textlabel.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "textlabel.h"
2 2
 
3
+namespace segl {
4
+
3 5
 GLGuiTextLabel::GLGuiTextLabel(int _x, int _y, bool _center, int _wrap) {
4 6
 	setPos(_x, _y);
5 7
 	center = _center;
@@ -19,7 +21,7 @@ void GLGuiTextLabel::setText(std::string str) {
19 21
 	text = str;
20 22
 }
21 23
 
22
-void GLGuiTextLabel::setColor(GLColor c) {
24
+void GLGuiTextLabel::setColor(Color c) {
23 25
 	col = c;
24 26
 }
25 27
 
@@ -35,3 +37,6 @@ void GLGuiTextLabel::render() {
35 37
 		fontengine.renderLines(text, x, y, center, 0, wrap, 0);
36 38
 	GLFontEngine::regain3DbyPoppingMatrix();
37 39
 }
40
+
41
+} // namespace segl
42
+

+ 7
- 3
glgui/textlabel.h View File

@@ -7,15 +7,17 @@
7 7
 #include <SDL/SDL_opengl.h>
8 8
 
9 9
 #include "object.h"
10
-#include "../glcolor.h"
10
+#include "../color.h"
11 11
 #include "../glfontengine.h"
12 12
 
13
+namespace segl {
14
+
13 15
 class GLGuiTextLabel : public GLGuiObject{
14 16
 	protected:
15 17
 		GLFontEngine fontengine;
16 18
 		std::string text;
17 19
 		
18
-		GLColor col;
20
+		Color col;
19 21
 		int x, y;
20 22
 		bool center;
21 23
 		int wrap;
@@ -24,9 +26,11 @@ class GLGuiTextLabel : public GLGuiObject{
24 26
 		GLGuiTextLabel(std::string, int _x, int _y, bool _center=false, int _wrap=0);
25 27
 
26 28
 		void setText(std::string str);
27
-		void setColor(GLColor);
29
+		void setColor(Color);
28 30
 		void setPos(int _x, int _y);
29 31
 		virtual void render();
30 32
 };
31 33
 
34
+} // namespace segl
35
+
32 36
 #endif

+ 7
- 3
glgui/window.cpp View File

@@ -1,12 +1,14 @@
1 1
 #include "window.h"
2 2
 
3
-GLGuiWindow::GLGuiWindow(SDL_Rect _pos, GLColor _bgcolor) {
3
+namespace segl {
4
+
5
+GLGuiWindow::GLGuiWindow(SDL_Rect _pos, Color _bgcolor) {
4 6
 	pos = _pos;
5 7
 	bgcolor = _bgcolor;
6 8
 }
7 9
 
8 10
 void GLGuiWindow::addItem(GLGuiObject *gobj) {
9
-	// Objekt wird in delete gelöscht
11
+	// Objekt wird in delete gel�scht
10 12
 	items.push_back(gobj);
11 13
 	if(gobj->isHighlightable())
12 14
 		highlightable.push_back(gobj);
@@ -33,8 +35,10 @@ SDL_Rect GLGuiWindow::getPos() {
33 35
 }
34 36
 
35 37
 GLGuiWindow::~GLGuiWindow() {
36
-//	der der allokiert soll sich gefälligst drum kümmern
38
+//	der der allokiert soll sich gef�lligst drum k�mmern
37 39
 // 	for(unsigned int i=0; i<items.size(); i++) {
38 40
 // 		delete(items[i]);
39 41
 // 	}
40 42
 }
43
+
44
+} // namespace segl

+ 6
- 3
glgui/window.h View File

@@ -7,16 +7,17 @@
7 7
 #include <SDL/SDL.h>
8 8
 #include <SDL/SDL_opengl.h>
9 9
 
10
-#include "../glcolor.h"
10
+#include "../color.h"
11 11
 #include "../gldrawhelper.h"
12 12
 #include "object.h"
13 13
 
14
+namespace segl {
14 15
 
15 16
 class GLGuiWindow : public GLGuiObject {
16 17
 	private:
17 18
 		bool renderbackground;
18 19
 		SDL_Rect pos;
19
-		GLColor bgcolor;
20
+		Color bgcolor;
20 21
 		
21 22
 		std::vector<GLGuiObject*> items;
22 23
 		
@@ -24,7 +25,7 @@ class GLGuiWindow : public GLGuiObject {
24 25
 		std::vector<GLGuiObject*> clickable;
25 26
 		std::vector<GLGuiObject*> keyboardable;
26 27
 	public:
27
-		GLGuiWindow(SDL_Rect _pos, GLColor _bgcolor);
28
+		GLGuiWindow(SDL_Rect _pos, Color _bgcolor);
28 29
 		~GLGuiWindow();
29 30
 		
30 31
 		void addItem(GLGuiObject*);
@@ -32,4 +33,6 @@ class GLGuiWindow : public GLGuiObject {
32 33
 		void render();
33 34
 };
34 35
 
36
+} // namespace segl
37
+
35 38
 #endif

+ 5
- 1
glmenu/menuitem.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "menuitem.h"
2 2
 
3
+namespace segl {
4
+
3 5
 MenuItem::MenuItem(std::string c) {
4 6
 	caption = c;
5 7
 	fontsizeadd = 0;
@@ -40,7 +42,7 @@ void MenuItem::render(Punkt2D pos, bool center, int basefontsize, int maxwidth,
40 42
 	if(!usevalue) {
41 43
 		fontengine.renderLine(caption, (int)pos.x, (int)pos.y, center);
42 44
 	} else {
43
-		// center und position ggf. überarbeiten..
45
+		// center und position ggf. �berarbeiten..
44 46
 		
45 47
 		Punkt2D tmp = pos;
46 48
 // 		tmp.x = pos.x - (caplen+vallen+valuewidth)/2;
@@ -79,3 +81,5 @@ MenuItem::~MenuItem() {
79 81
 	
80 82
 	
81 83
 }
84
+
85
+} // namespace segl

+ 4
- 0
glmenu/menuitem.h View File

@@ -5,6 +5,8 @@
5 5
 #include "../glfontengine.h"
6 6
 #include "../punkt2d.h"
7 7
 
8
+namespace segl {
9
+
8 10
 class MenuItem {
9 11
 	protected:
10 12
 		std::string caption;
@@ -43,4 +45,6 @@ class MenuItem {
43 45
 		virtual void render(Punkt2D pos, bool center, int basefontsize, int maxwidth, int valuewidth, bool highlight, int caplen, int capvallen, int maxlen);
44 46
 };
45 47
 
48
+} // namespace segl
49
+
46 50
 #endif

+ 4
- 0
glmenu/menuitems.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "menuitems.h"
2 2
 
3
+namespace segl {
4
+
3 5
 // MISendSDLEvent
4 6
 
5 7
 MISendSDLEvent::MISendSDLEvent(std::string str, SDL_Event event) : MenuItem(str) {
@@ -201,3 +203,5 @@ void MIEventOnToggle::right() {
201 203
 void MIEventOnToggle::resetEvent(SDL_Event event) {
202 204
 	sendevent = event;
203 205
 }
206
+
207
+} // namespace segl

+ 4
- 0
glmenu/menuitems.h View File

@@ -6,6 +6,8 @@
6 6
 #include <SDL.h>
7 7
 #include "menuitem.h"
8 8
 
9
+namespace segl {
10
+
9 11
 class MISendSDLEvent : public MenuItem {
10 12
 	private:
11 13
 		SDL_Event sendevent;
@@ -97,4 +99,6 @@ class MIEventOnToggle : public MIToggle {
97 99
 		void resetEvent(SDL_Event event);
98 100
 };
99 101
 
102
+} // namespace segl
103
+
100 104
 #endif

+ 4
- 0
glmenu/menumanager.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "menumanager.h"
2 2
 
3
+namespace segl {
4
+
3 5
 MenuManager::MenuManager() {
4 6
 	aktuell = 0;
5 7
 }
@@ -69,3 +71,5 @@ void MenuManager::reset() {
69 71
 	}
70 72
 	
71 73
 }
74
+
75
+} // namespace segl

+ 3
- 0
glmenu/menumanager.h View File

@@ -6,6 +6,7 @@
6 6
 #include "../glfontengine.h"
7 7
 #include "menumenu.h"
8 8
 
9
+namespace segl {
9 10
 
10 11
 class MenuManager {
11 12
 	private:
@@ -31,4 +32,6 @@ class MenuManager {
31 32
 		void reset();
32 33
 };
33 34
 
35
+} // namespace segl
36
+
34 37
 #endif

+ 4
- 0
glmenu/menumenu.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "menumenu.h"
2 2
 
3
+namespace segl {
4
+
3 5
 MenuMenu::MenuMenu() {
4 6
 	itempos = 0;
5 7
 	centermenu = false;
@@ -165,3 +167,5 @@ void MenuMenu::render() {
165 167
 	}
166 168
 	glEnable(GL_DEPTH_TEST);
167 169
 }
170
+
171
+} // namespace segl

+ 4
- 0
glmenu/menumenu.h View File

@@ -6,6 +6,8 @@
6 6
 #include "../punkt2d.h"
7 7
 #include "menuitem.h"
8 8
 
9
+namespace segl {
10
+
9 11
 class MenuMenu {
10 12
 	private:
11 13
 		std::vector<MenuItem*> menuitems;
@@ -49,4 +51,6 @@ class MenuMenu {
49 51
 		void render();
50 52
 };
51 53
 
54
+} // namespace segl
55
+
52 56
 #endif

+ 0
- 35
glrect.cpp View File

@@ -1,35 +0,0 @@
1
-#include "glrect.h"
2
-
3
-GLRect::GLRect() {
4
-	set(0.0f, 0.0f, 0.0f, 0.0f);
5
-}
6
-
7
-GLRect::GLRect(float _x, float _y, float _w, float _h) {
8
-	set(_x, _y, _w, _h);
9
-}
10
-
11
-GLRect::GLRect(const SDL_Rect &r) {
12
-	set(r.x, r.y, r.w, r.h);
13
-}
14
-
15
-void GLRect::set(float _x, float _y, float _w, float _h) {
16
-	x = _x;
17
-	y = _y;
18
-	w = _w;
19
-	h = _h;
20
-}
21
-
22
-void GLRect::setPoint(float _x, float _y) {
23
-	x = _x;
24
-	y = _y;
25
-}
26
-
27
-void GLRect::setDim(float _w, float _h) {
28
-	w = _w;
29
-	h = _h;
30
-}
31
-
32
-SDL_Rect GLRect::getSDLRect() {
33
-	SDL_Rect tmp = {(Uint8)x, (Uint8)y, (Uint8)w, (Uint8)h};
34
-	return tmp;
35
-}

+ 4
- 0
glsdlscreen.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "glsdlscreen.h"
2 2
 
3
+namespace segl {
4
+
3 5
 GLSDLScreen::GLSDLScreen() {
4 6
 	width = 0;
5 7
 	height = 1;
@@ -152,3 +154,5 @@ void GLSDLScreen::clearScreen() {
152 154
 void GLSDLScreen::renderScreen() {
153 155
 	SDL_GL_SwapBuffers();
154 156
 }
157
+
158
+} // namespace segl

+ 4
- 0
glsdlscreen.h View File

@@ -6,6 +6,8 @@
6 6
 #include <SDL_opengl.h>
7 7
 #include "gltexture.h"
8 8
 
9
+namespace segl {
10
+
9 11
 class GLSDLScreen {
10 12
 	private:
11 13
 		SDL_Surface *screen;
@@ -44,4 +46,6 @@ class GLSDLScreen {
44 46
 		void renderScreen();
45 47
 };
46 48
 
49
+} // namespace segl
50
+
47 51
 #endif

+ 5
- 1
gltexture.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "gltexture.h"
2 2
 
3
+namespace segl {
4
+
3 5
 GLTexture::GLTexture() {
4 6
 	init();
5 7
 	alltextures.push_back(this);
@@ -112,7 +114,7 @@ void GLTexture::unloadTexture() {
112 114
 	glDeleteTextures(1, &texint);
113 115
 	
114 116
 	loaded = false;
115
-	// Entweder tex == image, wurde schon gelöscht oder wir müssen es nich löschen
117
+	// Entweder tex == image, wurde schon gel�scht oder wir m�ssen es nich l�schen
116 118
 
117 119
 }
118 120
 
@@ -177,3 +179,5 @@ GLTexture::~GLTexture() {
177 179
 }
178 180
 
179 181
 std::vector<GLTexture*> GLTexture::alltextures;
182
+
183
+} // namespace segl

+ 4
- 0
gltexture.h View File

@@ -9,6 +9,8 @@
9 9
 #include <SDL_opengl.h>
10 10
 #include "sdlfuncs.h"
11 11
 
12
+namespace segl {
13
+
12 14
 class GLTexture {
13 15
 	private:
14 16
 		GLuint texint;
@@ -60,4 +62,6 @@ class GLTexture {
60 62
 		bool isLoaded();
61 63
 };
62 64
 
65
+} // namespace segl
66
+
63 67
 #endif

+ 0
- 177
main.cpp View File

@@ -1,177 +0,0 @@
1
-#define VERSION "0.2.2 DEV"
2
-
3
-#include <iostream>
4
-#include <string>
5
-
6
-#include <SDL.h>
7
-#include <SDL_opengl.h>
8
-
9
-#include "gltexture.h"
10
-#include "glfontengine.h"
11
-
12
-// #define GL_DEBUG_MOVEMENT false
13
-
14
-void setupGL();
15
-void resizeOpenGLWindow(int, int, float=1.0f, float=100.0f);
16
-
17
-int main(int argc, char **argv) {
18
-	std::cout << "ARGV: " << argv[0] << std::endl;
19
-	//Vars
20
-	SDL_Surface *screen;
21
-	bool quit = false;
22
-	SDL_Event event;
23
-	int w_width  = 640;
24
-	int w_height = 480;
25
-	int w_bbp    = 32;
26
-	float znear = 1.0f;
27
-	float zfar  = 100.0f;
28
-
29
-	if(SDL_Init(SDL_INIT_VIDEO)<0) {
30
-		std::cerr << "Konnte SDL nicht initialisieren" << SDL_GetError() << std::endl;
31
-		return 1;
32
-	}
33
-		
34
-	// Setting video mode
35
-	int videoFlags;
36
-	const SDL_VideoInfo *videoInfo;
37
-
38
-	videoInfo = SDL_GetVideoInfo();
39
-	
40
-	if(!videoInfo) {
41
-		std::cerr << "Video query failed: " << SDL_GetError() << std::endl;
42
-		return 1;
43
-	}
44
-	
45
-	videoFlags  = SDL_OPENGL;
46
-	videoFlags |= SDL_GL_DOUBLEBUFFER;
47
-	videoFlags |= SDL_HWPALETTE;
48
-	videoFlags |= SDL_RESIZABLE;
49
-	if(videoInfo->hw_available)
50
-		videoFlags |= SDL_HWSURFACE;
51
-	else
52
-		videoFlags |= SDL_SWSURFACE;
53
-	if(videoInfo->blit_hw)
54
-		videoFlags |= SDL_HWACCEL;
55
-		
56
-// 	videoFlags |=SDL_FULLSCREEN;
57
-	
58
-// 	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
59
-// 	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
60
-// 	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
61
-// 	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
62
-	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
63
-	
64
-	if(!(screen = SDL_SetVideoMode(w_width, w_height, w_bbp, videoFlags))) {
65
-		std::cerr << "Kein SDL-Screen verfügbar: " << SDL_GetError() << std::endl;
66
-		return 1;
67
-	}
68
-	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
69
-	
70
-	SDL_WM_SetCaption("GLGui Test, 0);
71
-	
72
-	// blank screen
73
-// 	SDL_FillRect(screen, 0, SDL_MapRGBA(screen->format, 0, 0, 0, 0));
74
-	
75
-	// GL Optionen
76
-	setupGL();
77
-		
78
-	resizeOpenGLWindow(w_width, w_height, znear, zfar);
79
-	
80
-	// Keyrepeat, falls benötigt auskommentieren
81
-	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
82
-	
83
-	// Fontengine initliaisieren, für alle die Fonts brauchen
84
-	GLFontEngine::addFont("font_big_better_alpha.png", "default");
85
-	
86
-	// Programmvariablen
87
-	Snake3D snake3d;
88
-	
89
-	//movement & keyboardcontrol
90
-	Uint8 *keys = SDL_GetKeyState(NULL);;
91
-	SDLKey tkey;
92
-	typedef enum { move_up=0, move_down, move_left, move_right} nummovekeys;
93
-	SDLKey movekeys[4];
94
-	
95
-	bool pause = true;
96
-	bool blend = false;
97
-	bool extralines = false;
98
-	bool fullscreen = false;
99
-	
100
-	// splash screen
101
-	bool splashscreen = true;
102
-	snake3d.pause(true);
103
-	SDL_Rect splashpos = { 40, 40, screen->w -80, 310 };
104
-	GLFontEngine fontengine("default");
105
-	
106
-#ifdef GL_DEBUG_MOVEMENT
107
-	movekeys[move_up]    = SDLK_i;
108
-	movekeys[move_down]  = SDLK_k;
109
-	movekeys[move_left]  = SDLK_j;
110
-	movekeys[move_right] = SDLK_l;
111
-#else
112
-	movekeys[move_up]    = SDLK_UP;
113
-	movekeys[move_down]  = SDLK_DOWN;
114
-	movekeys[move_left]  = SDLK_LEFT;
115
-	movekeys[move_right] = SDLK_RIGHT;
116
-#endif
117
-	
118
-	while(!quit) {
119
-		if(SDL_PollEvent(&event)) {
120
-			switch(event.type) {
121
-				case SDL_QUIT:
122
-					quit = true;
123
-				break;
124
-				case SDL_KEYDOWN:
125
-					keys = SDL_GetKeyState(NULL);
126
-					tkey = event.key.keysym.sym;
127
-
128
-				break;
129
-				case SDL_KEYUP:
130
-					keys = SDL_GetKeyState(NULL);
131
-				break;
132
-			}
133
-		} else {
134
-		
135
-			glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
136
-			glLoadIdentity();
137
-
138
-			SDL_Delay(10);
139
-		}
140
-		
141
-	}
142
-	GLFontEngine::quit();
143
-	SDL_Quit();
144
-	
145
-	return 0;
146
-}
147
-
148
-void setupGL() {
149
-	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
150
-	glClearDepth(1.0f);
151
-	glDepthFunc(GL_LEQUAL);
152
-	glEnable(GL_DEPTH_TEST);
153
-	glEnable(GL_TEXTURE_2D);
154
-	glShadeModel(GL_SMOOTH);
155
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
156
-// 	glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR);
157
-	
158
-// 	glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA);
159
-// 	glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
160
-	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
161
-	glEnable(GL_ALPHA_TEST);
162
-	glAlphaFunc(GL_GREATER, 0.1);
163
-}
164
-
165
-void resizeOpenGLWindow(int width, int height, float znear, float zfar) {
166
-	if(height==0)
167
-		height = 1;
168
-
169
-	glViewport(0, 0, (GLsizei)width, (GLsizei)height);
170
-	
171
-	glMatrixMode(GL_PROJECTION);
172
-	glLoadIdentity();
173
-	gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, znear, zfar);
174
-	
175
-	glMatrixMode(GL_MODELVIEW);
176
-	glLoadIdentity();
177
-}

+ 4
- 0
matrix.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "matrix.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Matrix::Matrix(int _m, int _n) {
4 6
 	m = _m;
5 7
 	n = _n;
@@ -154,3 +156,5 @@ Matrix::~Matrix() {
154 156
 	}
155 157
 	delete[](c);
156 158
 }
159
+
160
+} // namespace segl

+ 3
- 1
matrix.h View File

@@ -7,6 +7,8 @@
7 7
 #include "punkt3d.h"
8 8
 #include "emath.h"
9 9
 
10
+namespace segl {
11
+
10 12
 class Matrix {
11 13
 	protected:
12 14
 		float **c;
@@ -39,6 +41,6 @@ class Matrix {
39 41
 
40 42
 };
41 43
 
42
-
44
+} // namespace segl
43 45
 
44 46
 #endif

+ 4
- 0
model/loadobj.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "loadobj.h"
2 2
 
3
+namespace segl {
4
+
3 5
 LoadOBJ::LoadOBJ(std::string _filename) : Modelloader(_filename) {
4 6
 	
5 7
 }
@@ -233,3 +235,5 @@ bool LoadOBJ::load(Model *m) {
233 235
 // 	std::cout << "Loaded!" << std::endl;
234 236
 	return true;
235 237
 }
238
+
239
+} // namespace segl

+ 4
- 0
model/loadobj.h View File

@@ -6,6 +6,8 @@
6 6
 #include "model.h"
7 7
 #include "../extstring.h"
8 8
 
9
+namespace segl {
10
+
9 11
 class LoadOBJ : public Modelloader {
10 12
 	private:
11 13
 		
@@ -14,4 +16,6 @@ class LoadOBJ : public Modelloader {
14 16
 		bool load(Model *m);
15 17
 };
16 18
 
19
+} // namespace segl
20
+
17 21
 #endif

+ 6
- 2
model/model.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "model.h"
2 2
 
3
+namespace segl {
4
+
3 5
 // Class Meshpoint
4 6
 
5 7
 Meshpoint::Meshpoint() {
@@ -31,11 +33,11 @@ Material::Material() {
31 33
 	specular.set(1.0f, 1.0f, 1.0f);
32 34
 }
33 35
 
34
-Material::Material(std::string _name, GLColor _a, GLColor _d, GLColor _s) {
36
+Material::Material(std::string _name, Color _a, Color _d, Color _s) {
35 37
 	set(_name, _a, _d, _s);
36 38
 }
37 39
 
38
-void Material::set(std::string _name, GLColor _a, GLColor _d, GLColor _s) {
40
+void Material::set(std::string _name, Color _a, Color _d, Color _s) {
39 41
 	name = _name;
40 42
 	ambient = _a;
41 43
 	diffuse = _d;
@@ -156,3 +158,5 @@ const Punkt3D* Model::getMeshData(unsigned int *meshanz) {
156 158
 	*meshanz = meshdataanz;
157 159
 	return (const Punkt3D*)meshdata;
158 160
 }
161
+
162
+} // namespace segl

+ 8
- 4
model/model.h View File

@@ -5,9 +5,11 @@
5 5
 #include <SDL_opengl.h>
6 6
 #include "../punkt3d.h"
7 7
 #include "../punkt2d.h"
8
-#include "../glcolor.h"
8
+#include "../color.h"
9 9
 #include "../quader.h"
10 10
 
11
+namespace segl {
12
+
11 13
 class Meshpoint {
12 14
 	public:
13 15
 		Meshpoint();
@@ -22,12 +24,12 @@ class Meshpoint {
22 24
 class Material {
23 25
 	public:
24 26
 		Material();
25
-		Material(std::string _name, GLColor _a, GLColor _d, GLColor _s);
26
-		void set(std::string _name, GLColor _a, GLColor _d, GLColor _s);
27
+		Material(std::string _name, Color _a, Color _d, Color _s);
28
+		void set(std::string _name, Color _a, Color _d, Color _s);
27 29
 		void use();
28 30
 		
29 31
 		std::string name;
30
-		GLColor ambient, diffuse, specular;
32
+		Color ambient, diffuse, specular;
31 33
 };
32 34
 
33 35
 class Polygonpoint {
@@ -88,4 +90,6 @@ class Model {
88 90
 		const Punkt3D* getMeshData(unsigned int *meshanz);
89 91
 };
90 92
 
93
+} // namespace segl
94
+
91 95
 #endif

+ 4
- 0
model/modelloader.cpp View File

@@ -1,5 +1,9 @@
1 1
 #include "modelloader.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Modelloader::Modelloader(std::string _filename) {
4 6
 	filename = _filename;
5 7
 }
8
+
9
+} // namespace segl

+ 3
- 0
model/modelloader.h View File

@@ -5,6 +5,7 @@
5 5
 #include <fstream>
6 6
 #include "model.h"
7 7
 
8
+namespace segl {
8 9
 
9 10
 class Modelloader {
10 11
 	protected:
@@ -15,4 +16,6 @@ class Modelloader {
15 16
 		virtual bool load(Model *m)=0;
16 17
 };
17 18
 
19
+} // namespace segl
20
+
18 21
 #endif

+ 16
- 11
punkt2d.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "punkt2d.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Punkt2D::Punkt2D() {
4 6
 	x = y = 0.0f;
5 7
 }
@@ -112,33 +114,36 @@ bool Punkt2D::operator==(const Punkt2D& b) {
112 114
 bool Punkt2D::operator!=(const Punkt2D& b) {
113 115
 	return !(*this==b);
114 116
 }
117
+
115 118
 // Freunde
116 119
 
117
-Punkt2D operator+(const float& _m, const Punkt2D& b) {
118
-	return Punkt2D(b.x+_m, b.y+_m);
120
+segl::Punkt2D operator+(const float& _m, const segl::Punkt2D& b) {
121
+	return segl::Punkt2D(b.x+_m, b.y+_m);
119 122
 }
120 123
 
121
-Punkt2D operator-(const float& _m, const Punkt2D& b) {
122
-	return Punkt2D(b.x-_m, b.y-_m);
124
+segl::Punkt2D operator-(const float& _m, const segl::Punkt2D& b) {
125
+	return segl::Punkt2D(b.x-_m, b.y-_m);
123 126
 }
124 127
 
125
-Punkt2D operator*(const float& _m, const Punkt2D& b) {
126
-	return Punkt2D(b.x*_m, b.y*_m);
128
+segl::Punkt2D operator*(const float& _m, const segl::Punkt2D& b) {
129
+	return segl::Punkt2D(b.x*_m, b.y*_m);
127 130
 }
128 131
 
129
-Punkt2D operator/(const float& _m, const Punkt2D& b) {
130
-	return Punkt2D(b.x/_m, b.y/_m);
132
+segl::Punkt2D operator/(const float& _m, const segl::Punkt2D& b) {
133
+	return segl::Punkt2D(b.x/_m, b.y/_m);
131 134
 }
132 135
 
133
-void glTexCoord2f(Punkt2D p) {
136
+} // namespace segl
137
+
138
+void glTexCoord2f(segl::Punkt2D p) {
134 139
 	glTexCoord2f(p.x, p.y);
135 140
 }
136 141
 
137
-float abs(Punkt2D p) {
142
+float abs(segl::Punkt2D p) {
138 143
 	return p.abs();
139 144
 }
140 145
 
141 146
 // Fixed Headers
142
-void glTexCoordP2D(Punkt2D p) {
147
+void glTexCoordP2D(segl::Punkt2D p) {
143 148
 	glTexCoord2f(p.x, p.y);
144 149
 }

+ 10
- 3
punkt2d.h View File

@@ -5,6 +5,8 @@
5 5
 #include <cmath>
6 6
 #include "emath.h"
7 7
 
8
+namespace segl {
9
+
8 10
 class Punkt2D {
9 11
 	public:
10 12
 		Punkt2D();
@@ -45,10 +47,15 @@ class Punkt2D {
45 47
 		
46 48
 };
47 49
 
48
-void glTexCoord2f(Punkt2D);
49
-float abs(Punkt2D);
50
+
51
+} // namespace segl
52
+
53
+void glTexCoord2f(segl::Punkt2D);
54
+float abs(segl::Punkt2D);
50 55
 
51 56
 // Fixed Headers
52
-void glTexCoordP2D(Punkt2D p);
57
+void glTexCoordP2D(segl::Punkt2D p);
58
+
59
+
53 60
 
54 61
 #endif

+ 24
- 21
punkt3d.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "punkt3d.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Punkt3D::Punkt3D() {
4 6
 	x = y = z = 0.0f;
5 7
 }
@@ -88,8 +90,6 @@ void Punkt3D::print(std::string coordname) {
88 90
 	std::cout << coordname << "Coord: (" << x << ", " << y << ", " << z << ")" << std::endl;
89 91
 }
90 92
 
91
-
92
-
93 93
 Punkt3D Punkt3D::operator+(const Punkt3D &b) {
94 94
 	Punkt3D c;
95 95
 	c.x =  x + b.x;
@@ -179,68 +179,71 @@ bool Punkt3D::operator==(const Punkt3D& b) {
179 179
 bool Punkt3D::operator!=(const Punkt3D& b) {
180 180
 	return !(*this==b);
181 181
 }
182
+
182 183
 // Freunde
183 184
 
184
-Punkt3D operator+(const float& _m, const Punkt3D& b) {
185
-	return Punkt3D(b.x+_m, b.y+_m, b.z+_m);
185
+segl::Punkt3D operator+(const float& _m, const segl::Punkt3D& b) {
186
+	return segl::Punkt3D(b.x+_m, b.y+_m, b.z+_m);
186 187
 }
187 188
 
188
-Punkt3D operator-(const float& _m, const Punkt3D& b) {
189
-	return Punkt3D(b.x-_m, b.y-_m, b.z-_m);
189
+segl::Punkt3D operator-(const float& _m, const segl::Punkt3D& b) {
190
+	return segl::Punkt3D(b.x-_m, b.y-_m, b.z-_m);
190 191
 }
191 192
 
192
-Punkt3D operator*(const float& _m, const Punkt3D& b) {
193
-	return Punkt3D(b.x*_m, b.y*_m, b.z*_m);
193
+segl::Punkt3D operator*(const float& _m, const segl::Punkt3D& b) {
194
+	return segl::Punkt3D(b.x*_m, b.y*_m, b.z*_m);
194 195
 }
195 196
 
196
-Punkt3D operator/(const float& _m, const Punkt3D& b) {
197
-	return Punkt3D(b.x/_m, b.y/_m, b.z/_m);
197
+segl::Punkt3D operator/(const float& _m, const segl::Punkt3D& b) {
198
+	return segl::Punkt3D(b.x/_m, b.y/_m, b.z/_m);
198 199
 }
199 200
 
200
-std::ostream &operator<<(std::ostream &ostr, const Punkt3D &r) {
201
+std::ostream &operator<<(std::ostream &ostr, const segl::Punkt3D &r) {
201 202
 	return ostr << "(" << r.x << ", " << r.y << ", " << r.z << ")";
202 203
 }
203 204
 
204
-float abs(Punkt3D p) {
205
+} // namespace segl
206
+
207
+float abs(segl::Punkt3D p) {
205 208
 	return p.abs();
206 209
 }
207 210
 
208 211
 // OpenGL Funktionen f�r Punkt3D
209 212
 
210
-void glVertex3f(Punkt3D p) {
213
+void glVertex3f(segl::Punkt3D p) {
211 214
 	glVertex3f(p.x, p.y, p.z);
212 215
 }
213 216
 
214
-void glTranslatef(Punkt3D p) {
217
+void glTranslatef(segl::Punkt3D p) {
215 218
 	glTranslatef(p.x, p.y, p.z);
216 219
 }
217 220
 
218
-void glNormal3f(Punkt3D p) {
221
+void glNormal3f(segl::Punkt3D p) {
219 222
 	glNormal3f(p.x, p.y, p.z);
220 223
 }
221 224
 
222
-void glRotatef(float deg, Punkt3D vec) {
225
+void glRotatef(float deg, segl::Punkt3D vec) {
223 226
 	glRotatef(deg, vec.x, vec.y, vec.z);
224 227
 }
225 228
 
226 229
 // Funktionen mit richtgen bezeichnern
227
-void glVertexP3D(Punkt3D p) {
230
+void glVertexP3D(segl::Punkt3D p) {
228 231
 	glVertex3f(p.x, p.y, p.z);
229 232
 }
230 233
 
231
-void glTranslateP3D(Punkt3D p) {
234
+void glTranslateP3D(segl::Punkt3D p) {
232 235
 	glTranslatef(p.x, p.y, p.z);
233 236
 }
234 237
 
235
-void glNormalP3D(Punkt3D p) {
238
+void glNormalP3D(segl::Punkt3D p) {
236 239
 	glNormal3f(p.x, p.y, p.z);
237 240
 }
238 241
 
239
-void glRotateP3D(float deg, Punkt3D vec) {
242
+void glRotateP3D(float deg, segl::Punkt3D vec) {
240 243
 	glRotatef(deg, vec.x, vec.y, vec.z);
241 244
 }
242 245
 
243
-void gluLookAt(Punkt3D pos, Punkt3D viewport, Punkt3D normal) {
246
+void gluLookAt(segl::Punkt3D pos, segl::Punkt3D viewport, segl::Punkt3D normal) {
244 247
 	gluLookAt( pos.x, pos.y, pos.z,
245 248
 			   viewport.x, viewport.y, viewport.z,
246 249
 			   normal.x, normal.y, normal.z );

+ 14
- 10
punkt3d.h View File

@@ -5,6 +5,8 @@
5 5
 #include <cmath>
6 6
 #include "emath.h"
7 7
 
8
+namespace segl {
9
+
8 10
 class Punkt3D {
9 11
 	public:
10 12
 		Punkt3D();
@@ -55,22 +57,24 @@ class Punkt3D {
55 57
 		friend std::ostream &operator<<(std::ostream &ostr, const Punkt3D &r);
56 58
 };
57 59
 
58
-float abs(Punkt3D);
60
+} // namespace segl
61
+
62
+float abs(segl::Punkt3D);
59 63
 
60 64
 // OpenGL-Functions for Punkt3D
61 65
 
62
-void glVertex3f(Punkt3D);
63
-void glTranslatef(Punkt3D);
64
-void glNormal3f(Punkt3D);
66
+void glVertex3f(segl::Punkt3D);
67
+void glTranslatef(segl::Punkt3D);
68
+void glNormal3f(segl::Punkt3D);
65 69
 
66
-void glRotatef(float, Punkt3D);
70
+void glRotatef(float, segl::Punkt3D);
67 71
 
68 72
 // Funktionen mit richtgen bezeichnern
69
-void glVertexP3D(Punkt3D);
70
-void glTranslateP3D(Punkt3D);
71
-void glNormalP3D(Punkt3D);
73
+void glVertexP3D(segl::Punkt3D);
74
+void glTranslateP3D(segl::Punkt3D);
75
+void glNormalP3D(segl::Punkt3D);
72 76
 
73
-void glRotateP3D(float, Punkt3D);
74
-void gluLookAt(Punkt3D pos, Punkt3D viewport, Punkt3D normal);
77
+void glRotateP3D(float, segl::Punkt3D);
78
+void gluLookAt(segl::Punkt3D pos, segl::Punkt3D viewport, segl::Punkt3D normal);
75 79
 
76 80
 #endif

+ 4
- 0
quader.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "quader.h"
2 2
 
3
+namespace segl {
4
+
3 5
 void Quader::clean() {
4 6
 	a.set(0.0f, 0.0f, 0.0f);
5 7
 	b = c = d = e = f = g = h = a;
@@ -33,3 +35,5 @@ void Quader::render() {
33 35
 		glVertexP3D(h);
34 36
 	glEnd();
35 37
 }
38
+
39
+} // namespace segl

+ 3
- 0
quader.h View File

@@ -4,6 +4,7 @@
4 4
 #include <SDL_opengl.h>
5 5
 #include "punkt3d.h"
6 6
 
7
+namespace segl {
7 8
 
8 9
 class Quader {
9 10
 	public:
@@ -12,4 +13,6 @@ class Quader {
12 13
 		void render();
13 14
 };
14 15
 
16
+} // namespace segl
17
+
15 18
 #endif

+ 4
- 0
quaternion.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "quaternion.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Quaternion::Quaternion() {
4 6
 	w = 1.0f,
5 7
 	x = y = z = 0.0f;
@@ -163,3 +165,5 @@ Quaternion Quaternion::operator*(const Quaternion &q) {
163 165
 // 	q.createGlMatrix(matrix);
164 166
 // 	glMultMatrixf(matrix);
165 167
 // }
168
+
169
+} // namespace segl

+ 4
- 0
quaternion.h View File

@@ -8,6 +8,8 @@
8 8
 #include "punkt3d.h"
9 9
 #include "emath.h"
10 10
 
11
+namespace segl {
12
+
11 13
 class Quaternion {
12 14
 	private:
13 15
 		float x, y, z, w;
@@ -51,4 +53,6 @@ class Quaternion {
51 53
 // 
52 54
 // void glMultMatrixf(Quaternion);
53 55
 
56
+} // namespace segl
57
+
54 58
 #endif

+ 40
- 0
rect.cpp View File

@@ -0,0 +1,40 @@
1
+#include "rect.h"
2
+
3
+namespace segl {
4
+
5
+Rect::Rect() {
6
+	set(0.0f, 0.0f, 0.0f, 0.0f);
7
+}
8
+
9
+Rect::Rect(float _x, float _y, float _w, float _h) {
10
+	set(_x, _y, _w, _h);
11
+}
12
+
13
+Rect::Rect(const SDL_Rect &r) {
14
+	set(r.x, r.y, r.w, r.h);
15
+}
16
+
17
+void Rect::set(float _x, float _y, float _w, float _h) {
18
+	x = _x;
19
+	y = _y;
20
+	w = _w;
21
+	h = _h;
22
+}
23
+
24
+void Rect::setPoint(float _x, float _y) {
25
+	x = _x;
26
+	y = _y;
27
+}
28
+
29
+void Rect::setDim(float _w, float _h) {
30
+	w = _w;
31
+	h = _h;
32
+}
33
+
34
+SDL_Rect Rect::getSDLRect() {
35
+	SDL_Rect tmp = {(Uint8)x, (Uint8)y, (Uint8)w, (Uint8)h};
36
+	return tmp;
37
+}
38
+
39
+} // namespace segl
40
+

glrect.h → rect.h View File

@@ -1,16 +1,18 @@
1
-#ifndef __GLRECT_H
2
-#define __GLRECT_H
1
+#ifndef __RECT_H
2
+#define __RECT_H
3 3
 
4 4
 #include <SDL.h>
5 5
 
6
-class GLRect {
6
+namespace segl {
7
+
8
+class Rect {
7 9
 	public:
8 10
 		float x, y;
9 11
 		float w, h;
10 12
 		
11
-		GLRect();
12
-		GLRect(float, float, float, float);
13
-		GLRect(const SDL_Rect&);
13
+		Rect();
14
+		Rect(float, float, float, float);
15
+		Rect(const SDL_Rect&);
14 16
 		
15 17
 		void set(float, float, float, float);
16 18
 		void setPoint(float, float);
@@ -19,4 +21,6 @@ class GLRect {
19 21
 	
20 22
 };
21 23
 
24
+} // namespace segl
25
+
22 26
 #endif

+ 4
- 0
rotationsmatrix.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "rotationsmatrix.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Rotationsmatrix::Rotationsmatrix() : Matrix(3,3) {
4 6
 	set(x_axis, 0.0f);
5 7
 }
@@ -90,3 +92,5 @@ Rotationsmatrix Rotationsmatrix::operator*(const Rotationsmatrix &p) {
90 92
 Rotationsmatrix::~Rotationsmatrix() {
91 93
 
92 94
 }
95
+
96
+} // namespace segl

+ 4
- 0
rotationsmatrix.h View File

@@ -6,6 +6,8 @@
6 6
 #include "emath.h"
7 7
 #include "matrix.h"
8 8
 
9
+namespace segl {
10
+
9 11
 enum axis { x_axis=0, y_axis, z_axis };
10 12
 
11 13
 class Rotationsmatrix : public Matrix {
@@ -28,4 +30,6 @@ class Rotationsmatrix : public Matrix {
28 30
 		Rotationsmatrix operator*(const Rotationsmatrix&);
29 31
 };
30 32
 
33
+} // namespace segl
34
+
31 35
 #endif

+ 4
- 0
sdlfuncs.cpp View File

@@ -1,5 +1,7 @@
1 1
 #include "sdlfuncs.h"
2 2
 
3
+namespace segl {
4
+
3 5
 Uint32 getPixel(SDL_Surface *surface, int x, int y)
4 6
 {
5 7
     int bpp = surface->format->BytesPerPixel;
@@ -80,3 +82,5 @@ void mirrorSurfaceMiddleX(SDL_Surface *surface) {
80 82
 	}
81 83
 	SDL_UnlockSurface(surface);
82 84
 }
85
+
86
+} // namespace segl

+ 4
- 0
sdlfuncs.h View File

@@ -4,9 +4,13 @@
4 4
 #include <iostream>
5 5
 #include <SDL.h>
6 6
 
7
+namespace segl {
8
+
7 9
 Uint32 getPixel(SDL_Surface *surface, int x, int y);
8 10
 void setPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
9 11
 void swapPixel(SDL_Surface *surface, int x1, int y1, int x2, int y2);
10 12
 void mirrorSurfaceMiddleX(SDL_Surface *surface);
11 13
 
14
+} // namespace segl
15
+
12 16
 #endif

+ 0
- 14
testprog.cpp View File

@@ -1,14 +0,0 @@
1
-#include <iostream>
2
-#include "glsdlscreen.h"
3
-
4
-int main() {
5
-	GLSDLScreen screen;
6
-
7
-	screen.enableOpenGL(true);
8
-	screen.setVideoMode(640, 480, 32);
9
-	screen.apply();
10
-
11
-	// whee
12
-
13
-	return 0;
14
-}

+ 0
- 0
testprog.h View File


Loading…
Cancel
Save