com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20 Java Examples

The following examples show how to use com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FluidSimulatorSPH.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
private void createWorld() {
		dropRadius = 0.1f + dropRadiusK;
		dropRadiusPixel = (int) (dropRadius * PARTICLE_SIZE);
		dropRadiusPixel2 = dropRadiusPixel * dropRadiusPixel;
		if (IS_DESKTOP) {
//			dropTexture = new Texture("data/fluid_drop_red_64.png");
			dropTexture = new Texture("data/fluid_drop_64.png");
			dropTexture2 = new Texture("data/fluid_drop_blue_64.png");
			dropSprite = new Sprite(dropTexture);
			dropSprite.setSize(dropRadiusPixel, dropRadiusPixel);
		}
		if (IS_DESKTOP) {
			disposableParticles = new ArrayList<Particle>(SIZE);
		}
		defaultShader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), 
				Gdx.files.internal("data/shaders/default.frag").readString());
		if (!defaultShader.isCompiled()) {
			Gdx.app.log("SHADER_LOG", "couldn't compile scene shader: " + defaultShader.getLog());
		}
		immediateRenderer = new ImmediateModeRenderer20(50000, false, true, 0);

		// On Android populate directly
		if (!IS_DESKTOP) {
			for (float j = INITIAL_HEIGHT + hpadding + 2; j < WORLD_HEIGHT - 2; j += 1.0f) {
				for (float i = -WORLD_WIDTH / 3; i < WORLD_WIDTH / 3; i += 1.0f) {
					particles.add(new Particle(i, j));
					tempParticle = particles.get(particles.size() - 1);
					tempParticle.type = (emitType);
					if (particles.size() >= ANDROID_SIZE)
						return;
				}
			}
		}
	}
 
Example #2
Source File: FluidSimulatorGeneric.java    From fluid-simulator-v2 with Apache License 2.0 5 votes vote down vote up
public FluidSimulatorGeneric(FluidSimulatorStarter fluidSimulatorStarter) {
		this.game = fluidSimulatorStarter;
		// LibGDX single batches cannot have a size more than 5460
		batch = new SpriteBatch(IS_DESKTOP ? 5460 : ANDROID_SIZE);
		font = new BitmapFont();
		camera = new OrthographicCamera(WORLD_WIDTH, WORLD_HEIGHT);
		camera.position.set(0, (WORLD_HEIGHT / 2) - 1, 0);
		immediateRenderer = new ImmediateModeRenderer20(SIZE*6, false, true, 0);
		irt = new Renderer20(SIZE*6, false, true, 1);
		irt2 = new ImmediateModeRenderer20(SIZE*11, false, true, 1);
		shapeRenderer = new ShapeRenderer(SIZE);
		renderer = new Box2DDebugRenderer(true, true, false, true, false, false);
		
		//3D
		camera3D = new PerspectiveCamera(67, WORLD_WIDTH, WORLD_HEIGHT);
		camera3D.position.set(0, 130f, 250f);
		camera3D.lookAt(0,150f,0);
		camera3D.near = 0.1f;
		camera3D.far = 500f;
		camera3D.update();
		ModelBuilder modelBuilder = new ModelBuilder();
//        model = modelBuilder.createSphere(5f, 5f, 5f, 4, 4, GL10.GL_TRIANGLES,
//                new Material(ColorAttribute.createDiffuse(Color.GREEN)),
//                Usage.Position | Usage.Normal);
        model = modelBuilder.createBox(5f, 5f, 5f,
            new Material(ColorAttribute.createDiffuse(Color.GREEN)),
            Usage.Position | Usage.Normal);
        instance = new ModelInstance(model);
        modelBatch = new ModelBatch();
        environment = new Environment();
        environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
        environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0, -0.8f, -0.2f));
        camController = new Camera3DController(camera3D);
        camController.setFluidSimulator(this);
		
		world = new World(new Vector2(0, -9.8f), false);
		world.setContactListener(this);
	}