Hello Guest

Texture loading issus with glu

  • 3 Replies
  • 5993 Views
Texture loading issus with glu
« on: January 07, 2012, 22:29:32 »
Im trying to follow along with the NeHe tutorials and im trying to load a texture. Since devil is no longer supported I have tried using slick to load textures.  It works fine when I use this code
Code: [Select]
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, 800, 0, 600, 1, -100);
GL11.glMatrixMode(GL11.GL_MODELVIEW);

but not this code which is what the tutorials use.
Code: [Select]
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(
    45.0f,
    (float) displayMode.getWidth() / (float) displayMode.getHeight(),
    0.1f,
    100.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);

Is there a way to make the slick texture loading work with the glu code or is there another way I can load textures?
« Last Edit: January 07, 2012, 22:31:27 by sublixt »

Re: Texture loading issus with glu
« Reply #1 on: January 09, 2012, 13:47:09 »
None of the code you posted will affect textures at all.
The difference between the two is probably that in the first one you can see what was drawn on the screen (which might use the texture) and in the other one you can't.
The second one uses a perspective view. If the tutorial is doing 2D rendering, then there is no use for a perspective view anyways.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Re: Texture loading issus with glu
« Reply #2 on: January 09, 2012, 16:09:54 »
Im new to lwjgl and opengl in general. Can you tell me what the difference between perspective and ortho is?

Re: Texture loading issus with glu
« Reply #3 on: January 09, 2012, 17:56:30 »
A perspective view is how we normally see objects (objects that are further away look smaller) and orthographic is where all objects are the same size no matter how far away they are.
The way it can make what is drawn on screen disappear is because in your first call (glOrtho) you are making a view that shows units from (0 to 800) and (0 to 600). No matter how far away from the camera the object is, if it is in that range it will appear.
However, in perspective mode your visible units change depending on how close the object is to the camera (e.g. when one unit away, the range might be (-2 to +2) and (-2 to +2) ). If your object was at (100,100) then it would appear in the glOrtho, but not in the perspective view.

Someone else can probably explain it better. ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D