Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  libdgx - Shaperenderer - Opacity  (Read 1948 times)
0 Members and 1 Guest are viewing this topic.
Offline Phibedy

Senior Devvie


Medals: 9



« Posted 2012-12-31 08:31:53 »

Hi, I am wondering about the Shaperenderer: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html
1  
2  
3  
4  
5  
6  
shapeRenderer.begin(ShapeType.FilledCircle);
          shapeRenderer.setColor(0, 0, 0.4f, 0.3f);
          shapeRenderer.filledCircle(100,100,20);
          shapeRenderer.setColor(1, 1, 0, 0.3f);
          shapeRenderer.filledCircle(100,100,10);
          shapeRenderer.end();


Normally I would use the spritebatch for drawing, but this time I just want to draw a circle that contains another circle with a different color. In addition the one on the bottom shouldshow through the other. I just don't get it who to enable the alpha-"function" / if you google it, it always shows articles about the spritebatcher.
I thought
1  
2  
Gdx.graphics.getGL10().glEnable(GL10.GL_BLEND);
           Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
would manage it, but "glEnable(GL10.GL_BLEND)" throws nullpointer..
I am new to opengl-fun and that's absolutely confusing me, I just don't get what I am doing wrong  Roll Eyes
thx for help and patience Smiley
Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2012-12-31 09:14:05 »

Try:
1  
Gdx.gl.glEnable(GL10.GL_BLEND);

But note you should end any begins before doing more drawing if you change blending.

Offline Phibedy

Senior Devvie


Medals: 9



« Reply #2 - Posted 2012-12-31 09:21:53 »

1  
2  
3  
4  
Gdx.gl.glClearColor(1, 1, 1, 1);
       Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
       Gdx.graphics.getGL10().glEnable(GL10.GL_BLEND);
            Gdx.graphics.getGL10().glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

I don't think that I am drawing sth at the moment or do I missunderstand it?
best regards

edit: Got it, although shaderrenderer uses gl10 I have to modify gl20  persecutioncomplex
Does someone know why?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #3 - Posted 2012-12-31 15:42:49 »

edit: Got it, although shaderrenderer uses gl10 I have to modify gl20  persecutioncomplex
Does someone know why?

My only guess would be you enabled gl2 in the config (@launcher)

Also keep in mind shapeRenderer is slow and only for debug stuff - an unfortunate reality, you kinda have to do this stuff yourself if you need it (drawline, drawrect, fillCircle, whatever) - I do it with stretched images

Offline davedes
« Reply #4 - Posted 2012-12-31 15:54:49 »

You should use Gdx.gl or Gdx.graphics.getGLCommon() for functions that are shared by both GL10 and GL20. That way your code is independent of GL version. Smiley If useGL20 is true, then Gdx.gl10 will return null.

Of course, it doesn't matter if you use GL10 or GL20 for static constants (like GL_BLEND), since those will never be null.

As said, ShapeRenderer is not the fastest, but it will probably do fine for most purposes. Another downside is that it relies on hardware anti-aliasing; it varies from device to device, and some don't support it at all.

Also note that if you need lines or rectangles, you can use a regular SpriteBatch; see here.

If you need better performance (i.e. Android), you should look into using images, or if you fancy something slightly more advanced, read up on shaders. Smiley

Offline Phibedy

Senior Devvie


Medals: 9



« Reply #5 - Posted 2012-12-31 17:27:44 »

thx for explanation Smiley
The shaperenderer is just for prealpha-test-debugging-version. In the future I am not sure if I will use spritebatches or shaders. Spritebatches are very easy to use Cheesy
I already did that tut, but I think I have to read more about shaders if I want to use them  Grin
Especially because from es 1.0 to 2.0 are some creepy changes and at the moment I often confuse the functions and wonder about the result Grin
I just started learning opengl and maybe I did to big steps so I might haven't understood everything I thought I understood  Roll Eyes
best regards
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (9 views)
2014-11-28 16:25:09

PocketCrafter7 (10 views)
2014-11-28 16:24:29

toopeicgaming1999 (76 views)
2014-11-26 15:22:04

toopeicgaming1999 (67 views)
2014-11-26 15:20:36

toopeicgaming1999 (16 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!