コード例 #1
0
TextureRef Texture::loadImage(const char *filename, GLenum texUnit) {
    SDL_Surface *bitmap = IMG_Load(filename);
 
    if (bitmap == NULL) {
        Logger::logprintf(Logger::LOG_ERROR, Logger::LOG_TEXTURES, "Failed loading texture from file %s - Error: %s\n", filename, SDL_GetError());
        return TextureRef();
    }

    Logger::logprintf(Logger::LOG_INFO, Logger::LOG_TEXTURES, "Successfully loaded texture from file %s\n", filename);
    Texture *texture = new Texture(*bitmap, texUnit);
    SDL_FreeSurface(bitmap);

    return TextureRef(*texture);
}
コード例 #2
0
ファイル: CurvePreview.cpp プロジェクト: zenkovich/o2
	void CurvePreview::Redraw()
	{
		if (!mCurve)
			return;

		TextureRef texture = mSprite->GetTexture();
		if (!texture || texture->GetSize() != layout->GetSize())
		{
			texture = TextureRef(layout->GetSize(), PixelFormat::R8G8B8A8, Texture::Usage::RenderTarget);
			mSprite->SetTexture(texture);
			mSprite->SetTextureSrcRect(RectI(Vec2I(), texture->GetSize()));
		}

		const Color4 backColor(120, 120, 120, 255);
		const Color4 curveColor(0, 255, 0, 255);

		Camera prevCamera = o2Render.GetCamera();
		Camera currCamera; currCamera.SetRect(mCurve->GetRect());
		currCamera.SetScale(currCamera.GetScale().InvertedY());

		o2Render.SetRenderTexture(texture);
		o2Render.SetCamera(currCamera);
		o2Render.Clear(backColor);

		static Vector<Vertex2> buffer;
		buffer.Clear();

		auto curveColorHex = curveColor.ARGB();

		auto& keys = mCurve->GetKeys();
		for (auto& key : keys)
		{
			buffer.Add(Vertex2(key.position, key.value, curveColorHex, 0, 0));

			auto points = key.GetApproximatedPoints();
			for (int i = 0; i < key.GetApproximatedPointsCount(); i++)
				buffer.Add(Vertex2(points[i], curveColorHex, 0, 0));

			o2Render.DrawAAPolyLine(buffer.Data(), buffer.Count(), 2);
		}

		o2Render.UnbindRenderTexture();
		o2Render.SetCamera(prevCamera);
	}
コード例 #3
0
ファイル: File.cpp プロジェクト: PENGUINLIONG/LiongPlus
TextureRef FileImpl::Read(wchar_t *path)
{
    if (stream.is_open())
        stream.close();
    FileFormat &&format = DoDetect(path);
    stream.close();

    switch (format)
    {
    case FileFormat::BMP:
    {
        BMP bmp;
        return bmp.ToTexture(path);
    }
    case FileFormat::PNG:
    {
        PNG png;
        return png.ToTexture(path);
    }
    default:
        return TextureRef();
    }
}
コード例 #4
0
ファイル: materials.cpp プロジェクト: ema29/TemplePlus
		TextureRef GetPrimaryTexture() override {
			return TextureRef(); // Null texture
		}