mirror of
https://github.com/love2d/love.git
synced 2026-08-12 00:20:52 +02:00
Removed classes which should be implemented in Lua (or need of re-implementation).
This commit is contained in:
@@ -1,235 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "Animation.h"
|
||||
|
||||
// STD
|
||||
#include <cmath>
|
||||
|
||||
// LOVE
|
||||
#include <common/constants.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Animation::Animation(Image * image)
|
||||
: image(image), mode(1), current(0), playing(true),
|
||||
timeBuffer(0), direction(1), speed(1.0f)
|
||||
{
|
||||
image->retain();
|
||||
}
|
||||
|
||||
Animation::Animation(Image * image, float fw, float fh, float delay, int num)
|
||||
: image(image), mode(1), current(0), playing(true), timeBuffer(0), direction(1), speed(1.0f)
|
||||
{
|
||||
|
||||
image->retain();
|
||||
|
||||
// Generate frames.
|
||||
int w = (int)(image->getWidth()/fw);
|
||||
int h = (int)(image->getHeight()/fh);
|
||||
|
||||
int real_num = (num == 0) ? (w * h) : num;
|
||||
if(real_num > (w * h)) real_num = (w * h);
|
||||
|
||||
for(int i = 0;i<real_num;i++)
|
||||
{
|
||||
int x = (int)((i % w)*fw);
|
||||
int y = (int)((i/w)*fh);
|
||||
|
||||
addFrame((float)x, (float)y, fw, fh, delay);
|
||||
}
|
||||
}
|
||||
|
||||
Animation::~Animation()
|
||||
{
|
||||
if(image != 0)
|
||||
image->release();
|
||||
}
|
||||
|
||||
void Animation::addFrame(float x, float y, float w, float h, float delay)
|
||||
{
|
||||
// Add delay.
|
||||
delays.push_back(delay);
|
||||
|
||||
// Add frame.
|
||||
AnimationFrame f;
|
||||
f.x = x;
|
||||
f.y = y;
|
||||
f.w = w;
|
||||
f.h = h;
|
||||
f.postDelay = (int)delays.size() - 1;
|
||||
|
||||
frames.push_back(f);
|
||||
|
||||
if(frames.size() > 1)
|
||||
{
|
||||
frames.back().preDelay = frames[frames.size() - 2].postDelay;
|
||||
|
||||
// Update delay of first frame.
|
||||
frames.front().preDelay = frames.back().postDelay;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Animation::setMode(int mode)
|
||||
{
|
||||
this->mode = mode;
|
||||
}
|
||||
|
||||
void Animation::play()
|
||||
{
|
||||
playing = true;
|
||||
}
|
||||
|
||||
void Animation::stop()
|
||||
{
|
||||
playing = false;
|
||||
}
|
||||
|
||||
void Animation::reset()
|
||||
{
|
||||
current = 0;
|
||||
timeBuffer = 0;
|
||||
}
|
||||
|
||||
void Animation::seek(int frame)
|
||||
{
|
||||
if(frame >= 0 && frame < (int)frames.size())
|
||||
current = frame;
|
||||
}
|
||||
|
||||
int Animation::getCurrentFrame() const
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
int Animation::getSize() const
|
||||
{
|
||||
return (int)frames.size();
|
||||
}
|
||||
|
||||
void Animation::setDelay(int frame, float delay)
|
||||
{
|
||||
if(frame >= 0 && frame < (int)frames.size())
|
||||
delays[frames[0].postDelay] = delay;
|
||||
}
|
||||
|
||||
void Animation::setSpeed(float speed)
|
||||
{
|
||||
this->speed = speed;
|
||||
}
|
||||
|
||||
float Animation::getSpeed() const
|
||||
{
|
||||
return speed;
|
||||
}
|
||||
|
||||
void Animation::update(float dt)
|
||||
{
|
||||
if(!playing)
|
||||
return;
|
||||
|
||||
if(frames.size() <= 0)
|
||||
return;
|
||||
|
||||
timeBuffer += (dt * speed);
|
||||
|
||||
int next;
|
||||
float d;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case ANIMATION_LOOP:
|
||||
next = current;
|
||||
while(timeBuffer >= delays[frames[current].postDelay])
|
||||
{
|
||||
timeBuffer -= delays[frames[current].postDelay];
|
||||
if(++next >= (int)frames.size())
|
||||
next = 0;
|
||||
}
|
||||
current = next;
|
||||
break;
|
||||
case ANIMATION_PLAY_ONCE:
|
||||
next = current;
|
||||
while(timeBuffer >= delays[frames[current].postDelay])
|
||||
{
|
||||
timeBuffer -= delays[frames[current].postDelay];
|
||||
if(++next >= (int)frames.size())
|
||||
{
|
||||
next--;
|
||||
playing = false;
|
||||
timeBuffer = 0;
|
||||
}
|
||||
}
|
||||
current = next;
|
||||
break;
|
||||
case ANIMATION_BOUNCE:
|
||||
next = current;
|
||||
d = (direction == 1) ? delays[frames[next].postDelay] : delays[frames[next].preDelay];
|
||||
|
||||
while(timeBuffer >= d)
|
||||
{
|
||||
timeBuffer -= d;
|
||||
next += direction;
|
||||
if(next < 0 || next >= (int)frames.size())
|
||||
{
|
||||
direction *= -1;
|
||||
next += direction;
|
||||
}
|
||||
d = (direction == 1) ? delays[frames[next].postDelay] : delays[frames[next].preDelay];
|
||||
}
|
||||
current = next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Animation::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
||||
{
|
||||
if(frames.size() <= 0)
|
||||
return;
|
||||
|
||||
const AnimationFrame & f = frames[current];
|
||||
image->draws(x, y, angle, sx, sy, ox, oy, f.x, f.y, f.w, f.h);
|
||||
}
|
||||
|
||||
float Animation::getWidth() const
|
||||
{
|
||||
if(frames.size() <= 0)
|
||||
return 0;
|
||||
|
||||
return frames[current].w;
|
||||
}
|
||||
|
||||
float Animation::getHeight() const
|
||||
{
|
||||
if(frames.size() <= 0)
|
||||
return 0;
|
||||
|
||||
return frames[current].h;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_OPENGL_ANIMATION_H
|
||||
#define LOVE_OPENGL_ANIMATION_H
|
||||
|
||||
// LOVE
|
||||
#include "../Drawable.h"
|
||||
#include "Image.h"
|
||||
|
||||
// STD
|
||||
#include <vector>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
// Represents a single frame.
|
||||
struct AnimationFrame
|
||||
{
|
||||
float x, y; // Top left corner of the frame.
|
||||
float w, h; // Size of the frame.
|
||||
int preDelay; // Delay to previous frame.
|
||||
int postDelay; // Delay to next frame.
|
||||
};
|
||||
|
||||
class Animation : public Drawable
|
||||
{
|
||||
private:
|
||||
|
||||
// The source of the animation.
|
||||
Image * image;
|
||||
|
||||
// Delays between frames.
|
||||
// delays[0] is the delay between frames[0] and frames[1].
|
||||
std::vector<float> delays;
|
||||
|
||||
// Holds all the frames.
|
||||
std::vector<AnimationFrame> frames;
|
||||
|
||||
// Animation mode.
|
||||
int mode;
|
||||
|
||||
// The current frame.
|
||||
int current;
|
||||
|
||||
// True if playing, false otherwise.
|
||||
bool playing;
|
||||
|
||||
// "Left over"-time.
|
||||
float timeBuffer;
|
||||
|
||||
// Used for bounce mode.
|
||||
int direction;
|
||||
|
||||
// Overall speed. (1 = normal).
|
||||
float speed;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates an Animation with no frames.
|
||||
* @param image The image to use as the source.
|
||||
**/
|
||||
Animation(Image * image);
|
||||
|
||||
/**
|
||||
* Creates an Animation with frames from top-left to bottom right.
|
||||
* @param image The image to use as the source.
|
||||
* @param fw The width of each frame.
|
||||
* @param fh The height of each frame.
|
||||
* @param delay The delay after each frame.
|
||||
* @param num The number of frames. (0 = all)
|
||||
**/
|
||||
Animation(Image * image, float fw, float fh, float delay, int num = 0);
|
||||
|
||||
virtual ~Animation();
|
||||
|
||||
/**
|
||||
* Adds a single frame.
|
||||
* @param x The top-left corner of the frame.
|
||||
* @param y The top-right corner of the frame.
|
||||
* @param w The width of the frame.
|
||||
* @param h The height of the frame.
|
||||
* @param delay The delay after the frame.
|
||||
**/
|
||||
void addFrame(float x, float y, float w, float h, float delay);
|
||||
|
||||
/**
|
||||
* Sets the current animation mode, and reset.
|
||||
**/
|
||||
void setMode(int mode);
|
||||
|
||||
/**
|
||||
* Causes the Animation to start playing.
|
||||
**/
|
||||
void play();
|
||||
|
||||
/**
|
||||
* Causes the Animation to stop.
|
||||
**/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Resets the Animation.
|
||||
**/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Resets timebuffers, and sets the current frame directly.
|
||||
**/
|
||||
void seek(int frame);
|
||||
|
||||
/**
|
||||
* Gets the current frame.
|
||||
**/
|
||||
int getCurrentFrame() const;
|
||||
|
||||
/**
|
||||
* Gets amount of frames.
|
||||
**/
|
||||
int getSize() const;
|
||||
|
||||
/**
|
||||
* Sets the delay after a frame.
|
||||
**/
|
||||
void setDelay(int frame, float delay);
|
||||
|
||||
/**
|
||||
* Sets the overall animation speed.
|
||||
**/
|
||||
void setSpeed(float speed);
|
||||
|
||||
/**
|
||||
* Gets the overall animation speed.
|
||||
**/
|
||||
float getSpeed() const;
|
||||
|
||||
void update(float dt);
|
||||
|
||||
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
|
||||
|
||||
float getWidth() const;
|
||||
|
||||
float getHeight() const;
|
||||
};
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_OPENGL_ANIMATION_H
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "Color.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Color::Color()
|
||||
: red(255), green(255), blue(255), alpha(255)
|
||||
{
|
||||
}
|
||||
|
||||
Color::Color(int r, int g, int b, int a)
|
||||
: red(r), green(g), blue(b), alpha(a)
|
||||
{
|
||||
}
|
||||
|
||||
Color::~Color()
|
||||
{
|
||||
}
|
||||
|
||||
void Color::setRed(int red)
|
||||
{
|
||||
this->red = red;
|
||||
}
|
||||
|
||||
void Color::setGreen(int green)
|
||||
{
|
||||
this->green = green;
|
||||
}
|
||||
|
||||
void Color::setBlue(int blue)
|
||||
{
|
||||
this->blue = blue;
|
||||
}
|
||||
|
||||
void Color::setAlpha(int alpha)
|
||||
{
|
||||
this->alpha = alpha;
|
||||
}
|
||||
|
||||
int Color::getRed() const
|
||||
{
|
||||
return red;
|
||||
}
|
||||
|
||||
int Color::getGreen() const
|
||||
{
|
||||
return green;
|
||||
}
|
||||
|
||||
int Color::getBlue() const
|
||||
{
|
||||
return blue;
|
||||
}
|
||||
|
||||
int Color::getAlpha() const
|
||||
{
|
||||
return alpha;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_COLOR_H
|
||||
#define LOVE_GRAPHICS_OPENGL_COLOR_H
|
||||
|
||||
// LOVE
|
||||
#include <common/Object.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
/**
|
||||
* @author Michael Enger
|
||||
**/
|
||||
class Color : public Object
|
||||
{
|
||||
protected:
|
||||
|
||||
// Color components. (0-255)
|
||||
int red, green, blue, alpha;
|
||||
|
||||
public:
|
||||
|
||||
Color();
|
||||
|
||||
/**
|
||||
* Creates a new color with the specified component values.
|
||||
* Values must be unsigned bytes. (0-255).
|
||||
**/
|
||||
Color(int r, int g, int b, int a);
|
||||
|
||||
virtual ~Color();
|
||||
|
||||
/**
|
||||
* Sets the amount of red in the color.
|
||||
**/
|
||||
void setRed(int red);
|
||||
|
||||
/**
|
||||
* Sets the amount of green in the color.
|
||||
**/
|
||||
void setGreen(int green);
|
||||
|
||||
/**
|
||||
* Sets the amount of blue in the color.
|
||||
**/
|
||||
void setBlue(int blue);
|
||||
|
||||
/**
|
||||
* Sets the amount of alpha.
|
||||
**/
|
||||
void setAlpha(int alpha);
|
||||
|
||||
/**
|
||||
* Returns the amount of red in the color.
|
||||
**/
|
||||
int getRed() const;
|
||||
|
||||
/**
|
||||
* Returns the amount of green in the color.
|
||||
**/
|
||||
int getGreen() const;
|
||||
|
||||
/**
|
||||
* Returns the amount of blue in the color.
|
||||
**/
|
||||
int getBlue() const;
|
||||
|
||||
/**
|
||||
* Returns the amount of alpha.
|
||||
**/
|
||||
int getAlpha() const;
|
||||
|
||||
}; // Color
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_COLOR_H
|
||||
@@ -1,497 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "ParticleSystem.h"
|
||||
|
||||
#include <SDL_opengl.h>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
float calculate_variation(float inner, float outer, float var)
|
||||
{
|
||||
float low = inner - (outer/2.0f)*var;
|
||||
float high = inner + (outer/2.0f)*var;
|
||||
float r = (rand() / (float(RAND_MAX)+1));
|
||||
return low*(1-r)+high*r;
|
||||
}
|
||||
|
||||
|
||||
ParticleSystem::ParticleSystem(Image * sprite, unsigned int buffer) : pStart(0), pLast(0), pEnd(0), active(true), emissionRate(0),
|
||||
emitCounter(0), lifetime(-1), life(0), particleLifeMin(0), particleLifeMax(0),
|
||||
direction(0), spread(0), relative(false), speedMin(0), speedMax(0), gravityMin(0),
|
||||
gravityMax(0), radialAccelerationMin(0), radialAccelerationMax(0),
|
||||
tangentialAccelerationMin(0), tangentialAccelerationMax(0),
|
||||
sizeStart(1), sizeEnd(1), sizeVariation(0), rotationMin(0), rotationMax(0),
|
||||
spinStart(0), spinEnd(0), spinVariation(0)
|
||||
{
|
||||
this->sprite = sprite;
|
||||
sprite->retain();
|
||||
colorStart = Color(255, 255, 255, 255);
|
||||
colorEnd = Color(255, 255, 255, 255);
|
||||
setBufferSize(buffer);
|
||||
}
|
||||
|
||||
ParticleSystem::~ParticleSystem()
|
||||
{
|
||||
if(this->sprite != 0)
|
||||
{
|
||||
this->sprite->release();
|
||||
this->sprite = 0;
|
||||
}
|
||||
|
||||
if(pStart != 0)
|
||||
delete [] pStart;
|
||||
}
|
||||
|
||||
void ParticleSystem::add()
|
||||
{
|
||||
if(isFull()) return;
|
||||
|
||||
float min,max;
|
||||
|
||||
min = particleLifeMin;
|
||||
max = particleLifeMax;
|
||||
if(min == max)
|
||||
pLast->life = min;
|
||||
else
|
||||
pLast->life = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
pLast->lifetime = pLast->life;
|
||||
|
||||
pLast->position[0] = position.getX();
|
||||
pLast->position[1] = position.getY();
|
||||
|
||||
min = direction - spread/2.0f;
|
||||
max = direction + spread/2.0f;
|
||||
pLast->direction = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
|
||||
min = speedMin;
|
||||
max = speedMax;
|
||||
float speed = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
pLast->speed = love::Vector(cos(pLast->direction), sin(pLast->direction));
|
||||
pLast->speed *= speed;
|
||||
|
||||
min = gravityMin;
|
||||
max = gravityMax;
|
||||
pLast->gravity = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
|
||||
min = radialAccelerationMin;
|
||||
max = radialAccelerationMax;
|
||||
pLast->radialAcceleration = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
|
||||
min = tangentialAccelerationMin;
|
||||
max = tangentialAccelerationMax;
|
||||
pLast->tangentialAcceleration = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
|
||||
pLast->sizeStart = calculate_variation(sizeStart, sizeEnd, sizeVariation);
|
||||
pLast->sizeEnd = calculate_variation(sizeEnd, sizeStart, sizeVariation);
|
||||
pLast->size = pLast->sizeStart;
|
||||
|
||||
min = rotationMin;
|
||||
max = rotationMax;
|
||||
pLast->spinStart = calculate_variation(spinStart, spinEnd, spinVariation);
|
||||
pLast->spinEnd = calculate_variation(spinEnd, spinStart, spinVariation);
|
||||
pLast->rotation = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;;
|
||||
|
||||
pLast->color[0] = (float)colorStart.getRed() / 255;
|
||||
pLast->color[1] = (float)colorStart.getGreen() / 255;
|
||||
pLast->color[2] = (float)colorStart.getBlue() / 255;
|
||||
pLast->color[3] = (float)colorStart.getAlpha() / 255;
|
||||
|
||||
pLast++;
|
||||
}
|
||||
|
||||
void ParticleSystem::remove(particle * p)
|
||||
{
|
||||
if(!isEmpty())
|
||||
{
|
||||
*p = *(--pLast);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticleSystem::setSprite(Image * image)
|
||||
{
|
||||
if(this->sprite != 0)
|
||||
{
|
||||
this->sprite->release();
|
||||
this->sprite = 0;
|
||||
}
|
||||
|
||||
this->sprite = image;
|
||||
}
|
||||
|
||||
void ParticleSystem::setBufferSize(unsigned int size)
|
||||
{
|
||||
// delete previous data
|
||||
delete [] pStart;
|
||||
|
||||
pLast = pStart = new particle[size];
|
||||
|
||||
pEnd = pStart + size;
|
||||
}
|
||||
|
||||
void ParticleSystem::setEmissionRate(int rate)
|
||||
{
|
||||
emissionRate = rate;
|
||||
}
|
||||
|
||||
void ParticleSystem::setLifetime(float life)
|
||||
{
|
||||
this->life = lifetime = life;
|
||||
}
|
||||
|
||||
void ParticleSystem::setParticleLife(float min, float max)
|
||||
{
|
||||
particleLifeMin = min;
|
||||
if(max == 0)
|
||||
particleLifeMax = min;
|
||||
else
|
||||
particleLifeMax = max;
|
||||
}
|
||||
|
||||
void ParticleSystem::setPosition(float x, float y)
|
||||
{
|
||||
position = love::Vector(x, y);
|
||||
}
|
||||
|
||||
void ParticleSystem::setDirection(float direction)
|
||||
{
|
||||
this->direction = direction * LOVE_M_TORAD;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpread(float spread)
|
||||
{
|
||||
this->spread = spread * LOVE_M_TORAD;
|
||||
}
|
||||
|
||||
void ParticleSystem::setRelativeDirection(bool relative)
|
||||
{
|
||||
this->relative = relative;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpeed(float speed)
|
||||
{
|
||||
speedMin = speedMax = speed;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpeed(float min, float max)
|
||||
{
|
||||
speedMin = min;
|
||||
speedMax = max;
|
||||
}
|
||||
|
||||
void ParticleSystem::setGravity(float gravity)
|
||||
{
|
||||
gravityMin = gravityMax = gravity;
|
||||
}
|
||||
|
||||
void ParticleSystem::setGravity(float min, float max)
|
||||
{
|
||||
gravityMin = min;
|
||||
gravityMax = max;
|
||||
}
|
||||
|
||||
void ParticleSystem::setRadialAcceleration(float acceleration)
|
||||
{
|
||||
radialAccelerationMin = radialAccelerationMax = acceleration;
|
||||
}
|
||||
|
||||
void ParticleSystem::setRadialAcceleration(float min, float max)
|
||||
{
|
||||
radialAccelerationMin = min;
|
||||
radialAccelerationMax = max;
|
||||
}
|
||||
|
||||
void ParticleSystem::setTangentialAcceleration(float acceleration)
|
||||
{
|
||||
tangentialAccelerationMin = tangentialAccelerationMax = acceleration;
|
||||
}
|
||||
|
||||
void ParticleSystem::setTangentialAcceleration(float min, float max)
|
||||
{
|
||||
tangentialAccelerationMin = min;
|
||||
tangentialAccelerationMax = max;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSize(float size)
|
||||
{
|
||||
sizeStart = size;
|
||||
sizeEnd = size;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSize(float start, float end)
|
||||
{
|
||||
sizeStart = start;
|
||||
sizeEnd = end;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSize(float start, float end, float variation)
|
||||
{
|
||||
sizeStart = start;
|
||||
sizeEnd = end;
|
||||
sizeVariation = variation;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSizeVariation(float variation)
|
||||
{
|
||||
sizeVariation = variation;
|
||||
}
|
||||
|
||||
void ParticleSystem::setRotation(float rotation)
|
||||
{
|
||||
rotationMin = rotationMax = rotation;
|
||||
}
|
||||
|
||||
void ParticleSystem::setRotation(float min, float max)
|
||||
{
|
||||
rotationMin = min;
|
||||
rotationMax = max;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpin(float spin)
|
||||
{
|
||||
spinStart = spin * LOVE_M_TORAD;
|
||||
spinEnd = spin * LOVE_M_TORAD;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpin(float start, float end)
|
||||
{
|
||||
spinStart = start * LOVE_M_TORAD;
|
||||
spinEnd = end * LOVE_M_TORAD;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpin(float start, float end, float variation)
|
||||
{
|
||||
spinStart = start * LOVE_M_TORAD;
|
||||
spinEnd = end * LOVE_M_TORAD;
|
||||
spinVariation = variation * LOVE_M_TORAD;
|
||||
}
|
||||
|
||||
void ParticleSystem::setSpinVariation(float variation)
|
||||
{
|
||||
spinVariation = variation * LOVE_M_TORAD;
|
||||
}
|
||||
|
||||
void ParticleSystem::setColor(Color * color)
|
||||
{
|
||||
colorStart = *color;
|
||||
colorEnd = *color;
|
||||
}
|
||||
|
||||
void ParticleSystem::setColor(Color * start, Color * end)
|
||||
{
|
||||
colorStart = *start;
|
||||
colorEnd = *end;
|
||||
}
|
||||
|
||||
float ParticleSystem::getX() const
|
||||
{
|
||||
return position.getX();
|
||||
}
|
||||
|
||||
float ParticleSystem::getY() const
|
||||
{
|
||||
return position.getY();
|
||||
}
|
||||
|
||||
float ParticleSystem::getDirection() const
|
||||
{
|
||||
return direction * LOVE_M_TODEG;
|
||||
}
|
||||
|
||||
float ParticleSystem::getSpread() const
|
||||
{
|
||||
return spread * LOVE_M_TODEG;
|
||||
}
|
||||
|
||||
int ParticleSystem::count() const
|
||||
{
|
||||
return (int)(pLast - pStart);
|
||||
}
|
||||
|
||||
void ParticleSystem::start()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
|
||||
void ParticleSystem::stop()
|
||||
{
|
||||
active = false;
|
||||
life = lifetime;
|
||||
emitCounter = 0;
|
||||
}
|
||||
|
||||
void ParticleSystem::pause()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
|
||||
void ParticleSystem::reset()
|
||||
{
|
||||
pLast = pStart;
|
||||
life = lifetime;
|
||||
emitCounter = 0;
|
||||
}
|
||||
|
||||
bool ParticleSystem::isActive() const
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
bool ParticleSystem::isEmpty() const
|
||||
{
|
||||
return pStart == pLast;
|
||||
}
|
||||
|
||||
bool ParticleSystem::isFull() const
|
||||
{
|
||||
return pLast == pEnd;
|
||||
}
|
||||
|
||||
void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
||||
{
|
||||
if(sprite == 0) return; // just in case of failure
|
||||
|
||||
glPushMatrix();
|
||||
glPushAttrib(GL_CURRENT_BIT);
|
||||
|
||||
glTranslatef(x, y, 0);
|
||||
glRotatef(angle, 0, 0, 1.0f);
|
||||
glScalef(sx, sy, 1.0f);
|
||||
glTranslatef( ox, oy, 0);
|
||||
|
||||
particle * p = pStart;
|
||||
while(p != pLast)
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
glColor4f(p->color[0],p->color[1],p->color[2],p->color[3]);
|
||||
glTranslatef(p->position[0],p->position[1],0.0f);
|
||||
glRotatef(p->rotation * 57.29578f, 0.0f, 0.0f, 1.0f); // rad * (180 / pi)
|
||||
glScalef(p->size,p->size,1.0f);
|
||||
sprite->draw(0,0, 0, 1, 1, 0, 0);
|
||||
|
||||
glPopMatrix();
|
||||
p++;
|
||||
}
|
||||
|
||||
glPopAttrib();
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void ParticleSystem::update(float dt)
|
||||
{
|
||||
// Traverse all particles and update.
|
||||
particle * p = pStart;
|
||||
|
||||
// Make some more particles.
|
||||
if(active)
|
||||
{
|
||||
float rate = 1.0f / emissionRate; // the amount of time between each particle emit
|
||||
emitCounter += dt;
|
||||
while(emitCounter > rate)
|
||||
{
|
||||
add();
|
||||
emitCounter -= rate;
|
||||
}
|
||||
/*int particles = (int)(emissionRate * dt);
|
||||
for(int i = 0; i != particles; i++)
|
||||
add();*/
|
||||
|
||||
life -= dt;
|
||||
if(lifetime != -1 && life < 0)
|
||||
stop();
|
||||
}
|
||||
|
||||
while(p != pLast)
|
||||
{
|
||||
// Decrease lifespan.
|
||||
p->life -= dt;
|
||||
|
||||
if(p->life > 0)
|
||||
{
|
||||
|
||||
// Temp variables.
|
||||
love::Vector radial, tangential, gravity(0, p->gravity);
|
||||
love::Vector ppos(p->position[0], p->position[1]);
|
||||
|
||||
// Get vector from particle center to particle.
|
||||
radial = ppos - position;
|
||||
radial.normalize();
|
||||
tangential = radial;
|
||||
|
||||
// Resize radial acceleration.
|
||||
radial *= p->radialAcceleration;
|
||||
|
||||
// Calculate tangential acceleration.
|
||||
{
|
||||
float a = tangential.getX();
|
||||
tangential.setX(-tangential.getY());
|
||||
tangential.setY(a);
|
||||
}
|
||||
|
||||
// Resize tangential.
|
||||
tangential *= p->tangentialAcceleration;
|
||||
|
||||
// Update position.
|
||||
p->speed += (radial+tangential+gravity)*dt;
|
||||
|
||||
// Modify position.
|
||||
ppos += p->speed * dt;
|
||||
|
||||
p->position[0] = ppos.getX();
|
||||
p->position[1] = ppos.getY();
|
||||
|
||||
const float t = p->life / p->lifetime;
|
||||
|
||||
// Change size.
|
||||
p->size = p->sizeEnd - ((p->sizeEnd - p->sizeStart) * t);
|
||||
|
||||
// Rotate.
|
||||
p->rotation += (p->spinStart*(1-t) + p->spinEnd*t)*dt;
|
||||
|
||||
// Update color.
|
||||
p->color[0] = (float)(colorEnd.getRed()*(1.0f-t) + colorStart.getRed() * t)/255.0f;
|
||||
p->color[1] = (float)(colorEnd.getGreen()*(1.0f-t) + colorStart.getGreen() * t)/255.0f;
|
||||
p->color[2] = (float)(colorEnd.getBlue()*(1.0f-t) + colorStart.getBlue() * t)/255.0f;
|
||||
p->color[3] = (float)(colorEnd.getAlpha()*(1.0f-t) + colorStart.getAlpha() * t)/255.0f;
|
||||
|
||||
// Next particle.
|
||||
p++;
|
||||
}
|
||||
else
|
||||
{
|
||||
remove(p);
|
||||
|
||||
if(p >= pLast)
|
||||
return;
|
||||
} // else
|
||||
} // while
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,432 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_PARTICLE_SYSTEM_H
|
||||
#define LOVE_GRAPHICS_OPENGL_PARTICLE_SYSTEM_H
|
||||
|
||||
// LOVE
|
||||
|
||||
#include <common/math.h>
|
||||
#include <common/Vector.h>
|
||||
#include <common/constants.h>
|
||||
#include <graphics/Drawable.h>
|
||||
|
||||
#include "Color.h"
|
||||
#include "Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
// Represents a single particle.
|
||||
struct particle
|
||||
{
|
||||
float lifetime;
|
||||
float life;
|
||||
|
||||
float position[2];
|
||||
float direction;
|
||||
|
||||
love::Vector speed;
|
||||
float gravity;
|
||||
float radialAcceleration;
|
||||
float tangentialAcceleration;
|
||||
|
||||
float size;
|
||||
float sizeStart;
|
||||
float sizeEnd;
|
||||
|
||||
float rotation;
|
||||
float spinStart;
|
||||
float spinEnd;
|
||||
|
||||
float color[4];
|
||||
};
|
||||
|
||||
/**
|
||||
* A class for creating, moving and drawing particles.
|
||||
* A big thanks to bobthebloke.org
|
||||
**/
|
||||
class ParticleSystem : public Drawable
|
||||
{
|
||||
protected:
|
||||
|
||||
// The max amount of particles.
|
||||
unsigned int bufferSize;
|
||||
|
||||
// Pointer to the first particle.
|
||||
particle * pStart;
|
||||
|
||||
// Pointer to the next available free space.
|
||||
particle * pLast;
|
||||
|
||||
// Pointer to the end of the memory allocation.
|
||||
particle * pEnd;
|
||||
|
||||
// The sprite to be drawn.
|
||||
Image * sprite;
|
||||
|
||||
// Whether the particle emitter is active.
|
||||
bool active;
|
||||
|
||||
// The emission rate (particles/sec).
|
||||
int emissionRate;
|
||||
|
||||
// Used to determine when a particle should be emitted.
|
||||
float emitCounter;
|
||||
|
||||
// The relative position of the particle emitter.
|
||||
love::Vector position;
|
||||
|
||||
// The lifetime of the particle emitter (-1 means infinite) and the life it has left.
|
||||
float lifetime;
|
||||
float life;
|
||||
|
||||
// The particle life.
|
||||
float particleLifeMin;
|
||||
float particleLifeMax;
|
||||
|
||||
// The direction (and spread) the particles will be emitted in. Measured in radians.
|
||||
float direction;
|
||||
float spread;
|
||||
|
||||
// Whether the direction should be relative to the emitter's movement.
|
||||
bool relative;
|
||||
|
||||
// The speed.
|
||||
float speedMin;
|
||||
float speedMax;
|
||||
|
||||
// Acceleration towards the bottom of the screen
|
||||
float gravityMin;
|
||||
float gravityMax;
|
||||
|
||||
// Acceleration towards the emitter's center
|
||||
float radialAccelerationMin;
|
||||
float radialAccelerationMax;
|
||||
|
||||
// Acceleration perpendicular to the particle's direction.
|
||||
float tangentialAccelerationMin;
|
||||
float tangentialAccelerationMax;
|
||||
|
||||
// Size.
|
||||
float sizeStart;
|
||||
float sizeEnd;
|
||||
float sizeVariation;
|
||||
|
||||
// Rotation
|
||||
float rotationMin;
|
||||
float rotationMax;
|
||||
|
||||
// Spin.
|
||||
float spinStart;
|
||||
float spinEnd;
|
||||
float spinVariation;
|
||||
|
||||
// Color.
|
||||
Color colorStart;
|
||||
Color colorEnd;
|
||||
|
||||
void add();
|
||||
void remove(particle * p);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a particle system with the specified buffersize and sprite.
|
||||
**/
|
||||
ParticleSystem(Image * sprite, unsigned int buffer);
|
||||
|
||||
/**
|
||||
* Deletes any allocated memory.
|
||||
**/
|
||||
virtual ~ParticleSystem();
|
||||
|
||||
/**
|
||||
* Sets the sprite used in the particle system.
|
||||
* @param sprite The new sprite.
|
||||
**/
|
||||
void setSprite(Image * image);
|
||||
|
||||
/**
|
||||
* Clears the current buffer and allocates the appropriate amount of space for the buffer.
|
||||
* @param size The new buffer size.
|
||||
**/
|
||||
void setBufferSize(unsigned int size);
|
||||
|
||||
/**
|
||||
* Sets the emission rate.
|
||||
* @param rate The amount of particles per second.
|
||||
**/
|
||||
void setEmissionRate(int rate);
|
||||
|
||||
/**
|
||||
* Sets the lifetime of the particle emitter (-1 means eternal)
|
||||
* @param life The lifetime (in seconds).
|
||||
**/
|
||||
void setLifetime(float life);
|
||||
|
||||
/**
|
||||
* Sets the life range of the particles.
|
||||
* @param lifeMin The minimum life.
|
||||
* @param lifeMax The maximum life (if 0, then becomes the same as minimum life).
|
||||
**/
|
||||
void setParticleLife(float min, float max = 0);
|
||||
|
||||
/**
|
||||
* Sets the position of the center of the emitter and the direction (if set to relative).
|
||||
* Used to move the emitter without changing the position of already existing particles.
|
||||
* @param x The x-coordinate.
|
||||
* @param y The y-coordinate.
|
||||
**/
|
||||
void setPosition(float x, float y);
|
||||
|
||||
/**
|
||||
* Sets the direction and the spread of the particle emitter.
|
||||
* @param direction The direction (in degrees).
|
||||
**/
|
||||
void setDirection(float direction);
|
||||
|
||||
/**
|
||||
* Sets the spread of the particle emitter.
|
||||
* @param spread The spread (in degrees).
|
||||
**/
|
||||
void setSpread(float spread);
|
||||
|
||||
/**
|
||||
* Sets whether the direction should be relative to the particle emitters movement. Used in conjunction with setPosition.
|
||||
* @param relative Whether to have relative direction.
|
||||
**/
|
||||
void setRelativeDirection(bool relative);
|
||||
|
||||
/**
|
||||
* Sets the speed of the particles.
|
||||
* @param speed The speed.
|
||||
**/
|
||||
void setSpeed(float speed);
|
||||
|
||||
/**
|
||||
* Sets the speed of the particles.
|
||||
* @param min The minimum speed.
|
||||
* @param max The maximum speed.
|
||||
**/
|
||||
void setSpeed(float min, float max);
|
||||
|
||||
/**
|
||||
* Sets the gravity of the particles (the acceleration along the y-axis).
|
||||
* @param gravity The amount of gravity.
|
||||
**/
|
||||
void setGravity(float gravity);
|
||||
|
||||
/**
|
||||
* Sets the gravity of the particles (the acceleration along the y-axis).
|
||||
* @param min The minimum gravity.
|
||||
* @param max The maximum gravity.
|
||||
**/
|
||||
void setGravity(float min, float max);
|
||||
|
||||
/**
|
||||
* Sets the radial acceleration (the acceleration towards the particle emitter).
|
||||
* @param acceleration The amount of acceleration.
|
||||
**/
|
||||
void setRadialAcceleration(float acceleration);
|
||||
|
||||
/**
|
||||
* Sets the radial acceleration (the acceleration towards the particle emitter).
|
||||
* @param min The minimum acceleration.
|
||||
* @param max The maximum acceleration.
|
||||
**/
|
||||
void setRadialAcceleration(float min, float max);
|
||||
|
||||
/**
|
||||
* Sets the tangential acceleration (the acceleration perpendicular to the particle's direction).
|
||||
* @param acceleration The amount of acceleration.
|
||||
**/
|
||||
void setTangentialAcceleration(float acceleration);
|
||||
|
||||
/**
|
||||
* Sets the tangential acceleration (the acceleration perpendicular to the particle's direction).
|
||||
* @param min The minimum acceleration.
|
||||
* @param max The maximum acceleration.
|
||||
**/
|
||||
void setTangentialAcceleration(float min, float max);
|
||||
|
||||
/**
|
||||
* Sets the size of the sprite (1.0 being the default size).
|
||||
* @param size The size of the sprite.
|
||||
**/
|
||||
void setSize(float size);
|
||||
|
||||
/**
|
||||
* Sets the size of the sprite upon creation and upon death (1.0 being the default size).
|
||||
* @param start The size of the sprite upon creation
|
||||
* @param end The size of the sprite upon death.
|
||||
**/
|
||||
void setSize(float start, float end);
|
||||
|
||||
/**
|
||||
* Sets the size of the sprite upon creation and upon death (1.0 being the default size) and any variation.
|
||||
* @param start The size of the sprite upon creation
|
||||
* @param end The size of the sprite upon death.
|
||||
* @param variation The amount of variation on the starting size (0 being no variation and 1.0 a random size between start and end).
|
||||
**/
|
||||
void setSize(float start, float end, float variation);
|
||||
|
||||
/**
|
||||
* Sets the amount of variation to the sprite's beginning size (0 being no variation and 1.0 a random size between start and end).
|
||||
* @param variation The amount of variation.
|
||||
**/
|
||||
void setSizeVariation(float variation);
|
||||
|
||||
/**
|
||||
* Sets the amount of rotation a sprite starts out with.
|
||||
* @param rotation The amount of rotation.
|
||||
**/
|
||||
void setRotation(float rotation);
|
||||
|
||||
/**
|
||||
* Sets the amount of rotation a sprite starts out with (a random value between min and max).
|
||||
* @param min The minimum amount of rotation.
|
||||
* @param max The maximum amount of rotation.
|
||||
**/
|
||||
void setRotation(float min, float max);
|
||||
|
||||
/**
|
||||
* Sets the spin of the sprite.
|
||||
* @param spin The spin of the sprite (in degrees).
|
||||
**/
|
||||
void setSpin(float spin);
|
||||
|
||||
/**
|
||||
* Sets the spin of the sprite upon particle creation and death.
|
||||
* @param start The spin of the sprite upon creation (in degrees).
|
||||
* @param end The spin of the sprite upon death (in degrees).
|
||||
**/
|
||||
void setSpin(float start, float end);
|
||||
|
||||
/**
|
||||
* Sets the spin of the sprite upon particle creation and death and the variation.
|
||||
* @param start The spin of the sprite upon creation (in degrees).
|
||||
* @param end The spin of the sprite upon death (in degrees).
|
||||
* @param variation The variation of the start spin (0 being no variation and 1 beign a random spin between start and end).
|
||||
**/
|
||||
void setSpin(float start, float end, float variation);
|
||||
|
||||
/**
|
||||
* Sets the variation of the start spin (0 being no variation and 1 beign a random spin between start and end).
|
||||
* @param variation The variation in degrees.
|
||||
**/
|
||||
void setSpinVariation(float variation);
|
||||
|
||||
/**
|
||||
* Sets the color of the particles.
|
||||
* @param color The color.
|
||||
**/
|
||||
void setColor(Color * color);
|
||||
|
||||
/**
|
||||
* Sets the color of the particles.
|
||||
* @param start The color of the particle when created.
|
||||
* @param end The color of the particle upon death.
|
||||
**/
|
||||
void setColor(Color * start, Color * end);
|
||||
|
||||
/**
|
||||
* Returns the x-coordinate of the emitter's position.
|
||||
**/
|
||||
float getX() const;
|
||||
|
||||
/**
|
||||
* Returns the y-coordinate of the emitter's position.
|
||||
**/
|
||||
float getY() const;
|
||||
|
||||
/**
|
||||
* Returns the direction of the emitter (in degrees).
|
||||
**/
|
||||
float getDirection() const;
|
||||
|
||||
/**
|
||||
* Returns the directional spread of the emitter (in degrees).
|
||||
**/
|
||||
float getSpread() const;
|
||||
|
||||
/**
|
||||
* Returns the amount of particles that are currently active in the system.
|
||||
**/
|
||||
int count() const;
|
||||
|
||||
/**
|
||||
* Starts/resumes the particle emitter.
|
||||
**/
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Stops the particle emitter and resets.
|
||||
**/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Pauses the particle emitter.
|
||||
**/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Resets the particle emitter.
|
||||
**/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Returns whether the particle emitter is active.
|
||||
**/
|
||||
bool isActive() const;
|
||||
|
||||
/**
|
||||
* Returns whether the particle system is empty of particles or not.
|
||||
**/
|
||||
bool isEmpty() const;
|
||||
|
||||
/**
|
||||
* Returns whether the amount of particles has reached the buffer limit or not.
|
||||
**/
|
||||
bool isFull() const;
|
||||
|
||||
/**
|
||||
* Draws the particle emitter at the specified position.
|
||||
* @param x The x-coordinate.
|
||||
* @param y The y-coordinate.
|
||||
**/
|
||||
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
|
||||
|
||||
/**
|
||||
* Updates the particle system.
|
||||
* @param dt Time since last update.
|
||||
**/
|
||||
void update(float dt);
|
||||
};
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_PARTICLE_SYSTEM_H
|
||||
@@ -1,111 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "SpriteBatch.h"
|
||||
|
||||
// STD
|
||||
#include <iostream>
|
||||
|
||||
// LOVE
|
||||
#include "VertexBuffer.h"
|
||||
#include "Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
SpriteBatch::SpriteBatch(Image * image, int size, int usage)
|
||||
: size(size), next(0)
|
||||
{
|
||||
// Four vertices in one sprite.
|
||||
buffer = new VertexBuffer(image, size*6, TYPE_TRIANGLES, usage);
|
||||
}
|
||||
|
||||
SpriteBatch::~SpriteBatch()
|
||||
{
|
||||
buffer->release();
|
||||
}
|
||||
|
||||
void SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, float oy)
|
||||
{
|
||||
// Only do this if there's a free slot.
|
||||
if(next < size)
|
||||
{
|
||||
// Get a pointer to the correct insertion position.
|
||||
vertex * v = buffer->vertices + next*6;
|
||||
|
||||
// Fill vertices with ones (for white colors).
|
||||
memset(v, 0xff, sizeof(vertex)*6);
|
||||
|
||||
// Half-sizes.
|
||||
float w2 = buffer->image->getWidth()/2.0f;
|
||||
float h2 = buffer->image->getHeight()/2.0f;
|
||||
|
||||
// MASSIVE TODO: just copy vertices from image.
|
||||
|
||||
v[0].x = -w2; v[0].y = -h2;
|
||||
v[1].x = -w2; v[1].y = h2;
|
||||
v[2].x = w2; v[2].y = h2;
|
||||
v[3].x = w2; v[3].y = -h2;
|
||||
|
||||
v[0].s = 0; v[0].t = 0;
|
||||
v[1].s = 0; v[1].t = 1;
|
||||
v[2].s = 1; v[2].t = 1;
|
||||
v[3].s = 1; v[3].t = 0;
|
||||
|
||||
// Transform.
|
||||
Matrix t;
|
||||
t.translate(x, y);
|
||||
t.scale(sx, sy);
|
||||
t.rotate(a);
|
||||
t.transform(v, v, 4);
|
||||
|
||||
v[5] = v[3];
|
||||
v[4] = v[2];
|
||||
v[3] = v[0];
|
||||
|
||||
// Send the buffer to the GPU.
|
||||
buffer->update(next*6, 6);
|
||||
|
||||
// Increment counter.
|
||||
next++;
|
||||
}
|
||||
}
|
||||
|
||||
void SpriteBatch::clear()
|
||||
{
|
||||
// Reset the position of the next index.
|
||||
next = 0;
|
||||
|
||||
// Also reset the buffer.
|
||||
buffer->clear();
|
||||
}
|
||||
|
||||
void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
||||
{
|
||||
// Let the buffer handle this.
|
||||
buffer->draw(x, y, angle, sx, sy, ox, oy);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
#define LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
|
||||
// C
|
||||
#include <cstring>
|
||||
|
||||
// LOVE
|
||||
#include <common/math.h>
|
||||
#include <common/Object.h>
|
||||
#include <common/Vector.h>
|
||||
#include <common/Matrix.h>
|
||||
#include <graphics/Drawable.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
// Forward declarations.
|
||||
class VertexBuffer;
|
||||
class Image;
|
||||
|
||||
class SpriteBatch : public Drawable
|
||||
{
|
||||
private:
|
||||
|
||||
// Max number of sprites in the batch.
|
||||
int size;
|
||||
|
||||
// The next free element.
|
||||
int next;
|
||||
|
||||
// Vertex Buffer.
|
||||
VertexBuffer * buffer;
|
||||
|
||||
public:
|
||||
|
||||
SpriteBatch(Image * image, int size, int usage);
|
||||
virtual ~SpriteBatch();
|
||||
|
||||
void add(float x, float y, float a, float sx, float sy, float ox, float oy);
|
||||
void clear();
|
||||
|
||||
// Implements Drawable.
|
||||
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
|
||||
|
||||
}; // SpriteBatch
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
@@ -1,188 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
VertexBuffer::VertexBuffer(Image * image, int size, int type, int usage)
|
||||
: size(size), next(0), image(image), vbo_buf(0), type(type), gl_type(0), usage(usage), gl_usage(0)
|
||||
{
|
||||
if(image != 0)
|
||||
image->retain();
|
||||
|
||||
vertices = new vertex[size];
|
||||
|
||||
// If VBOs aren't supported, then we must use vertex arrays.
|
||||
if(!GLEE_ARB_vertex_buffer_object)
|
||||
usage = USAGE_ARRAY;
|
||||
|
||||
// Find out which OpenGL VBO usage hint to use.
|
||||
gl_usage = (usage == USAGE_DYNAMIC) ? GL_DYNAMIC_DRAW : gl_usage;
|
||||
gl_usage = (usage == USAGE_STATIC) ? GL_STATIC_DRAW : gl_usage;
|
||||
gl_usage = (usage == USAGE_STREAM) ? GL_STREAM_DRAW : gl_usage;
|
||||
|
||||
setType(type);
|
||||
|
||||
if(useVBO())
|
||||
{
|
||||
glGenBuffers(1, &vbo_buf);
|
||||
if(vbo_buf != 0)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_buf);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex)*size, vertices, gl_usage);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
else // FAIL. Use vertex arrays instead.
|
||||
usage = USAGE_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
VertexBuffer::~VertexBuffer()
|
||||
{
|
||||
if(image != 0)
|
||||
image->release();
|
||||
|
||||
delete [] vertices;
|
||||
|
||||
if(useVBO() && vbo_buf != 0)
|
||||
glDeleteBuffers(1, &vbo_buf);
|
||||
}
|
||||
|
||||
bool VertexBuffer::useVBO() const
|
||||
{
|
||||
return usage >= USAGE_DYNAMIC;
|
||||
}
|
||||
|
||||
void VertexBuffer::update(int pos, int size)
|
||||
{
|
||||
// Update VBO.
|
||||
if(useVBO())
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_buf);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, pos*sizeof(vertex), sizeof(vertex)*size, &vertices[pos]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
// ... no need to update vertex arrays.
|
||||
|
||||
next += size;
|
||||
}
|
||||
|
||||
void VertexBuffer::setType(int type)
|
||||
{
|
||||
this->type = type;
|
||||
// Find out which OpenGL primitive type to use.
|
||||
gl_type = (type == TYPE_POINTS) ? GL_POINTS : gl_type;
|
||||
gl_type = (type == TYPE_LINES) ? GL_LINES : gl_type;
|
||||
gl_type = (type == TYPE_LINE_STRIP) ? GL_LINE_STRIP : gl_type;
|
||||
gl_type = (type == TYPE_TRIANGLES) ? GL_TRIANGLES : gl_type;
|
||||
gl_type = (type == TYPE_TRIANGLE_STRIP) ? GL_TRIANGLE_STRIP : gl_type;
|
||||
gl_type = (type == TYPE_TRIANGLE_FAN) ? GL_TRIANGLE_FAN : gl_type;
|
||||
}
|
||||
|
||||
int VertexBuffer::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
void VertexBuffer::add(float x, float y, float s, float t, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
{
|
||||
// Only do this if there's a free slot.
|
||||
if(next < size)
|
||||
{
|
||||
vertex & e = vertices[next];
|
||||
|
||||
e.x = x;
|
||||
e.y = y;
|
||||
e.s = s;
|
||||
e.t = t;
|
||||
e.r = r;
|
||||
e.g = g;
|
||||
e.b = b;
|
||||
e.a = a;
|
||||
|
||||
update(next, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void VertexBuffer::add(float x, float y, float s, float t)
|
||||
{
|
||||
add(x, y, s, y, 255, 255, 255, 255);
|
||||
}
|
||||
|
||||
void VertexBuffer::clear()
|
||||
{
|
||||
// Reset the position of the next index.
|
||||
next = 0;
|
||||
}
|
||||
|
||||
void VertexBuffer::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(x, y, 0);
|
||||
|
||||
if(image == 0)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
else
|
||||
image->bind();
|
||||
|
||||
// Enable vertex arrays.
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
if(useVBO())
|
||||
{
|
||||
// Bind the VBO buffer.
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_buf);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid*)0);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)(sizeof(unsigned char)*4));
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)(sizeof(unsigned char)*4+sizeof(float)*2));
|
||||
glDrawArrays(gl_type, 0, next);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid*)&vertices[0].r);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].x);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].s);
|
||||
glDrawArrays(gl_type, 0, next);
|
||||
}
|
||||
|
||||
// Disable vertex arrays.
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
// Enable textures again.
|
||||
if(image == 0)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
#define LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
|
||||
// LOVE
|
||||
#include <common/constants.h>
|
||||
#include <common/math.h>
|
||||
#include <common/Object.h>
|
||||
#include <common/Vector.h>
|
||||
#include <common/Matrix.h>
|
||||
#include <graphics/Drawable.h>
|
||||
|
||||
// Module.
|
||||
#include "Image.h"
|
||||
|
||||
// OpenGL
|
||||
#include "GLee.h"
|
||||
#include <SDL/SDL_opengl.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
class VertexBuffer : public Drawable
|
||||
{
|
||||
friend class SpriteBatch;
|
||||
private:
|
||||
|
||||
vertex * vertices;
|
||||
|
||||
// Max number of vertices in the buffer.
|
||||
int size;
|
||||
|
||||
// The next free element.
|
||||
int next;
|
||||
|
||||
// The texture (optional).
|
||||
Image * image;
|
||||
|
||||
// Contains the vbo_buffer.
|
||||
GLuint vbo_buf;
|
||||
|
||||
// The uage hint for the vertex buffer.
|
||||
int usage;
|
||||
int gl_usage;
|
||||
|
||||
// The type of primitives we're drawing.
|
||||
int type;
|
||||
int gl_type;
|
||||
|
||||
private:
|
||||
|
||||
bool useVBO() const;
|
||||
void update(int pos, int size);
|
||||
|
||||
public:
|
||||
|
||||
VertexBuffer(Image * image, int size, int type, int usage);
|
||||
virtual ~VertexBuffer();
|
||||
|
||||
void setType(int type);
|
||||
int getType() const;
|
||||
|
||||
void add(float x, float y, float s, float t, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
void add(float x, float y, float s, float t);
|
||||
void clear();
|
||||
|
||||
// Implements Drawable.
|
||||
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
|
||||
|
||||
}; // VertexBuffer
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
@@ -1,161 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
// LOVE
|
||||
#include "wrap_Animation.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Animation * luax_checkanimation(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Animation>(L, idx, "Animation", LOVE_GRAPHICS_ANIMATION_BITS);
|
||||
}
|
||||
|
||||
int _wrap_Animation_addFrame(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float w = (float)luaL_checknumber(L, 4);
|
||||
float h = (float)luaL_checknumber(L, 5);
|
||||
float d = (float)luaL_checknumber(L, 6);
|
||||
t->addFrame(x, y, w, h, d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_play(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
t->play();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_stop(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
t->stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_reset(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
t->reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_seek(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
int frame = luaL_checkint(L, 2);
|
||||
t->seek(frame);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_getCurrentFrame(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
lua_pushnumber(L, t->getCurrentFrame());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Animation_getSize(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
lua_pushnumber(L, t->getSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Animation_setDelay(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
int frame = luaL_checkint(L, 2);
|
||||
float delay = (float)luaL_checknumber(L, 3);
|
||||
t->setDelay(frame, delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_setSpeed(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
float speed = (float)luaL_checknumber(L, 2);
|
||||
t->setSpeed(speed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_getSpeed(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
lua_pushnumber(L, t->getSpeed());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Animation_update(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
float dt = (float)luaL_checknumber(L, 2);
|
||||
t->update(dt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Animation_getWidth(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
lua_pushnumber(L, t->getWidth());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Animation_getHeight(lua_State * L)
|
||||
{
|
||||
Animation * t = luax_checkanimation(L, 1);
|
||||
lua_pushnumber(L, t->getHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg wrap_Animation_functions[] = {
|
||||
{ "addFrame", _wrap_Animation_addFrame },
|
||||
{ "play", _wrap_Animation_play },
|
||||
{ "stop", _wrap_Animation_stop },
|
||||
{ "reset", _wrap_Animation_reset },
|
||||
{ "seek", _wrap_Animation_seek },
|
||||
{ "getCurrentFrame", _wrap_Animation_getCurrentFrame },
|
||||
{ "getSize", _wrap_Animation_getSize },
|
||||
{ "setDelay", _wrap_Animation_setDelay },
|
||||
{ "setSpeed", _wrap_Animation_setSpeed },
|
||||
{ "getSpeed", _wrap_Animation_getSpeed },
|
||||
{ "update", _wrap_Animation_update },
|
||||
{ "getWidth", _wrap_Animation_getWidth },
|
||||
{ "getHeight", _wrap_Animation_getHeight },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_Animation_open(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "Animation", wrap_Animation_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_ANIMATION_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_ANIMATION_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Animation.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Animation * luax_checkanimation(lua_State * L, int idx);
|
||||
int _wrap_Animation_addFrame(lua_State * L);
|
||||
int _wrap_Animation_play(lua_State * L);
|
||||
int _wrap_Animation_stop(lua_State * L);
|
||||
int _wrap_Animation_reset(lua_State * L);
|
||||
int _wrap_Animation_seek(lua_State * L);
|
||||
int _wrap_Animation_getCurrentFrame(lua_State * L);
|
||||
int _wrap_Animation_getSize(lua_State * L);
|
||||
int _wrap_Animation_setDelay(lua_State * L);
|
||||
int _wrap_Animation_setSpeed(lua_State * L);
|
||||
int _wrap_Animation_getSpeed(lua_State * L);
|
||||
int _wrap_Animation_update(lua_State * L);
|
||||
int _wrap_Animation_getWidth(lua_State * L);
|
||||
int _wrap_Animation_getHeight(lua_State * L);
|
||||
int wrap_Animation_open(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_ANIMATION_H
|
||||
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
// LOVE
|
||||
#include "wrap_Color.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
// This macro makes checking for the correct type slightly more compact.
|
||||
Color * luax_checkcolor(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Color>(L, idx, "Color", LOVE_GRAPHICS_COLOR_BITS);
|
||||
}
|
||||
|
||||
int _wrap_Color_setRed(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
int arg = luaL_checkinteger(L, 2);
|
||||
t->setRed(arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Color_setGreen(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
int arg = luaL_checkinteger(L, 2);
|
||||
t->setGreen(arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Color_setBlue(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
int arg = luaL_checkinteger(L, 2);
|
||||
t->setBlue(arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Color_setAlpha(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
int arg = luaL_checkinteger(L, 2);
|
||||
t->setAlpha(arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_Color_getRed(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
lua_pushinteger(L, t->getRed());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Color_getGreen(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
lua_pushinteger(L, t->getGreen());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Color_getBlue(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
lua_pushinteger(L, t->getBlue());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_Color_getAlpha(lua_State * L)
|
||||
{
|
||||
Color * t = luax_checkcolor(L, 1);
|
||||
lua_pushinteger(L, t->getAlpha());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg wrap_Color_functions[] = {
|
||||
{ "setRed", _wrap_Color_setRed },
|
||||
{ "setGreen", _wrap_Color_setGreen },
|
||||
{ "setBlue", _wrap_Color_setBlue },
|
||||
{ "setAlpha", _wrap_Color_setAlpha },
|
||||
{ "getRed", _wrap_Color_getRed },
|
||||
{ "getGreen", _wrap_Color_getGreen },
|
||||
{ "getBlue", _wrap_Color_getBlue },
|
||||
{ "getAlpha", _wrap_Color_getAlpha },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_Color_open(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "Color", wrap_Color_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_COLOR_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_COLOR_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Color.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Color * luax_checkcolor(lua_State * L, int idx);
|
||||
int _wrap_Color_setRed(lua_State * L);
|
||||
int _wrap_Color_setGreen(lua_State * L);
|
||||
int _wrap_Color_setBlue(lua_State * L);
|
||||
int _wrap_Color_setAlpha(lua_State * L);
|
||||
int _wrap_Color_getRed(lua_State * L);
|
||||
int _wrap_Color_getGreen(lua_State * L);
|
||||
int _wrap_Color_getBlue(lua_State * L);
|
||||
int _wrap_Color_getAlpha(lua_State * L);
|
||||
int wrap_Color_open(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_COLOR_H
|
||||
@@ -1,334 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_ParticleSystem.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
ParticleSystem * luax_checkparticlesystem(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<ParticleSystem>(L, idx, "ParticleSystem", LOVE_GRAPHICS_PARTICLE_SYSTEM_BITS);
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSprite(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
Image * i = luax_checkimage(L, 2);
|
||||
t->setSprite(i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setBufferSize(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
int arg1 = luaL_checkint(L, 2);
|
||||
t->setBufferSize((unsigned int)arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setEmissionRate(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
int arg1 = luaL_checkint(L, 2);
|
||||
t->setEmissionRate((unsigned int)arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setLifetime(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setLifetime(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setParticleLife(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_checknumber(L, 3);
|
||||
t->setParticleLife(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setPosition(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_checknumber(L, 3);
|
||||
t->setPosition(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setDirection(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setDirection(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSpread(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setSpread(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setRelativeDirection(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
bool arg1 = (bool)luax_toboolean(L, 2);
|
||||
t->setRelativeDirection(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSpeed(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
t->setSpeed(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setGravity(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
t->setGravity(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setRadialAcceleration(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
t->setRadialAcceleration(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setTangentialAcceleration(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
t->setTangentialAcceleration(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSize(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
float arg3 = (float)luaL_optnumber(L, 3, 0);
|
||||
t->setSize(arg1, arg2, arg3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSizeVariation(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setSizeVariation(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setRotation(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
t->setRotation(arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSpin(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
float arg2 = (float)luaL_optnumber(L, 3, arg1);
|
||||
float arg3 = (float)luaL_optnumber(L, 3, 0);
|
||||
t->setSpin(arg1, arg2, arg3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setSpinVariation(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float arg1 = (float)luaL_checknumber(L, 2);
|
||||
t->setSpinVariation(arg1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_setColor(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
Color * start = luax_checkcolor(L, 2);
|
||||
Color * end = (lua_gettop(L) == 3) ? luax_checkcolor(L, 3) : start;
|
||||
t->setColor(start, end);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_getX(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getX());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_getY(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getY());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_getDirection(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getDirection());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_getSpread(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getSpread());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_count(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->count());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_start(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
t->start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_stop(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
t->stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_pause(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
t->pause();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_reset(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
t->reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_isActive(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
luax_pushboolean(L, t->isActive());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_isEmpty(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
luax_pushboolean(L, t->isEmpty());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_isFull(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
luax_pushboolean(L, t->isFull());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_ParticleSystem_update(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
float dt = (float)luaL_checknumber(L, 2);
|
||||
t->update(dt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg wrap_ParticleSystem_functions[] = {
|
||||
{ "setSprite", _wrap_ParticleSystem_setSprite },
|
||||
{ "setBufferSize", _wrap_ParticleSystem_setBufferSize },
|
||||
{ "setEmissionRate", _wrap_ParticleSystem_setEmissionRate },
|
||||
{ "setLifeTime", _wrap_ParticleSystem_setLifetime },
|
||||
{ "setParticleLife", _wrap_ParticleSystem_setParticleLife },
|
||||
{ "setPosition", _wrap_ParticleSystem_setPosition },
|
||||
{ "setDirection", _wrap_ParticleSystem_setDirection },
|
||||
{ "setSpread", _wrap_ParticleSystem_setSpread },
|
||||
{ "setRelativeDirection", _wrap_ParticleSystem_setRelativeDirection },
|
||||
{ "setSpeed", _wrap_ParticleSystem_setSpeed },
|
||||
{ "setGravity", _wrap_ParticleSystem_setGravity },
|
||||
{ "setRadialAcceleration", _wrap_ParticleSystem_setRadialAcceleration },
|
||||
{ "setTangentialAcceleration", _wrap_ParticleSystem_setTangentialAcceleration },
|
||||
{ "setSize", _wrap_ParticleSystem_setSize },
|
||||
{ "setSizeVariation", _wrap_ParticleSystem_setSizeVariation },
|
||||
{ "setRotation", _wrap_ParticleSystem_setRotation },
|
||||
{ "setSpin", _wrap_ParticleSystem_setSpin },
|
||||
{ "setSpinVariation", _wrap_ParticleSystem_setSpinVariation },
|
||||
{ "setColor", _wrap_ParticleSystem_setColor },
|
||||
{ "getX", _wrap_ParticleSystem_getX },
|
||||
{ "getY", _wrap_ParticleSystem_getY },
|
||||
{ "getDirection", _wrap_ParticleSystem_getDirection },
|
||||
{ "getSpread", _wrap_ParticleSystem_getSpread },
|
||||
{ "count", _wrap_ParticleSystem_count },
|
||||
{ "start", _wrap_ParticleSystem_start },
|
||||
{ "stop", _wrap_ParticleSystem_stop },
|
||||
{ "pause", _wrap_ParticleSystem_pause },
|
||||
{ "reset", _wrap_ParticleSystem_reset },
|
||||
{ "isActive", _wrap_ParticleSystem_isActive },
|
||||
{ "isEmpty", _wrap_ParticleSystem_isEmpty },
|
||||
{ "isFull", _wrap_ParticleSystem_isFull },
|
||||
{ "update", _wrap_ParticleSystem_update },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_ParticleSystem_open(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "ParticleSystem", wrap_ParticleSystem_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "wrap_Image.h"
|
||||
#include "wrap_Color.h"
|
||||
#include "ParticleSystem.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
ParticleSystem * luax_checkparticlesystem(lua_State * L, int idx);
|
||||
int _wrap_ParticleSystem_setSprite(lua_State * L);
|
||||
int _wrap_ParticleSystem_setBufferSize(lua_State * L);
|
||||
int _wrap_ParticleSystem_setEmissionRate(lua_State * L);
|
||||
int _wrap_ParticleSystem_setLifetime(lua_State * L);
|
||||
int _wrap_ParticleSystem_setParticleLife(lua_State * L);
|
||||
int _wrap_ParticleSystem_setPosition(lua_State * L);
|
||||
int _wrap_ParticleSystem_setDirection(lua_State * L);
|
||||
int _wrap_ParticleSystem_setSpread(lua_State * L);
|
||||
int _wrap_ParticleSystem_setRelativeDirection(lua_State * L);
|
||||
int _wrap_ParticleSystem_setSpeed(lua_State * L);
|
||||
int _wrap_ParticleSystem_setGravity(lua_State * L);
|
||||
int _wrap_ParticleSystem_setRadialAcceleration(lua_State * L);
|
||||
int _wrap_ParticleSystem_setTangentialAcceleration(lua_State * L);
|
||||
int _wrap_ParticleSystem_setSize(lua_State * L);
|
||||
int _wrap_ParticleSystem_setSizeVariation(lua_State * L);
|
||||
int _wrap_ParticleSystem_setRotation(lua_State * L);
|
||||
int _wrap_ParticleSystem_setSpin(lua_State * L);
|
||||
int _wrap_ParticleSystem_setSpinVariation(lua_State * L);
|
||||
int _wrap_ParticleSystem_setColor(lua_State * L);
|
||||
int _wrap_ParticleSystem_getX(lua_State * L);
|
||||
int _wrap_ParticleSystem_getY(lua_State * L);
|
||||
int _wrap_ParticleSystem_getDirection(lua_State * L);
|
||||
int _wrap_ParticleSystem_getSpread(lua_State * L);
|
||||
int _wrap_ParticleSystem_count(lua_State * L);
|
||||
int _wrap_ParticleSystem_start(lua_State * L);
|
||||
int _wrap_ParticleSystem_stop(lua_State * L);
|
||||
int _wrap_ParticleSystem_pause(lua_State * L);
|
||||
int _wrap_ParticleSystem_reset(lua_State * L);
|
||||
int _wrap_ParticleSystem_isActive(lua_State * L);
|
||||
int _wrap_ParticleSystem_isEmpty(lua_State * L);
|
||||
int _wrap_ParticleSystem_isFull(lua_State * L);
|
||||
int _wrap_ParticleSystem_update(lua_State * L);
|
||||
int wrap_ParticleSystem_open(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_PARTICLE_SYSTEM_H
|
||||
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_SpriteBatch.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", LOVE_GRAPHICS_SPRITE_BATCH_BITS);
|
||||
}
|
||||
|
||||
int _wrap_SpriteBatch_add(lua_State * L)
|
||||
{
|
||||
SpriteBatch * t = luax_checkspritebatch(L, 1);
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0f);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0f);
|
||||
float angle = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
float sx = (float)luaL_optnumber(L, 5, 1.0f);
|
||||
float sy = (float)luaL_optnumber(L, 6, sx);
|
||||
float ox = (float)luaL_optnumber(L, 7, 0);
|
||||
float oy = (float)luaL_optnumber(L, 8, 0);
|
||||
t->add(x, y, angle, sx, sy, ox, oy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_SpriteBatch_clear(lua_State * L)
|
||||
{
|
||||
SpriteBatch * t = luax_checkspritebatch(L, 1);
|
||||
t->clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg wrap_SpriteBatch_functions[] = {
|
||||
{ "add", _wrap_SpriteBatch_add },
|
||||
{ "clear", _wrap_SpriteBatch_clear },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_SpriteBatch_open(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "SpriteBatch", wrap_SpriteBatch_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
|
||||
#include <common/runtime.h>
|
||||
#include "SpriteBatch.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx);
|
||||
int _wrap_SpriteBatch_add(lua_State * L);
|
||||
int _wrap_SpriteBatch_clear(lua_State * L);
|
||||
int wrap_SpriteBatch_open(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include "wrap_VertexBuffer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
VertexBuffer * luax_checkvertexbuffer(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<VertexBuffer>(L, idx, "VertexBuffer", LOVE_GRAPHICS_VERTEX_BUFFER_BITS);
|
||||
}
|
||||
|
||||
int _wrap_VertexBuffer_setType(lua_State * L)
|
||||
{
|
||||
VertexBuffer * t = luax_checkvertexbuffer(L, 1);
|
||||
int type = luaL_checkint(L, 2);
|
||||
t->setType(type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_VertexBuffer_getType(lua_State * L)
|
||||
{
|
||||
VertexBuffer * t = luax_checkvertexbuffer(L, 1);
|
||||
lua_pushnumber(L, t->getType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _wrap_VertexBuffer_add(lua_State * L)
|
||||
{
|
||||
VertexBuffer * vb = luax_checkvertexbuffer(L, 1);
|
||||
float x = (float)luaL_optnumber(L, 2, 0.0f);
|
||||
float y = (float)luaL_optnumber(L, 3, 0.0f);
|
||||
float s = (float)luaL_optnumber(L, 4, 0.0f);
|
||||
float t = (float)luaL_optnumber(L, 5, 0.0f);
|
||||
unsigned char r = (unsigned char)luaL_optnumber(L, 6, 255);
|
||||
unsigned char g = (unsigned char)luaL_optnumber(L, 7, 255);
|
||||
unsigned char b = (unsigned char)luaL_optnumber(L, 8, 255);
|
||||
unsigned char a = (unsigned char)luaL_optnumber(L, 9, 255);
|
||||
vb->add(x, y, s, t, r, g, b, a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wrap_VertexBuffer_clear(lua_State * L)
|
||||
{
|
||||
VertexBuffer * t = luax_checkvertexbuffer(L, 1);
|
||||
t->clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg wrap_VertexBuffer_functions[] = {
|
||||
{ "setType", _wrap_VertexBuffer_setType },
|
||||
{ "getType", _wrap_VertexBuffer_getType },
|
||||
{ "add", _wrap_VertexBuffer_add },
|
||||
{ "clear", _wrap_VertexBuffer_clear },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int wrap_VertexBuffer_open(lua_State * L)
|
||||
{
|
||||
luax_register_type(L, "VertexBuffer", wrap_VertexBuffer_functions);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2009 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_VERTEX_BUFFER_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_VERTEX_BUFFER_H
|
||||
|
||||
#include <common/runtime.h>
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
VertexBuffer * luax_checkvertexbuffer(lua_State * L, int idx);
|
||||
int _wrap_VertexBuffer_setType(lua_State * L);
|
||||
int _wrap_VertexBuffer_getType(lua_State * L);
|
||||
int _wrap_VertexBuffer_add(lua_State * L);
|
||||
int _wrap_VertexBuffer_clear(lua_State * L);
|
||||
int wrap_VertexBuffer_open(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_VERTEX_BUFFER_H
|
||||
Reference in New Issue
Block a user