简体   繁体   中英

Pixmap circle border doesn't appear in libGDX html project

I'm programming my first project with libGDX and I'm currently trying to draw a transparent circle with an opaque border on top of the background. It's working as desired in the android an the desktop project. The html project, however, doesn't render the border of the circle.

html项目上没有边框

The circle is a texture which is created with a pixmap. As there is no possibility to set the strokewidth for the drawCircle method (why isn't there any?; see http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Pixmap.html#drawCircle-int-int-int- ), I'm drawing the border as a filledCircle with another circle on top of it:

  1. creating the texture

    Pixmap pixmap = new Pixmap(radius * 2 + 1, radius * 2 + 1, Format.RGBA8888); Pixmap.setBlending(Blending.None); pixmap.setColor(new Color(1,1,1,1)); pixmap.fillCircle(radius, radius, radius); pixmap.setColor(new Color(0, 0, 0, 0.6f); pixmap.fillCircle(radius, radius, radius - borderWidth); texture = new Texture(pixmap); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); pixmap.dispose();

  2. drawing

     Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0)); // tell the camera to update its matrices. camera.update(); game.spriteBatch.setProjectionMatrix(camera.combined); // begin the drawing process game.spriteBatch.begin(); drawBackground(); //circle gets drawn here game.spriteBatch.draw(texture, 50, 50); //end drawing process game.spriteBatch.end(); 

Any ideas?

Edit: Tested on Chrome (35.0.1916.153) and Firefox (30.0) on Ubuntu 14.04. Can anybody reproduce this problem?

You need to disable blending before drawing a circle:

pixmap.setBlending(Pixmap.Blending.None);
pixmap.fillCircle(radius, radius, radius);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM