From 35094294df2e1b5fdb6fd63abd9f7c195b25c6da Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 1 Jul 2010 00:40:33 +0200 Subject: Added PointSprite-class. --- pointsprite.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pointsprite.cpp (limited to 'pointsprite.cpp') 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 -- cgit v1.2.3