Search in sources :

Example 1 with ImmediateModeRenderer20

use of com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20 in project libgdx by libgdx.

the class ImmediateModeRendererTest method create.

@Override
public void create() {
    renderer = new ImmediateModeRenderer20(false, true, 1);
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
}
Also used : ImmediateModeRenderer20(com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20) Texture(com.badlogic.gdx.graphics.Texture)

Example 2 with ImmediateModeRenderer20

use of com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20 in project libgdx by libgdx.

the class PathTest method create.

@Override
public void create() {
    renderer = new ImmediateModeRenderer20(false, false, 0);
    spriteBatch = new SpriteBatch();
    obj = new Sprite(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    obj.setSize(40, 40);
    obj.setOriginCenter();
    obj2 = new Sprite(new Texture(Gdx.files.internal("data/bobrgb888-32x32.png")));
    obj2.setSize(40, 40);
    obj2.setOriginCenter();
    // 96DP
    ZIGZAG_SCALE = Gdx.graphics.getDensity() * 96;
    float w = Gdx.graphics.getWidth() - obj.getWidth();
    float h = Gdx.graphics.getHeight() - obj.getHeight();
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, h)));
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(0, h), new Vector2(w, h)));
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h)));
    Vector2[] cp = new Vector2[] { new Vector2(0, 0), new Vector2(w * 0.25f, h * 0.5f), new Vector2(0, h), new Vector2(w * 0.5f, h * 0.75f), new Vector2(w, h), new Vector2(w * 0.75f, h * 0.5f), new Vector2(w, 0), new Vector2(w * 0.5f, h * 0.25f) };
    paths.add(new BSpline<Vector2>(cp, 3, true));
    paths.add(new CatmullRomSpline<Vector2>(cp, true));
    pathLength = paths.get(currentPath).approxLength(500);
    avg_speed = speed * pathLength;
    Gdx.input.setInputProcessor(this);
}
Also used : ImmediateModeRenderer20(com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) Vector2(com.badlogic.gdx.math.Vector2) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 3 with ImmediateModeRenderer20

use of com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20 in project nhglib by VoidZombie.

the class Main method engineStarted.

@Override
public void engineStarted() {
    super.engineStarted();
    Nhg.debugLogs = true;
    Gdx.input.setCursorCatched(true);
    world = new NhgWorld(nhg.messaging, nhg.entities, nhg.assets, new DefaultWorldStrategy(), new Bounds(2f, 2f, 2f));
    fpsLogger = new FPSLogger();
    renderer20 = new ImmediateModeRenderer20(false, true, 0);
    nhg.input.addListener(this);
    nhg.assets.queueAsset(new Asset("scene", "myscene.nhs", Scene.class));
    nhg.assets.queueAsset(new Asset("inputMap", "input.nhc", JsonValue.class));
    GraphicsSystem graphicsSystem = nhg.entities.getEntitySystem(GraphicsSystem.class);
    graphicsSystem.setClearColor(Color.GRAY);
    Environment environment = graphicsSystem.getEnvironment();
    GammaCorrectionAttribute gammaCorrectionAttribute = new GammaCorrectionAttribute();
    gammaCorrectionAttribute.gammaCorrection = true;
    environment.set(gammaCorrectionAttribute);
    // Subscribe to asset events
    nhg.messaging.get(Strings.Events.assetLoaded, Strings.Events.assetLoadingFinished).subscribe(new Consumer<Message>() {

        @Override
        public void accept(Message message) throws Exception {
            if (message.is(Strings.Events.assetLoaded)) {
                Asset asset = (Asset) message.data.get(Strings.Defaults.assetKey);
                if (asset.is("scene")) {
                    scene = nhg.assets.get(asset);
                    world.loadScene(scene);
                    world.setReferenceEntity("camera");
                    ModelBuilder mb = new ModelBuilder();
                    Model planeModel = mb.createBox(2f, 0.01f, 20f, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates);
                    int plane = scene.sceneGraph.createSceneEntity("plane");
                    scene.sceneGraph.addSceneEntity(plane);
                    ModelComponent modelComponent = nhg.entities.createComponent(plane, ModelComponent.class);
                    modelComponent.initWithModel(planeModel);
                    NodeComponent nodeComponent = nhg.entities.getComponent(plane, NodeComponent.class);
                    nodeComponent.setTranslation(0, 0, 0, true);
                    Integer cameraEntity = scene.sceneGraph.getSceneEntity("camera");
                    cameraNode = nhg.entities.getComponent(cameraEntity, NodeComponent.class);
                } else if (asset.is("inputMap")) {
                    nhg.input.fromJson((JsonValue) nhg.assets.get(asset));
                    nhg.input.setActiveContext("game", true);
                    nhg.input.setActiveContext("global", true);
                }
            }
        }
    });
}
Also used : NhgWorld(io.github.voidzombie.nhglib.graphics.worlds.NhgWorld) Message(io.github.voidzombie.nhglib.runtime.messaging.Message) GammaCorrectionAttribute(io.github.voidzombie.nhglib.graphics.shaders.attributes.GammaCorrectionAttribute) Bounds(io.github.voidzombie.nhglib.utils.data.Bounds) JsonValue(com.badlogic.gdx.utils.JsonValue) Material(com.badlogic.gdx.graphics.g3d.Material) Scene(io.github.voidzombie.nhglib.graphics.scenes.Scene) FPSLogger(com.badlogic.gdx.graphics.FPSLogger) ImmediateModeRenderer20(com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) ModelComponent(io.github.voidzombie.nhglib.runtime.ecs.components.graphics.ModelComponent) DefaultWorldStrategy(io.github.voidzombie.nhglib.graphics.worlds.strategies.impl.DefaultWorldStrategy) Model(com.badlogic.gdx.graphics.g3d.Model) NodeComponent(io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent) Asset(io.github.voidzombie.nhglib.assets.Asset) GraphicsSystem(io.github.voidzombie.nhglib.runtime.ecs.systems.impl.GraphicsSystem) Environment(com.badlogic.gdx.graphics.g3d.Environment)

Aggregations

ImmediateModeRenderer20 (com.badlogic.gdx.graphics.glutils.ImmediateModeRenderer20)3 Texture (com.badlogic.gdx.graphics.Texture)2 FPSLogger (com.badlogic.gdx.graphics.FPSLogger)1 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 Environment (com.badlogic.gdx.graphics.g3d.Environment)1 Material (com.badlogic.gdx.graphics.g3d.Material)1 Model (com.badlogic.gdx.graphics.g3d.Model)1 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)1 Vector2 (com.badlogic.gdx.math.Vector2)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 Asset (io.github.voidzombie.nhglib.assets.Asset)1 Scene (io.github.voidzombie.nhglib.graphics.scenes.Scene)1 GammaCorrectionAttribute (io.github.voidzombie.nhglib.graphics.shaders.attributes.GammaCorrectionAttribute)1 NhgWorld (io.github.voidzombie.nhglib.graphics.worlds.NhgWorld)1 DefaultWorldStrategy (io.github.voidzombie.nhglib.graphics.worlds.strategies.impl.DefaultWorldStrategy)1 ModelComponent (io.github.voidzombie.nhglib.runtime.ecs.components.graphics.ModelComponent)1 NodeComponent (io.github.voidzombie.nhglib.runtime.ecs.components.scenes.NodeComponent)1 GraphicsSystem (io.github.voidzombie.nhglib.runtime.ecs.systems.impl.GraphicsSystem)1 Message (io.github.voidzombie.nhglib.runtime.messaging.Message)1