DargPhoenix
DargPhoenix

Reputation: 1

Java OpenGL Syntax

i am new here and have a little problem. I included OpenGl into eclipse and tried to run a little test program and everything is working fine as it should, but i have a problem with the syntax.

Here is a little example :

GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(45, (float)Display.getWidth()/(float)Display.getHeight(), 0.3f,1000f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);

As far as i remember i didnt have to call the GL version everytime and should look like this :

glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLU.gluPerspective(45, (float)Display.getWidth()/(float)Display.getHeight(), 0.3f, 1000f);
glMatrixMode(GL_MODELVIEW);

I havnt found any answer out there because for everyone it seems to work from scratch. I start to believe that i did a mistake while including opengl into eclipse but i did it like i did it back at university.

java build path

Hopefully someone knows what i can do or not do :D

I tried following tutorials on youtube and they all use the second codeblock and even if i follow the same libraries it doesnt work for me while it works in the tutorial ??? I tried different build paths and didnt change anything. I tried to change the library version but didnt do anything either.

Upvotes: -2

Views: 102

Answers (1)

Bohemian
Bohemian

Reputation: 425348

To reference static methods with qualifying them with the class name, eg glEnable(x) instead of GL11.glEnable(x), you must import the static methods, either individually or all of them:

import static fully.qualified.path.GL11.*;

Upvotes: 0

Related Questions