コード例 #1
0
ファイル: PixmapTest.cpp プロジェクト: NoiSek/libgdx-cpp
    void create() {
        Texture::ptr texture = Texture::ptr(new Texture(1024,1024, Pixmap::Format::RGBA8888, Pixmap::Gdx2d));

        Pixmap::ptr pixmap = Pixmap::newFromRect(840, 480, Pixmap::Format::RGBA8888, Pixmap::Gdx2d);
        texture->setFilter(Texture::TextureFilter::Nearest, Texture::TextureFilter::Linear);
        texture->setWrap(Texture::TextureWrap::ClampToEdge, Texture::TextureWrap::ClampToEdge);
        pixmap->setColor(1.0f, 0.0f, 0.0f, 1.0f); // Red
        pixmap->drawLine(0, 0, 100, 100);
        
        pixmap->setColor(0.0f, 0.0f, 1.0f, 1.0f); // Blue
        pixmap->drawLine(100, 100, 200, 0);
        
        pixmap->setColor(0.0f, 1.0f, 0.0f, 1.0f); // Green
        pixmap->drawLine(100, 0, 100, 100);
        
        pixmap->setColor(1.0f, 1.0f, 1.0f, 1.0f); // White
        pixmap->drawCircle(400, 300, 100);

        texture->draw(*pixmap, 0, 0);
        region = new TextureRegion(texture, 0, 0, 800, 480);
        batch = new SpriteBatch();

        Pixmap::ptr px = Pixmap::newFromRect(512, 1024, Pixmap::Format::RGBA8888, Pixmap::Gdx2d);
        for (int y = 0; y < pixmap->getHeight(); y++) { // 1024
            for (int x = 0; x < pixmap->getWidth(); x++) { // 512
                                pixmap->getPixel(x, y);
                        }
        }
        px->dispose();
    }
コード例 #2
0
ファイル: AlphaTest.cpp プロジェクト: aevum/libgdx-cpp-tests
 void create() {
     Pixmap::ptr pixmap = Pixmap::newFromRect(256, 256, Pixmap::Format::RGBA8888, Pixmap::Gdx2d);
     pixmap->setColor(0, 1, 0, 0.7f);
     pixmap->fill();
     
     spriteBatch = new SpriteBatch();
     texture = Texture::ptr(new Texture(pixmap, false));
     texture->setFilter(Texture::TextureFilter::Linear, Texture::TextureFilter::Linear);
 }