summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-02-27 23:48:41 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-02-27 23:48:41 +0100
commit77361abc13c02469d41af5d937adf517ac5326b9 (patch)
tree2d2fa8316867349413764dee21eade239fe8d8ce
parentb353185ff989e2dd058284dc5b1a6d5d6197bcbd (diff)
Added SDL_image based texture loader.
-rw-r--r--SConstruct4
-rw-r--r--patt.jon196
-rw-r--r--pattern.cpp12
-rw-r--r--pattern.h14
-rwxr-xr-xtexture.cpp2
-rwxr-xr-xtexturesdl.cpp16
-rwxr-xr-xtexturesdl.h8
7 files changed, 239 insertions, 13 deletions
diff --git a/SConstruct b/SConstruct
index df0a150..80e5275 100644
--- a/SConstruct
+++ b/SConstruct
@@ -2,12 +2,12 @@ env = Environment(
LIBS = ['ARgsub_lite', 'ARvideo', 'AR', 'png'],
)
-common_sources = ['application.cpp', 'pattern.cpp', 'texture.cpp', 'texturepng.cpp']
+common_sources = ['application.cpp', 'pattern.cpp', 'texture.cpp', 'texturesdl.cpp']
if env['PLATFORM'] == 'darwin':
env.Append(CPPFLAGS = '-m32')
env.Append(LINKFLAGS = '-m32')
- env.Append(FRAMEWORKS = ['SDL', 'Cocoa', 'OpenGL', 'QuickTime', 'Carbon', 'AppKit'])
+ env.Append(FRAMEWORKS = ['SDL', 'SDL_image', 'Cocoa', 'OpenGL', 'QuickTime', 'Carbon', 'AppKit'])
common_sources.append('SDLMain.m')
else:
env.Append(LIBS = ['GL', 'GLU', 'SDL', 'SDLmain', 'gstreamer-0.10'])
diff --git a/patt.jon b/patt.jon
new file mode 100644
index 0000000..27d8b47
--- /dev/null
+++ b/patt.jon
@@ -0,0 +1,196 @@
+ 61 20 20 25 34 35 25 125 196 194 197 198 198 198 197 198
+ 45 16 12 15 18 23 21 85 192 200 199 199 198 200 199 198
+ 60 23 22 16 24 23 23 131 195 200 198 199 199 199 199 198
+ 149 112 108 81 102 100 121 177 199 200 200 200 198 198 200 200
+ 191 190 194 188 192 195 193 196 200 200 200 200 199 199 200 201
+ 198 198 199 196 197 197 198 200 199 200 200 200 200 200 199 201
+ 198 198 198 198 199 199 200 199 198 200 200 200 200 200 200 202
+ 195 200 198 200 200 200 201 200 200 200 200 200 200 200 200 200
+ 196 199 198 199 200 200 200 200 200 200 200 200 200 200 200 200
+ 196 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 197 199 200 200 200 200 200 200 200 200 200 200 200 200 199 199
+ 195 199 200 200 200 200 200 200 200 200 200 200 200 200 199 201
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 199 199 199 200 200 200 199 199 200 200 199 199 200 200
+ 52 26 27 31 26 32 29 131 199 200 200 199 199 199 199 199
+ 51 13 19 17 15 15 14 120 201 199 200 200 200 200 199 200
+ 71 19 17 17 16 18 23 140 200 199 200 200 200 200 200 200
+ 167 132 120 96 114 122 133 186 199 200 200 200 200 200 200 199
+ 200 200 197 196 199 198 199 200 200 200 200 200 200 200 200 199
+ 199 199 199 199 200 200 200 200 200 200 200 200 200 200 200 199
+ 198 200 200 200 200 200 199 200 200 200 200 200 200 200 200 199
+ 200 199 200 200 200 199 199 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 199 200 200 200 200 200 200 200 200 200
+ 199 200 199 199 200 200 200 200 200 200 200 200 200 200 200 200
+ 199 199 199 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 201 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 200 199 199 199 200 200 200 199 199 200 200 199 199 200 200
+ 43 30 31 33 34 30 23 129 198 198 198 199 199 200 199 199
+ 42 16 16 16 22 25 23 127 199 201 200 200 200 200 199 199
+ 67 24 21 23 24 26 32 163 200 200 200 200 200 200 200 200
+ 162 130 126 108 126 131 141 194 199 200 200 200 200 200 199 200
+ 197 197 197 196 199 198 198 200 200 200 200 200 200 200 198 199
+ 199 199 199 199 199 199 200 200 200 200 200 200 200 200 199 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 197 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 199 199 199 200 200 200 199 200 200 200 199 199 200 200
+
+ 198 198 198 200 201 201 202 200 200 200 200 199 201 199 199 200
+ 197 199 199 200 200 199 200 200 200 200 200 199 199 200 200 200
+ 198 200 199 198 199 200 200 200 200 200 200 200 200 200 200 199
+ 198 198 199 198 199 200 200 200 200 200 200 200 200 200 200 199
+ 198 199 199 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 197 199 198 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 194 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 196 192 195 199 200 199 198 200 200 200 200 200 200 200 200 199
+ 125 85 131 177 196 200 199 200 200 200 200 200 200 200 200 200
+ 25 21 23 121 193 198 200 201 200 200 200 200 200 200 200 200
+ 35 23 23 100 195 197 199 200 200 200 200 200 200 200 200 200
+ 34 18 24 102 192 197 199 200 200 200 200 200 200 200 200 199
+ 25 15 16 81 188 196 198 200 199 200 200 200 200 200 200 199
+ 20 12 22 108 194 199 198 198 198 200 200 200 200 200 200 199
+ 20 16 23 112 190 198 198 200 199 199 200 199 199 200 200 200
+ 61 45 60 149 191 198 198 195 196 196 198 197 195 199 200 199
+ 199 200 200 199 199 199 199 200 200 200 200 200 199 200 199 200
+ 199 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 199 199 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 201 200 199 200 200 200 200 200 200 200 200 200 200 200 199
+ 131 120 140 186 200 200 200 200 200 200 200 200 200 200 200 200
+ 29 14 23 133 199 200 199 199 199 200 200 200 200 200 200 200
+ 32 15 18 122 198 200 200 199 200 200 200 200 200 200 200 200
+ 26 15 16 114 199 200 200 200 200 200 200 200 200 200 200 199
+ 31 17 17 96 196 199 200 200 200 199 200 200 200 200 200 199
+ 27 19 17 120 197 199 200 200 200 199 199 200 200 200 200 199
+ 26 13 19 132 200 199 200 199 200 200 199 200 200 200 200 200
+ 52 51 71 167 200 199 198 200 200 199 199 201 200 200 200 200
+ 199 199 200 200 199 200 199 199 200 200 200 200 199 198 200 200
+ 199 199 200 199 198 199 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 201 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 199 200 199 200 200 200 200 200 200 200 200 200 200 200 199
+ 129 127 163 194 200 200 200 200 200 200 200 200 200 200 200 200
+ 23 23 32 141 198 200 200 200 200 200 200 200 200 200 200 200
+ 30 25 26 131 198 199 200 200 200 200 200 200 200 200 200 200
+ 34 22 24 126 199 199 200 200 200 200 200 200 200 200 200 199
+ 33 16 23 108 196 199 200 200 200 200 200 200 200 200 200 199
+ 31 16 21 126 197 199 200 200 200 200 200 200 200 200 200 199
+ 30 16 24 130 197 199 200 200 200 200 200 200 200 200 200 200
+ 43 42 67 162 197 199 199 199 199 197 198 198 199 200 200 200
+
+ 200 200 199 199 200 200 199 199 200 200 200 199 199 199 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 201 199 200 200 200 200 200 200 200 200 200 200 200 200 199 195
+ 199 199 200 200 200 200 200 200 200 200 200 200 200 200 199 197
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199 196
+ 200 200 200 200 200 200 200 200 200 200 200 200 199 198 199 196
+ 200 200 200 200 200 200 200 200 200 201 200 200 200 198 200 195
+ 202 200 200 200 200 200 200 198 199 200 199 199 198 198 198 198
+ 201 199 200 200 200 200 200 199 200 198 197 197 196 199 198 198
+ 201 200 199 199 200 200 200 200 196 193 195 192 188 194 190 191
+ 200 200 198 198 200 200 200 199 177 121 100 102 81 108 112 149
+ 198 199 199 199 199 198 200 195 131 23 23 24 16 22 23 60
+ 198 199 200 198 199 199 200 192 85 21 23 18 15 12 16 45
+ 198 197 198 198 198 197 194 196 125 25 35 34 25 20 20 61
+ 200 200 199 199 200 200 199 199 200 200 200 199 199 199 200 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 201
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 199 199 199
+ 200 200 200 200 200 200 200 200 200 200 200 200 199 199 200 199
+ 200 200 200 200 200 200 200 200 200 199 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 199 199 200 200 200 199 200
+ 199 200 200 200 200 200 200 200 200 199 200 200 200 200 200 198
+ 199 200 200 200 200 200 200 200 200 200 200 200 199 199 199 199
+ 199 200 200 200 200 200 200 200 200 199 198 199 196 197 200 200
+ 199 200 200 200 200 200 200 199 186 133 122 114 96 120 132 167
+ 200 200 200 200 200 200 199 200 140 23 18 16 17 17 19 71
+ 200 199 200 200 200 200 199 201 120 14 15 15 17 19 13 51
+ 199 199 199 199 199 200 200 199 131 29 32 26 31 27 26 52
+ 200 200 199 199 200 200 200 199 200 200 200 199 199 199 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 198 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 197
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 199 200 200 200 200 200 200 200 200 199 199 199 199 199 199
+ 199 198 200 200 200 200 200 200 200 198 198 199 196 197 197 197
+ 200 199 200 200 200 200 200 199 194 141 131 126 108 126 130 162
+ 200 200 200 200 200 200 200 200 163 32 26 24 23 21 24 67
+ 199 199 200 200 200 200 201 199 127 23 25 22 16 16 16 42
+ 199 199 200 199 199 198 198 198 129 23 30 34 33 31 30 43
+
+ 199 200 199 195 197 198 196 196 195 198 198 191 149 60 45 61
+ 200 200 200 199 199 200 199 199 200 198 198 190 112 23 16 20
+ 199 200 200 200 200 200 200 198 198 198 199 194 108 22 12 20
+ 199 200 200 200 200 200 200 199 200 198 196 188 81 16 15 25
+ 199 200 200 200 200 200 200 200 200 199 197 192 102 24 18 34
+ 200 200 200 200 200 200 200 200 200 199 197 195 100 23 23 35
+ 200 200 200 200 200 200 200 200 201 200 198 193 121 23 21 25
+ 200 200 200 200 200 200 200 200 200 199 200 196 177 131 85 125
+ 199 200 200 200 200 200 200 200 200 198 199 200 199 195 192 196
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 194
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 198 199 197
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 199 199 198
+ 199 200 200 200 200 200 200 200 200 200 200 199 198 199 198 198
+ 199 200 200 200 200 200 200 200 200 200 200 199 198 199 200 198
+ 200 200 200 199 199 200 200 200 200 200 199 200 200 199 199 197
+ 200 199 199 201 199 200 200 200 200 202 201 201 200 198 198 198
+ 200 200 200 200 201 199 199 200 200 198 199 200 167 71 51 52
+ 200 200 200 200 200 199 200 200 199 200 199 200 132 19 13 26
+ 199 200 200 200 200 199 199 200 200 200 199 197 120 17 19 27
+ 199 200 200 200 200 200 199 200 200 200 199 196 96 17 17 31
+ 199 200 200 200 200 200 200 200 200 200 200 199 114 16 15 26
+ 200 200 200 200 200 200 200 200 199 200 200 198 122 18 15 32
+ 200 200 200 200 200 200 200 199 199 199 200 199 133 23 14 29
+ 200 200 200 200 200 200 200 200 200 200 200 200 186 140 120 131
+ 199 200 200 200 200 200 200 200 200 200 200 200 199 200 201 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 199 199 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199 199
+ 200 199 200 199 200 200 200 200 200 199 199 199 199 200 200 199
+ 200 200 200 199 198 198 197 199 199 199 199 197 162 67 42 43
+ 200 200 200 200 200 200 200 200 200 200 199 197 130 24 16 30
+ 199 200 200 200 200 200 200 200 200 200 199 197 126 21 16 31
+ 199 200 200 200 200 200 200 200 200 200 199 196 108 23 16 33
+ 199 200 200 200 200 200 200 200 200 200 199 199 126 24 22 34
+ 200 200 200 200 200 200 200 200 200 200 199 198 131 26 25 30
+ 200 200 200 200 200 200 200 200 200 200 200 198 141 32 23 23
+ 200 200 200 200 200 200 200 200 200 200 200 200 194 163 127 129
+ 199 200 200 200 200 200 200 200 200 200 200 200 199 200 199 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 201 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 198
+ 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 199
+ 199 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200
+ 200 200 200 200 200 200 200 200 200 200 199 198 199 200 199 199
+ 200 200 198 199 200 200 200 200 199 199 200 199 200 200 199 199
+
diff --git a/pattern.cpp b/pattern.cpp
index 87d39f3..63b3bcc 100644
--- a/pattern.cpp
+++ b/pattern.cpp
@@ -8,7 +8,7 @@
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
-#include "texturepng.h"
+#include "texturesdl.h"
Pattern::Pattern(std::string filename) {
patt_width = 25.0;
@@ -29,12 +29,11 @@ void Pattern::update(ARMarkerInfo* marker_info, int marker_num) {
}
}
-KakePattern::KakePattern() : Pattern("patt.hiro") {
-
- tex = new TexturePNG("foo.png");
+SpritePattern::SpritePattern(Texture* _tex) : Pattern("patt.jon") {
+ tex = _tex;
}
-void KakePattern::draw() {
+void SpritePattern::draw() {
double gl_para[16];
arglCameraView(patt_trans_kake, gl_para, 1.0);
@@ -55,3 +54,6 @@ void KakePattern::draw() {
glVertex3f(30, -30, 0);
glEnd();
}
+
+KakePattern::KakePattern() : SpritePattern(new TextureSDL("foo.png")) {
+}
diff --git a/pattern.h b/pattern.h
index 3e28d97..75c91e3 100644
--- a/pattern.h
+++ b/pattern.h
@@ -7,10 +7,10 @@
class Pattern {
private:
- double patt_width;
- double patt_center[2];
int patt_id;
protected:
+ double patt_width;
+ double patt_center[2];
double patt_trans_kake[3][4];
public:
@@ -21,16 +21,20 @@ class Pattern {
virtual void draw() = 0;
};
-class KakePattern : public Pattern {
+class SpritePattern : public Pattern {
private:
-
Texture* tex;
public:
- KakePattern();
+ SpritePattern(Texture* _tex);
protected:
virtual void draw();
};
+class KakePattern : public SpritePattern {
+ public:
+ KakePattern();
+};
+
#endif
diff --git a/texture.cpp b/texture.cpp
index 5a4a7ab..cbf9f40 100755
--- a/texture.cpp
+++ b/texture.cpp
@@ -21,5 +21,5 @@ void Texture::build() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
//glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
- gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_BGRA, GL_UNSIGNED_BYTE, data);
}
diff --git a/texturesdl.cpp b/texturesdl.cpp
new file mode 100755
index 0000000..ea7d9ac
--- /dev/null
+++ b/texturesdl.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <stdexcept>
+#include <SDL_image/SDL_image.h>
+#include "texturesdl.h"
+
+TextureSDL::TextureSDL(const char* filename) {
+ SDL_Surface* image = IMG_Load(filename);
+
+ width = image->w;
+ height = image->h;
+ data = (unsigned char*)image->pixels;
+
+ build();
+
+ SDL_FreeSurface(image);
+}
diff --git a/texturesdl.h b/texturesdl.h
new file mode 100755
index 0000000..6b2eff2
--- /dev/null
+++ b/texturesdl.h
@@ -0,0 +1,8 @@
+#ifndef _TEXTURESDL_H_
+#define _TEXTURESDL_H_
+#include "texture.h"
+class TextureSDL : public Texture {
+ public:
+ TextureSDL(const char* filename);
+};
+#endif // _TEXTURESDL_H_