Using lwjgl methods with libgdx

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

Using lwjgl methods with libgdx

Postby Hakkai » Mon May 27, 2013 7:51 pm

Hello guys, I have one question, so, how I can use lwjgl functions(for ex.: GL11.glLight(...)) with libgdx functions? Do I need do opengl initialization like glViewport?
Hakkai
 
Posts: 5
Joined: Mon May 27, 2013 7:47 pm

Re: Using lwjgl methods with libgdx

Postby davedes » Mon May 27, 2013 9:42 pm

LibGDX has its own GL interfaces for GL ES. There is GL10, GL11, GL20, and GLCommon. GL20 is only available if if useGL20 is set to true in the app config (and GL 2.x+ is available). If Gdx.gl20 is available (non-null), then Gdx.gl10/gl11 will be null -- and vice versa. Gdx.gl is always non-null.

Usage example:
Code: Select all
//if gl20 exists, gl10 and gl11 will be null
if (Gdx.graphics.isGL20Available()) {
    Gdx.gl20.glXXXX(...);
}
//otherwise, gl20 will be null
else {
    Gdx.gl10.glXXXX(...);
    Gdx.gl11.glXXXX(...);
}

//GLCommon is never null
//you should use it for things like glBlendFunc and other functions that are not deprecated
Gdx.gl.glXXXX


You can find glLight in GL10. This is generally not a good idea since the code isn't very portable (i.e. does not run with GLES20). glLight is deprecated in modern OpenGL and in OpenGL ES 2+.

If you want to call desktop-specific GL stuff (like geometry shaders) you would need to write your own path for that. e.g. If you only want to support the LWJGL backend, you can simply link the LWJGL jars/natives with your project and call the LWJGL GL interfaces directly.
davedes
 
Posts: 434
Joined: Thu Oct 11, 2012 7:51 pm

Re: Using lwjgl methods with libgdx

Postby Hakkai » Tue May 28, 2013 5:00 am

yes, but I tried use GL11.glBegin(GL11.GL_QUADS)...GL11.glEnd() and it doesn't work without initialization like GL11.glViewport(...) glOrtho(...). Is it ok? And I doesn't add library lwjgl, because it's included. and imports GL11 of course from org.lwjgl...
Hakkai
 
Posts: 5
Joined: Mon May 27, 2013 7:47 pm

Re: Using lwjgl methods with libgdx

Postby Hakkai » Tue May 28, 2013 5:06 am

And I'm using Gdx.gl20 with shaders, but I need some functions from gl11 like glPushMatrix and glTranslate etc...
Hakkai
 
Posts: 5
Joined: Mon May 27, 2013 7:47 pm

Re: Using lwjgl methods with libgdx

Postby Hakkai » Tue May 28, 2013 7:27 am

and how I can use display lists with libgdx?
Hakkai
 
Posts: 5
Joined: Mon May 27, 2013 7:47 pm

Re: Using lwjgl methods with libgdx

Postby davedes » Wed May 29, 2013 3:25 am

glBegin/glEnd relies on the fixed function matrix stack and glOrtho. In GL20 (programmable pipeline) you can't use the fixed function stack or methods like glPushMatrix. Instead you work with your own matrices -- LibGDX provides Vector2/Matrix3/etc. Generally you would use the LibGDX Camera classes which help you.

Display lists are also deprecated, and not included in LWJGL.

It sounds like you are just copying code from somewhere? What are you trying to achieve exactly?
davedes
 
Posts: 434
Joined: Thu Oct 11, 2012 7:51 pm

Re: Using lwjgl methods with libgdx

Postby Hakkai » Wed May 29, 2013 4:51 am

I'm just learning libgdx. So ok, I understood all, thank you. I like OpenGL 1 because it's very easy, but right now I understanding how it's outdated and not modern.

And display lists are included in the original lwjgl(v.2.9.0)
Hakkai
 
Posts: 5
Joined: Mon May 27, 2013 7:47 pm

Re: Using lwjgl methods with libgdx

Postby kalle_h » Wed May 29, 2013 8:09 am

Display list are slow. No reason ever to use them anymore.
kalle_h
 
Posts: 637
Joined: Thu Dec 29, 2011 9:50 pm


Return to General Development

Who is online

Users browsing this forum: No registered users and 0 guests

cron