예제 #1
0
	void Render(double time)
	{
		std::size_t metaball_count = ball_paths.size(), k = 0;
		std::vector<GLfloat> metaballs(metaball_count*4);
		for(std::size_t ball=0; ball != metaball_count; ++ball)
		{
			Vec4f pos = ball_paths[ball].Position(time / 10.0);

			for(std::size_t coord=0; coord != 4; ++coord)
				metaballs[k++] = pos.At(coord);
		}

		Texture::Image1D(
			Texture::Target::_1D,
			0,
			PixelDataInternalFormat::RGBA32F,
			metaball_count,
			0,
			PixelDataFormat::RGBA,
			PixelDataType::Float,
			metaballs.data()
		);
		gl.Clear().DepthBuffer();
		gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
	}
예제 #2
0
    void UpdateMetaballs(double time) {
        std::size_t metaball_count = ball_paths.size(), k = 0;
        std::vector<GLfloat> metaballs(metaball_count * 4);
        for(std::size_t ball = 0; ball != metaball_count; ++ball) {
            Vec4f pos = ball_paths[ball].Position(time / 21.0);

            for(GLuint coord = 0; coord != 4; ++coord)
                metaballs[k++] = pos.At(coord);
        }

        gl.Bound(Texture::Target::_1D, metaballs_tex)
          .Image1D(
            0,
            PixelDataInternalFormat::RGBA32F,
            metaball_count,
            0,
            PixelDataFormat::RGBA,
            PixelDataType::Float,
            metaballs.data());
    }