Newbie Question on Textures and OpenGL

Hi all,

I’m trying to teach myself OpenGL under the Java
platform. And I’m having alot of problems making
past the initial stages of the learning curve.

I was wondering if I can get some advice.

There are 3 OpenGL interfaces I’m using as examples
right now

  • SWT OpenGL package
  • LWJGL pacakge
  • gl4java package (Nene’s examples)

I’m looking at the example source code for
all three and I’m getting really confused…

Especially with the Textures.
I was wondering if anyone can point to a
“Dummies’ guide to OpenGL Textures” tutorial or
something.

Some Questions:
Of those examples mentioned about, do the
texture loading code only work with png files?
Does loading different formats require somesort of
conversion? If someone can point of to loading textures
of different formats that’d be great!!

I keep getting a Coordinate out of bounds! exception
when I try and use different files with the LWJGL TextureMapping Example.

Anyways, I’m pretty lost…
I’m looking at the Nene tutorials, but the way they
load the texture is very different then the LWJGL and
SWT examples…

Also, what are some advantages and disadvantages
of the 3 types of OpenGL packages ??

Anyways, Any help will be greatly appreciated.
Much thanks in advance.

Are you using the lwjgl NeHe tutorials? - if not, go here:
http://chman-area.tuxfamily.org/

The pros and cons of each package:

SWT OpenGL
Didn’t know there as a binding! So can’t help much on it.

LWJGL
Pros: about as fast as it is possible to get with Java.
Comes with OpenAL and also an input library too.
And a hires timer and some maths ops.
No dependency whatsoever on AWT.
We’re here to answer questions although with any luck we’ll move the bulk of it to puppygames :slight_smile:
Cons: scary pseudo-pointer stuff helps you on your way to crashes and unexpected behaviour galore.
Deliberately designed for writing fullscreen games and nothing else - you’re only allowed one window, and it’s probably a fullscreen one at that. You have to do everything else yourself.

GL4Java
Pros: Properly integrated with AWT - use multiple windows, mix with AWT components, etc.
Uses buffers and none of that nasty pointer stuff
Nice install.
Cons: Rumoured to have died a bit.
Relies on AWT being present hence encumbered with some bloat.
Not quite as fast as LWJGL but in percentage terms that’s irrelevant.

Cas :slight_smile:

I’m also having some problems with the Texture tutorial.
I don’t understand… how come if I take the same
tutorial, and I replace the picture with a different picture.
I don’t get the desired result?

I can a white blank texture rather than the picture I
replaced with…

Probably coz you did it wrong :wink:
More details please!

Cas :slight_smile:

[quote]I’m also having some problems with the Texture tutorial.
I don’t understand… how come if I take the same
tutorial, and I replace the picture with a different picture.
I don’t get the desired result?
[/quote]
Remember that the size of the textures must be power of two. Meaning the width and height must be one of the following: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 etc.

Which would be better for taking away from java in terms of learning? Like, if I wanted to switch to C++ OpenGL development, wouldn’t LWJGL be a better choice for keeping “shit straight”?
(just curious)

[quote]Which would be better for taking away from java in terms of learning?
[/quote]
And what should we do? - cut the texture, draw weird stuff or crash the VM? - your choice…

nech_neb: Yeah, what Tom said! A missing texture usually means the texture dimensions aren’t powers of two. You can either stretch/squash the image or pad it out, and then fix it with modified texture coordinates.

Brian: Having a bad day? ;D

PlanetMongo: OpenGL is OpenGL. What you learn of the core libraries will be the same in LWJGL, GL4Java and in the C/C++ OpenGL bindings. However, big differences will appear in things like input handling, image loading and context creation. But all the core functionality will be the same. Innit great? 8)

Ahh… My bad. I was under the impression that gl4java “hid” the OpenGL calls… My question might have been a bit misworded or misconstrued in that I was wondering which (lwjgl, gl4java) would be a better tool for learning OpenGL for usage in other languages (like, C++), if necessary. I have come to the conclusion that LWJGL fits that a bit better (as there’s no getting around pointers in C++, might as well get sorta used to them now, right?).