コード例 #1
0
int w_SpriteBatch_setTexture(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	Texture *tex = luax_checktexture(L, 2);
	t->setTexture(tex);
	return 0;
}
コード例 #2
0
ファイル: TileSet.cpp プロジェクト: Joilnen/GamePlay
TileSet* TileSet::create(const char* imagePath,
                         float tileWidth, float tileHeight,
                         unsigned int rowCount, unsigned int columnCount)
{
    GP_ASSERT(imagePath);
    GP_ASSERT(tileWidth > 0 && tileHeight > 0);
    GP_ASSERT(rowCount > 0 && columnCount > 0);
    
    SpriteBatch* batch = SpriteBatch::create(imagePath);
    batch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
    batch->getSampler()->setFilterMode(Texture::Filter::NEAREST, Texture::Filter::NEAREST);
    batch->getStateBlock()->setDepthWrite(false);
    batch->getStateBlock()->setDepthTest(true);
    
    TileSet* tileset = new TileSet();
    tileset->_batch = batch;
    tileset->_tiles = new Vector2[rowCount * columnCount];
    memset(tileset->_tiles, -1, sizeof(float) * rowCount * columnCount * 2);
    tileset->_tileWidth = tileWidth;
    tileset->_tileHeight = tileHeight;
    tileset->_rowCount = rowCount;
    tileset->_columnCount = columnCount;
    tileset->_width = tileWidth * columnCount;
    tileset->_height = tileHeight * rowCount;
    return tileset;
}
コード例 #3
0
ファイル: CheckBox.cpp プロジェクト: rgngl/GamePlay
unsigned int CheckBox::drawImages(Form* form, const Rectangle& clip)
{
    if (!_image)
        return 0;

    // Left, v-center.
    // TODO: Set an alignment for icons.

    const Rectangle& region = _image->getRegion();
    const Theme::UVs& uvs = _image->getUVs();
    Vector4 color = _image->getColor();
    color.w *= _opacity;

    Vector2 size;
    if (_imageSize.isZero())
    {
        size.set(region.width, region.height);
    }
    else
    {
        size.set(_imageSize);
    }

    Vector2 pos(_viewportBounds.x, _viewportBounds.y + _viewportBounds.height * 0.5f - size.y * 0.5f);

    SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
    startBatch(form, batch);
    batch->draw(pos.x, pos.y, size.x, size.y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
    finishBatch(form, batch);

    return 1;
}
コード例 #4
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: joedrago/love
int w_SpriteBatch_setg(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	int index = luaL_checkinteger(L, 2);
	Geometry *g = luax_checktype<Geometry>(L, 3, "Geometry", GRAPHICS_GEOMETRY_T);

	float x = (float)luaL_optnumber(L, 4, 0.0f);
	float y = (float)luaL_optnumber(L, 5, 0.0f);
	float angle = (float)luaL_optnumber(L, 6, 0.0f);
	float sx = (float)luaL_optnumber(L, 7, 1.0f);
	float sy = (float)luaL_optnumber(L, 8, sx);
	float ox = (float)luaL_optnumber(L, 9, 0);
	float oy = (float)luaL_optnumber(L, 10, 0);
	float kx = (float)luaL_optnumber(L, 11, 0);
	float ky = (float)luaL_optnumber(L, 12, 0);
	try
	{
		t->addg(g, x, y, angle, sx, sy, ox, oy, kx, ky, index);
	}
	catch (love::Exception &e)
	{
		return luaL_error(L, "%s", e.what());
	}
	return 0;
}
コード例 #5
0
ファイル: TextBox.cpp プロジェクト: 0chunhui/GamePlay
unsigned int TextBox::drawImages(Form* form, const Rectangle& clip)
{
    Control::State state = getState();

    if (_caretImage && (state == ACTIVE || hasFocus()))
    {
        // Draw the cursor at its current location.
        const Rectangle& region = _caretImage->getRegion();
        if (!region.isEmpty())
        {
            const Theme::UVs& uvs = _caretImage->getUVs();
            Vector4 color = _caretImage->getColor();
            color.w *= _opacity;

            float caretWidth = region.width * _fontSize / region.height;

            Font* font = getFont(state);
            unsigned int fontSize = getFontSize(state);
            Vector2 point;
            font->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, fontSize, &point, _caretLocation, 
                 getTextAlignment(state), true, getTextRightToLeft(state));

            SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
            startBatch(form, batch);
            batch->draw(point.x - caretWidth * 0.5f, point.y, caretWidth, fontSize, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
            finishBatch(form, batch);

            return 1;
        }
    }

    return 0;
}
コード例 #6
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: joedrago/love
int w_SpriteBatch_setImage(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	Image *image = luax_checktype<Image>(L, 2, "Image", GRAPHICS_IMAGE_T);
	t->setImage(image);
	return 0;
}
コード例 #7
0
int w_SpriteBatch_setBufferSize(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	int size = (int) luaL_checknumber(L, 2);
	luax_catchexcept(L, [&]() {t->setBufferSize(size); });
	return 0;
}
コード例 #8
0
	//=====-----=======---------=========---------==========---------=========----------=============
    void ParticleSet::drawParticles( SpriteBatch& sb, const TexturePtr texture, const Color& color, const int layer, const float sizeFactor, bool doFade )
	{
		for(int i = 0; i <= mHighestLiveIndex; ++i)
		{
			if(!mParticles[i].mAlive)
			{
				continue;
			}
			
			if (mParticles[i].mLifetime == -1.0f) 
			{
                Color finalColor( color );
                finalColor *= mParticles[i].mAlphaMultiplier;
				sb.drawQuad(layer, texture, mParticles[i].mPosition + VectorTools::rotateVector(mParticles[i].mOffset, Walaber::degToRad(mParticles[i].mAngleDeg)), Walaber::degToRad(mParticles[i].mAngleDeg), mParticles[i].mSize * sizeFactor, finalColor);
			}
			else 
			{
				Color finalCol = color;
				
				if (doFade)
					finalCol = _getParticleColor(&mParticles[i], color); // color * lerp(0.0f, 1.0f, mParticles[i].mLifetime / mParticles[i].mFadeLength);
                
				sb.drawQuad(layer, texture, mParticles[i].mPosition + VectorTools::rotateVector(mParticles[i].mOffset, Walaber::degToRad(mParticles[i].mAngleDeg)), Walaber::degToRad(mParticles[i].mAngleDeg), getParticleSize(i) * sizeFactor, finalCol);
			}
		}
	}
コード例 #9
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: joedrago/love
int w_SpriteBatch_setColor(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	Color c;

	if (lua_gettop(L) <= 1)
	{
		t->setColor();
		return 0;
	}
	else if (lua_istable(L, 2))
	{
		for (int i = 1; i <= 4; i++)
			lua_rawgeti(L, 2, i);

		c.r = (unsigned char) luaL_checkint(L, -4);
		c.g = (unsigned char) luaL_checkint(L, -3);
		c.b = (unsigned char) luaL_checkint(L, -2);
		c.a = (unsigned char) luaL_optint(L, -1, 255);

		lua_pop(L, 4);
	}
	else
	{
		c.r = (unsigned char)luaL_checkint(L, 2);
		c.g = (unsigned char)luaL_checkint(L, 3);
		c.b = (unsigned char)luaL_checkint(L, 4);
		c.a = (unsigned char)luaL_optint(L, 5, 255);
	}

	t->setColor(c);

	return 0;
}
コード例 #10
0
void ParticleEmitter::draw (SpriteBatch& spriteBatch,float delta) {
    accumulator += std::min(delta * 1000, 250.f);
    if (accumulator < 1) {
        draw(spriteBatch);
        return;
    }
    int deltaMillis = (int)accumulator;
    accumulator -= deltaMillis;

    if (additive) spriteBatch.setBlendFunction(gdx_cpp::graphics::GL10::GL_SRC_ALPHA, gdx_cpp::graphics::GL10::GL_ONE);

    for (unsigned int index = 0; index < active.size(); index++) {
        if (active[index])
        {
            if (updateParticle(index, delta, deltaMillis))
            {
                particles[index]->draw(spriteBatch);
            }
            else
            {
                active[index] = false;
                activeCount--;
            }
        }
    }

    if (additive) spriteBatch.setBlendFunction(gdx_cpp::graphics::GL10::GL_SRC_ALPHA, gdx_cpp::graphics::GL10::GL_ONE_MINUS_SRC_ALPHA);

    if (delayTimer < delay) {
        delayTimer += deltaMillis;
        return;
    }

    if (firstUpdate) {
        firstUpdate = false;
        addParticle();
    }

    if (durationTimer < duration)
        durationTimer += deltaMillis;
    else {
        if (!continuous || allowCompletionVar) return;
        restart();
    }

    emissionDelta += deltaMillis;
    float emissionTime = emission + emissionDiff * emissionValue.getScale(durationTimer / (float)duration);
    if (emissionTime > 0) {
        emissionTime = 1000 / emissionTime;
        if (emissionDelta >= emissionTime) {
            int emitCount = (int)(emissionDelta / emissionTime);
            emitCount = std::min(emitCount, maxParticleCount - activeCount);
            emissionDelta -= emitCount * emissionTime;
            emissionDelta = std::fmod((float)emissionDelta,  emissionTime);
            addParticles(emitCount);
        }
    }
    if (activeCount < minParticleCount) addParticles(minParticleCount - activeCount);
}
コード例 #11
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: joedrago/love
int w_SpriteBatch_getImage(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	Image *image = t->getImage();
	image->retain();
	luax_newtype(L, "Image", GRAPHICS_IMAGE_T, (void *)image);
	return 1;
}
コード例 #12
0
void Level::draw(SpriteBatch& spriteBatch)
{
	for (auto& block : m_levelData)
	{
		spriteBatch.draw(glm::vec4(block.pos.x, block.pos.y, block.size.x, block.size.y), glm::vec4(0,0,1,1), m_texture.id, 0, m_color);
	}
    spriteBatch.draw(glm::vec4(m_finishPoint.pos.x-2.f, m_finishPoint.pos.y-2.f, m_finishPoint.size.x, m_finishPoint.size.y), glm::vec4(0,0,1,1), m_texture.id, 0, ColorRGBA8(20,20,220,255));
}
コード例 #13
0
int w_SpriteBatch_attachAttribute(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	const char *name = luaL_checkstring(L, 2);
	Mesh *m = luax_checktype<Mesh>(L, 3, GRAPHICS_MESH_ID);

	luax_catchexcept(L, [&](){ t->attachAttribute(name, m); });
	return 0;
}
コード例 #14
0
ファイル: MeshGame.cpp プロジェクト: yohanip/GamePlay
void MeshGame::drawSplash(void* param)
{
    clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);
    SpriteBatch* batch = SpriteBatch::create("res/logo_powered_white.png");
    batch->start();
    batch->draw(this->getWidth() * 0.5f, this->getHeight() * 0.5f, 0.0f, 512.0f, 512.0f, 0.0f, 1.0f, 1.0f, 0.0f, Vector4::one(), true);
    batch->finish();
    SAFE_DELETE(batch);
}
コード例 #15
0
ファイル: SpaceshipGame.cpp プロジェクト: aaweb/GamePlay
void SpaceshipGame::drawSplash(void* coookie)
{
    clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);
    SpriteBatch* batch = SpriteBatch::create("res/splash.png");
    batch->begin();
    batch->draw(Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT), Rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT), Vector4::one());
    batch->end();
    SAFE_DELETE(batch);
}
コード例 #16
0
ファイル: CharacterGame.cpp プロジェクト: jsethi/GamePlay
void CharacterGame::drawSplash(void* param)
{
    clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);
    SpriteBatch* batch = SpriteBatch::create("res/logo_powered_white.png");
    batch->begin();
    batch->draw(getWidth() * 0.5f, getHeight() * 0.5f, 0.0f, 512.0f, 512.0f, 0.0f, 1.0f, 1.0f, 0.0f, Vector4::one(), true);
    batch->end();
    SAFE_DELETE(batch);
}
コード例 #17
0
void ParticleEmitter::draw (SpriteBatch& spriteBatch) {
    if (additive) spriteBatch.setBlendFunction(gdx_cpp::graphics::GL10::GL_SRC_ALPHA, gdx_cpp::graphics::GL10::GL10::GL_ONE);

    for (unsigned index = 0; index < active.size(); index++) {
        if (active[index])
        {
            particles[index]->draw(spriteBatch);
        }
    }

    if (additive) spriteBatch.setBlendFunction(gdx_cpp::graphics::GL10::GL_SRC_ALPHA, gdx_cpp::graphics::GL10::GL_ONE_MINUS_SRC_ALPHA);
}
コード例 #18
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: joedrago/love
int w_SpriteBatch_bind(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	try
	{
		t->lock();
	}
	catch (love::Exception &e)
	{
		return luaL_error(L, "%s", e.what());
	}
	return 0;
}
コード例 #19
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: AnisB/love
	int w_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;
	}
コード例 #20
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: AnisB/love
	int w_SpriteBatch_addq(lua_State * L)
	{
		SpriteBatch * t = luax_checkspritebatch(L, 1);
		Quad * q = luax_checktype<Quad>(L, 2, "Quad", GRAPHICS_QUAD_T);
		float x = (float)luaL_optnumber(L, 3, 0.0f);
		float y = (float)luaL_optnumber(L, 4, 0.0f);
		float angle = (float)luaL_optnumber(L, 5, 0.0f);
		float sx = (float)luaL_optnumber(L, 6, 1.0f);
		float sy = (float)luaL_optnumber(L, 7, sx);
		float ox = (float)luaL_optnumber(L, 8, 0);
		float oy = (float)luaL_optnumber(L, 9, 0);
		t->addq(q, x, y, angle, sx, sy, ox, oy);
		return 0;
	}
コード例 #21
0
ファイル: NinePatch.cpp プロジェクト: arielsancf/libgdx-cpp
void NinePatch::draw (SpriteBatch& batch,float x,float y,float width,float height) {
    float centerColumnX = x;
    if (patches[(int)Sides::BOTTOM_LEFT].isValid())
        centerColumnX += patches[(int)Sides::BOTTOM_LEFT].getRegionWidth();
    else if (patches[(int)Sides::MIDDLE_LEFT].isValid())
        centerColumnX += patches[(int)Sides::MIDDLE_LEFT].getRegionWidth();
    else if (patches[(int)Sides::TOP_LEFT].isValid()) //
        centerColumnX += patches[(int)Sides::TOP_LEFT].getRegionWidth();

    float rightColumnX = x + width;
    if (patches[(int)Sides::BOTTOM_RIGHT].isValid())
        rightColumnX -= patches[(int)Sides::BOTTOM_RIGHT].getRegionWidth();
    else if (patches[(int)Sides::MIDDLE_RIGHT].isValid())
        rightColumnX += patches[(int)Sides::MIDDLE_RIGHT].getRegionWidth();
    else if (patches[(int)Sides::TOP_RIGHT].isValid()) //
        rightColumnX += patches[(int)Sides::TOP_RIGHT].getRegionWidth();

    float middleRowY = y;
    if (patches[(int)Sides::TOP_LEFT].isValid())
        middleRowY += patches[(int)Sides::TOP_LEFT].getRegionHeight();
    else if (patches[(int)Sides::TOP_CENTER].isValid())
        middleRowY += patches[(int)Sides::TOP_CENTER].getRegionHeight();
    else if (patches[(int)Sides::TOP_RIGHT].isValid()) //
        middleRowY += patches[(int)Sides::TOP_RIGHT].getRegionHeight();

    float topRowY = y + height;
    if (patches[(int)Sides::TOP_LEFT].isValid())
        topRowY -= patches[(int)Sides::TOP_LEFT].getRegionHeight();
    else if (patches[(int)Sides::TOP_CENTER].isValid())
        topRowY -= patches[(int)Sides::TOP_CENTER].getRegionHeight();
    else if (patches[(int)Sides::TOP_RIGHT].isValid()) //
        topRowY -= patches[(int)Sides::TOP_RIGHT].getRegionHeight();

    // Bottom row
    if (patches[(int)Sides::BOTTOM_LEFT].isValid()) batch.draw(patches[(int)Sides::BOTTOM_LEFT], x, y, centerColumnX - x, middleRowY - y);
    if (patches[(int)Sides::BOTTOM_CENTER].isValid())
        batch.draw(patches[(int)Sides::BOTTOM_CENTER], centerColumnX, y, rightColumnX - centerColumnX, middleRowY - y);
    if (patches[(int)Sides::BOTTOM_RIGHT].isValid())
        batch.draw(patches[(int)Sides::BOTTOM_RIGHT], rightColumnX, y, x + width - rightColumnX, middleRowY - y);

    // Middle row
    if (patches[(int)Sides::MIDDLE_LEFT].isValid()) batch.draw(patches[(int)Sides::MIDDLE_LEFT], x, middleRowY, centerColumnX - x, topRowY - middleRowY);
    if (patches[(int)Sides::MIDDLE_CENTER].isValid())
        batch.draw(patches[(int)Sides::MIDDLE_CENTER], centerColumnX, middleRowY, rightColumnX - centerColumnX, topRowY - middleRowY);
    if (patches[(int)Sides::MIDDLE_RIGHT].isValid())
        batch.draw(patches[(int)Sides::MIDDLE_RIGHT], rightColumnX, middleRowY, x + width - rightColumnX, topRowY - middleRowY);

    // Top row
    if (patches[(int)Sides::TOP_LEFT].isValid()) batch.draw(patches[(int)Sides::TOP_LEFT], x, topRowY, centerColumnX - x, y + height - topRowY);
    if (patches[(int)Sides::TOP_CENTER].isValid())
        batch.draw(patches[(int)Sides::TOP_CENTER], centerColumnX, topRowY, rightColumnX - centerColumnX, y + height - topRowY);
    if (patches[(int)Sides::TOP_RIGHT].isValid())
        batch.draw(patches[(int)Sides::TOP_RIGHT], rightColumnX, topRowY, x + width - rightColumnX, y + height - topRowY);
}
コード例 #22
0
ファイル: Main.cpp プロジェクト: TCooper8/KetaGLFramework
	virtual void Draw() override
	{
		GetGraphicsDevice().Clear(Color4::White);
		spriteBatch.Begin(BlendState::AlphaBlend);

		for (int i = 0; i < blipCount; i++)
		{
			spriteBatch.Draw(ball, blips[i], scale, origin);
		}

		theta += 0.01f;

		Game::Draw();
		spriteBatch.End();
	}
コード例 #23
0
int w_SpriteBatch_getTexture(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	Texture *tex = t->getTexture();

	// FIXME: big hack right here.
	if (typeid(*tex) == typeid(Image))
		luax_pushtype(L, GRAPHICS_IMAGE_ID, tex);
	else if (typeid(*tex) == typeid(Canvas))
		luax_pushtype(L, GRAPHICS_CANVAS_ID, tex);
	else
		return luaL_error(L, "Unable to determine texture type.");

	return 1;
}
コード例 #24
0
ファイル: Projectile.cpp プロジェクト: Alvera/MarzenaProjects
void Projectile::draw(SpriteBatch& spriteBatch)
{
	glm::vec4 uv = glm::vec4(0.0f, 0.0f, 1.0f, 1.0f);
	static GLTexture texture = ResourceManager::getTexture("Textures/PNG/Coal.png");
	glm::vec4 posAndSize = glm::vec4(_position.x, _position.y, 30, 30);
	spriteBatch.draw(posAndSize, uv, texture.id, 0.0f, Color4(255, 255, 255, 255));
}
コード例 #25
0
ファイル: draw.cpp プロジェクト: garudaxc/AndroidGL
void LoadResource() {
	GGlobalVarManager->Init();

	GFileSys->SetRootPath("../../resource/", true);
	
	GShaderManager.LoadFromFile(ShaderDiffuse, "../../assets/shader330.glsl");
	GShaderManager.LoadFromFile(ShaderUI, "../../assets/ShaderUI.glsl");
	checkGlError("GShaderManager.LoadFromFile");

	bitmapFont.LoadFromFile("consolas.bitmapfont");
	spriteBatch.Init(128);

	ModelInstance* model = NULL;
	model = CreateModel("build_tower003.mesh", "2.png");
	model->transform_ = Matrix4f::Transform(Quaternionf::IDENTITY, Vector3f(-1.0f, 10.0f, 0.0f));
	Models.push_back(model);

	//model = CreateModel("build_house008.mesh", "1.png");
	//model->transform_ = Matrix4f::Transform(Quaternionf::IDENTITY, Vector3f(1.5f, 10.0f, 0.0f));
	//Models.push_back(model);


	//model = CreateModel("Box001.mesh", "2.png");
	//MatrixTransform(model->transform_, Quaternionf::IDENTITY, Vector3f(0.0f, 0.0f, 0.0f));
	//Models.push_back(model);

}
コード例 #26
0
 void SpriteFont::draw(SpriteBatch& batch, const char* s, glm::vec2 position, glm::vec2 scaling, 
                       float depth, ColorRGBA8 tint, Justification just /* = Justification::LEFT */) {
     glm::vec2 tp = position;
     // Apply justification
     if (just == Justification::MIDDLE) {
         tp.x -= measure(s).x * scaling.x / 2;
     } else if (just == Justification::RIGHT) {
         tp.x -= measure(s).x * scaling.x;
     }
     for (int si = 0; s[si] != 0; si++) {
         char c = s[si];
         if (s[si] == '\n') {
             tp.y += _fontHeight * scaling.y;
             tp.x = position.x;
         } else {
             // Check for correct glyph
             int gi = c - _regStart;
             if (gi < 0 || gi >= _regLength)
                 gi = _regLength;
             glm::vec4 destRect(tp, _glyphs[gi].size * scaling);
             batch.draw(destRect, _glyphs[gi].uvRect, _texID, depth, tint);
             tp.x += _glyphs[gi].size.x * scaling.x;
         }
     }
 }
コード例 #27
0
int w_SpriteBatch_getColor(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	const Color *color = t->getColor();

	// getColor returns null if no color is set.
	if (!color)
		return 0;

	lua_pushnumber(L, color->r);
	lua_pushnumber(L, color->g);
	lua_pushnumber(L, color->b);
	lua_pushnumber(L, color->a);

	return 4;
}
コード例 #28
0
ファイル: wrap_SpriteBatch.cpp プロジェクト: joedrago/love
int w_SpriteBatch_set(lua_State *L)
{
	SpriteBatch *t = luax_checkspritebatch(L, 1);
	int index = luaL_checkinteger(L, 2);
	float x = (float)luaL_optnumber(L, 3, 0.0f);
	float y = (float)luaL_optnumber(L, 4, 0.0f);
	float angle = (float)luaL_optnumber(L, 5, 0.0f);
	float sx = (float)luaL_optnumber(L, 6, 1.0f);
	float sy = (float)luaL_optnumber(L, 7, sx);
	float ox = (float)luaL_optnumber(L, 8, 0);
	float oy = (float)luaL_optnumber(L, 9, 0);
	float kx = (float)luaL_optnumber(L, 10, 0);
	float ky = (float)luaL_optnumber(L, 11, 0);
	t->add(x, y, angle, sx, sy, ox, oy, kx, ky, index);
	return 0;
}
コード例 #29
0
void Level::draw(SpriteBatch& spriteBatch)
{
	for (auto& block : m_levelData)
	{
		spriteBatch.draw(glm::vec4(block.pos.x, block.pos.y, block.size.x, block.size.y), glm::vec4(0,0,1,1), m_texture.id, 0, m_color);
	}

}
コード例 #30
0
Sprite* Sprite::create(const char* imagePath, float width, float height,
                       const Rectangle& source, unsigned int frameCount, Effect* effect)
{
    GP_ASSERT(imagePath != NULL);
    GP_ASSERT(width >= -1 && height >= -1);
    GP_ASSERT(source.width >= -1 && source.height >= -1);
    GP_ASSERT(frameCount > 0);

    SpriteBatch* batch = SpriteBatch::create(imagePath, effect);
    batch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
    batch->getSampler()->setFilterMode(Texture::Filter::LINEAR, Texture::Filter::LINEAR);
    batch->getStateBlock()->setDepthWrite(false);
    batch->getStateBlock()->setDepthTest(true);

    unsigned int imageWidth = batch->getSampler()->getTexture()->getWidth();
    unsigned int imageHeight = batch->getSampler()->getTexture()->getHeight();
    if (width == -1)
        width = imageWidth;
    if (height == -1)
        height = imageHeight;

    Sprite* sprite = new Sprite();
    sprite->_width = width;
    sprite->_height = height;
    sprite->_batch = batch;
    sprite->_frameCount = frameCount;
    sprite->_frames = new Rectangle[frameCount];
    sprite->_frames[0] = source;
    if (sprite->_frames[0].width == -1.0f)
        sprite->_frames[0].width = imageWidth;
    if (sprite->_frames[0].height == -1.0f)
        sprite->_frames[0].height = imageHeight;
    return sprite;
}