IContent * c2d::TileAtlasReader::read(DataStream & stream) { auto& atlas = getGraphicsDevice().getContext().getSpriteAtlas(); int nsheets = 0; stream.readInt(nsheets); atlas.reserve(nsheets); for ( int index = 0; index < nsheets; index++ ) { c2d::TileSheet& sheet = atlas.emplace(); String textureName; stream.readString(textureName); auto ptexture = getContentManager().loadContent<Graphics::Texture>(textureName); sheet.setTexture(ptexture); int nsprites = 0; stream >> nsprites; for ( int sidx = 0; sidx < nsprites; ++sidx ) { String name; c2d::TileSheet::Tile tile; stream >> name >> tile.coord.left >> tile.coord.right >> tile.coord.top >> tile.coord.bottom >> tile.rotated; sheet.add(name, tile); } } return nullptr; }
void LuckyLeprechauns::toggleWireframe() { GraphicsDevice device = getGraphicsDevice(); unsigned long fillMode = device.getRenderState(D3DRS_FILLMODE) == D3DFILL_SOLID ? D3DFILL_WIREFRAME : D3DFILL_SOLID; device.setRenderState(D3DRS_FILLMODE, fillMode); }
IContent* TextureReader::read(DataStream& stream) { if ( !hasGraphicsDevice() ) { return nullptr; } int width, height, format; stream >> width >> height >> format; BufferedStream datastream; stream.read(datastream); Graphics::TextureDescription desc; desc.width = width; desc.height = height; desc.format = Graphics::eFormat_BC3; desc.pinitData = datastream.getData(); return getGraphicsDevice().createTexture(desc); }
void PolygonRenderSetup::use() { VertexAttributePointerDescription vertexDescription; vertexDescription.location = VtxLocation; vertexDescription.size = 3; vertexDescription.type = PrimitiveType::Float; vertexDescription.normalized = false; vertexDescription.stride = sizeof(float32) * getVertexElementsCount(); vertexDescription.offset = 0; VertexAttributePointerDescription colorDescription; colorDescription.location = ColorLocation; colorDescription.size = 4; colorDescription.type = PrimitiveType::Float; colorDescription.normalized = false; colorDescription.stride = sizeof(float32) * getVertexElementsCount(); colorDescription.offset = sizeof(float32) * 3; GraphicsDevice* const graphicsDevice = getGraphicsDevice(); graphicsDevice->createVertexPointer(&vertexDescription); graphicsDevice->createVertexPointer(&colorDescription); }
void PolygonRenderSetup::clear() { GraphicsDevice* const graphicsDevice = getGraphicsDevice(); graphicsDevice->disableVertexPointer(VtxLocation); graphicsDevice->disableVertexPointer(ColorLocation); }