mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
SpriteBatches are now affected by love.graphics.setColor()
This commit is contained in:
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 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
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "SpriteBatch.h"
|
#include "SpriteBatch.h"
|
||||||
@@ -153,23 +153,23 @@ namespace opengl
|
|||||||
next = 0;
|
next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * SpriteBatch::lock()
|
void * SpriteBatch::lock()
|
||||||
{
|
{
|
||||||
// If already locked, prevent from locking again.
|
// If already locked, prevent from locking again.
|
||||||
if(lockp != 0)
|
if(lockp != 0)
|
||||||
return lockp;
|
return lockp;
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
|
||||||
lockp = (vertex *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
|
lockp = (vertex *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
|
||||||
return lockp;
|
return lockp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteBatch::unlock()
|
void SpriteBatch::unlock()
|
||||||
{
|
{
|
||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
lockp = 0;
|
lockp = 0;
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
||||||
{
|
{
|
||||||
@@ -185,19 +185,16 @@ namespace opengl
|
|||||||
// Enable vertex arrays.
|
// Enable vertex arrays.
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
|
||||||
|
|
||||||
// Bind the VBO buffer.
|
// Bind the VBO buffer.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[1]);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[1]);
|
||||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid*)0);
|
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)(sizeof(unsigned char)*4));
|
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));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)(sizeof(unsigned char)*4+sizeof(float)*2));
|
||||||
|
|
||||||
glDrawElements(GL_TRIANGLES, next*6, GL_UNSIGNED_SHORT, 0);
|
glDrawElements(GL_TRIANGLES, next*6, GL_UNSIGNED_SHORT, 0);
|
||||||
|
|
||||||
// Disable vertex arrays.
|
// Disable vertex arrays.
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user