1
\$\begingroup\$

In the GL30 interface, both the methods glClear() and glClearColor() are absent. I tried to call the method Gdx.gl30.glClear(GL30.GL_COLOR_BUFFER_BIT) inside render() but it threw me a null pointer exception. So I checked the interface. There's no glClear() method in GL30. Only in GL20. But OpenGL documentation says that they are supported in both v2.0 and v3.0. Why is it not included in LibGDX?

\$\endgroup\$
10
  • \$\begingroup\$ Could you include the code that you're trying to use that isn't working? \$\endgroup\$
    – user5665
    Jul 26, 2016 at 12:33
  • 1
    \$\begingroup\$ Maybe LibGDX doesn't separate GL functions by version ? So it will be something like LIB.gl.glClear() ? \$\endgroup\$
    – Russoul
    Jul 26, 2016 at 12:38
  • \$\begingroup\$ @MattJensJensen I tried to call the method Gdx.gl30.glClear(GL30.GL_COLOR_BUFFER_BIT); inside render() but it threw me a null pointer exception. So I checked the interface. There's no glClear() method in GL30. Only in GL20. \$\endgroup\$
    – Neerkoli
    Jul 26, 2016 at 12:45
  • \$\begingroup\$ @Russoul But the gl in Gdx is a GL20 object. \$\endgroup\$
    – Neerkoli
    Jul 26, 2016 at 12:47
  • 1
    \$\begingroup\$ Have you set config.useGL30 = true? \$\endgroup\$
    – user5665
    Jul 26, 2016 at 12:48

2 Answers 2

1
\$\begingroup\$

LibGDX is primary written in java, so it binds OpenGL functions to java methods. In the process of binding LibGDX is not required to keep original namespaces (java's equivalent of c/c++ namespace is package). LibGDX has a few classes which contain bindings to OpenGL functions and fields. Those classes extend each other: class containing bindings to the most recent supported version of OpenGL inherits a class with a prior version.

Lastly, GDX instantiates the last subclass so you can call any GL function from there not bothering about which specification of OpenGL implements it.

Also ,as said in another answer, you should config GDX to enable functions of OpenGL 3.0:

config.useGL30 = true;
\$\endgroup\$
3
\$\begingroup\$

You must configure GDX to use GL30 prior to calling functions on Gdx.gl30:

config.useGL30 = true;

com.badlogic.gdx.graphics.GL30 does not contain glClear and glClearColor in its interface because it is a subclass of com.badlogic.gdx.graphics.GL20 and those functions are inherited from GL20 therefore there is no need to define them in GL30's interface.

See the Gdx docs for Methods inherited from interface com.badlogic.gdx.graphics.GL20.

\$\endgroup\$
2
  • \$\begingroup\$ This solved the null pointer exception. Thanks! But it doesn't really answer the question I asked. \$\endgroup\$
    – Neerkoli
    Jul 26, 2016 at 17:56
  • \$\begingroup\$ I've added the additional answer for those elements in your question. \$\endgroup\$
    – user5665
    Jul 26, 2016 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .