ImmediateModeRenderer with SpriteBatch

Anything libgdx related goes here!

ImmediateModeRenderer with SpriteBatch

Postby aksarfevad » Wed Dec 29, 2010 2:10 am

I'm just trying to run a simple test that has both a Sprite Batch and an ImmediateModeRenderer. When I add the Sprite Batch in, the ImmediateModeRenderer doesn't draw anything. I tried disabling/enabling a bunch of stuff but still can't figure out what I'm doing wrong. Any tips?

Code: Select all
    @Override public void render () {
       Gdx.graphics.getGL10().glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
       
        float width = (float)testRegion.getRegionWidth()/Gdx.graphics.getWidth();
        float height = (float)-testRegion.getRegionHeight()/Gdx.graphics.getHeight();
                   
        spriteBatch.begin();
            font.draw(spriteBatch, "size: " + width + ", " + height, 20, 25);
        spriteBatch.end();
       
        renderer.begin(GL10.GL_LINE_STRIP);
           renderer.color(1, 0, 0, 1);
           renderer.vertex(-width/2, -height/2, 0);
           renderer.color(1, 0, 0, 1);
           renderer.vertex(-width/2, height/2, 0);
           renderer.color(1, 0, 0, 1);
           renderer.vertex(width/2, height/2, 0);
           renderer.color(1, 0, 0, 1);
           renderer.vertex(width/2, -height/2, 0);
           renderer.color(1, 0, 0, 1);
           renderer.vertex(-width/2, -height/2, 0);
        renderer.end();
    }
aksarfevad
 
Posts: 275
Joined: Fri Nov 19, 2010 4:19 am

Re: ImmediateModeRenderer with SpriteBatch

Postby consiliens » Wed Dec 29, 2010 2:23 am

Maybe IsometricTileTest which uses ImmediateModeRenderer and SpriteCache will help?
consiliens
 
Posts: 177
Joined: Wed Oct 27, 2010 6:55 am

Re: ImmediateModeRenderer with SpriteBatch

Postby aksarfevad » Wed Dec 29, 2010 3:30 am

Hmm... well I found a better way to test for now. If anyone knows what is wrong off the top of their head it might help others.
aksarfevad
 
Posts: 275
Joined: Fri Nov 19, 2010 4:19 am

Re: ImmediateModeRenderer with SpriteBatch

Postby BurningHand » Wed Dec 29, 2010 4:00 am

I did an ImmediateModeRenderer + SpriteBatch today with no problems.

I always use a camera:

Code: Select all
   @Override
   public void render()
   {
                // Where Camera is OthographicCamera

      Camera.update();
      Camera.setMatrices();
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      
      HexDebugRenderer.RenderHexes(Board.hexes); // Uses ImmediateModeRenderer to draw Hex Tiles as GL_LINES

        SpriteBatch.setProjectionMatrix(Camera.getCombinedMatrix());
        SpriteBatch.begin();

        Sprite.draw(SpriteBatch);

                SpriteBatch.end();
        }
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2812
Joined: Mon Oct 25, 2010 4:35 am


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest