summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-07-01 00:40:33 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-07-01 00:40:33 +0200
commit35094294df2e1b5fdb6fd63abd9f7c195b25c6da (patch)
tree18aab2e1efb8d98209f4701091a06989c500bf38
parentab8c1e0eeffedb0e5979874fba64b305effdb2d3 (diff)
Added PointSprite-class.HEADmaster
-rw-r--r--pointsprite.cpp24
-rw-r--r--pointsprite.h17
2 files changed, 41 insertions, 0 deletions
diff --git a/pointsprite.cpp b/pointsprite.cpp
new file mode 100644
index 0000000..85a61b9
--- /dev/null
+++ b/pointsprite.cpp
@@ -0,0 +1,24 @@
+#include "pointsprite.h"
+
+#include "SDL/SDL_opengl.h"
+
+PointSprite::PointSprite(float _size, const Texture& _texture) : texture(_texture) {
+ size = _size;
+}
+
+void PointSprite::draw(const Vector2& pos) const {
+ texture.bind();
+ glPointSize(size);
+
+ glBegin(GL_POINTS);
+ glVertex2f(pos.x, pos.y);
+ glEnd();
+}
+
+void PointSprite::draw_array(void* ptr, unsigned int coords, unsigned int stride, unsigned int first, unsigned int num) {
+ texture.bind();
+ glPointSize(size);
+
+ glVertexPointer(coords, GL_FLOAT, stride, ptr);
+ glDrawArrays(GL_POINTS, first, num);
+} \ No newline at end of file
diff --git a/pointsprite.h b/pointsprite.h
new file mode 100644
index 0000000..65a95d2
--- /dev/null
+++ b/pointsprite.h
@@ -0,0 +1,17 @@
+#ifndef POINTSPRITE_H
+#define POINTSPRITE_H
+
+#include "texture.h"
+#include "vector.h"
+
+class PointSprite {
+ public:
+ PointSprite(float _size, const Texture& _texture);
+ void draw(const Vector2& pos) const;
+ void draw_array(void* ptr, unsigned int coords, unsigned int stride, unsigned int first, unsigned int num);
+ private:
+ float size;
+ const Texture& texture;
+};
+
+#endif