Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  OpenGL Loading Texture (LWJGL)  (Read 552 times)
0 Members and 1 Guest are viewing this topic.
Offline Pawnguy7

Junior Newbie

« Posted 2014-01-18 02:07:10 »


So I decided to try learning OpenGL (again), and... for some reason am using Java, and thus LWJGL.

It went well for a while, but I am quite stuck on getting a texture to display.

I feel it is something small, but it has not become apparent to me over 12 hours, so I decided to come for help.

The image loads successfully. glGetError returns 0 (and glGenTextures returns 1 (not 0), if it matters).

I tried glTextCoordx at some point, but to no avail.

It is my understanding that there are several steps:

First, enable textures, and set several parameters (glTexParameteri).

Get an id for a new texture.

"upload" the data for it (I had a lot of trouble with this step. In the current configuration, it no longer errors with 1280 though (invalid enum)).

Bind it.

Draw stuffs.

Unbind it.

I also tried it with binding before the upload, as it seems it does not take a handle/id, but rather affects the current bound texture. No success.

What am I missing?
Offline Opiop
« Reply #1 - Posted 2014-01-18 02:09:35 »

Offline Pawnguy7

Junior Newbie

« Reply #2 - Posted 2014-01-18 02:28:43 »

That was what I was trying to follow, yes. If I use the vertices and texture coordinates provided, it still does not use the texture.

Do you think I should use the exact code of the tutorial, to see if it works, then modify?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Opiop
« Reply #3 - Posted 2014-01-18 02:42:49 »

Yes you should use the exact code. That's why its a tutorial. I use it all the time, it works fine.

Offline Pawnguy7

Junior Newbie

« Reply #4 - Posted 2014-01-18 03:23:10 »

Ok. Tried that. With some modifications (file loading was amiss, and the videomode creation crashed it), it works.

Theoretically I can keep this close and try it again on the side, and see which steps I am missing. Hopefully I get it working.

Did you, when learning, have difficulties with glTexImage2D? It feels rather fragile, I am not positive when the data is correct or not.
Offline Opiop
« Reply #5 - Posted 2014-01-18 03:27:52 »

No I didn't, it really is kind of straight forward. Just take a look at the LWJGL docs and look at all the parameters and really learn what they mean, you'll get it after you study it for a few minutes!

Besides, I wrote my texture class once and have never had to mess with it again. Once you get texture loading working, you really don't have to mess with it again. So just make it work and never look back unless you have issues!

Offline theagentd

« JGO Bitwise Duke »

Medals: 564
Projects: 4
Exp: 8 years

« Reply #6 - Posted 2014-01-19 02:28:07 »

Did you, when learning, have difficulties with glTexImage2D? It feels rather fragile, I am not positive when the data is correct or not.
Nope. If something goes wrong you'll either get an error (you do call glGetError() regularly, right?) or crash the VM.

The most common reason for textures "not loading" is forgetting to set the filtering mode. By default OpenGL expects mipmaps, so you need to either set the max mipmap level (GL_TEXTURE_MAX_LEVEL) or change the min filtering mode (GL_TEXTURE_MIN_FILTER) to a mode that doesn't require mipmaps. Just a hint...

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

BurntPizza (28 views)
2015-10-08 03:11:46

BurntPizza (16 views)
2015-10-08 00:30:40

BurntPizza (19 views)
2015-10-07 17:15:53

BurntPizza (32 views)
2015-10-07 02:11:23

KaiHH (38 views)
2015-10-06 20:22:20

KaiHH (16 views)
2015-10-06 19:41:59

BurntPizza (32 views)
2015-10-06 19:04:48

basil_ (46 views)
2015-09-30 17:04:40

shadowstryker (25 views)
2015-09-29 15:55:06

TheSpaceHedgehog (31 views)
2015-09-29 01:58:48
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!