Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 289 times)
0 Members and 1 Guest are viewing this topic.
Offline Pawnguy7

Junior Newbie





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

Greetings.

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.

http://pastebin.com/CfsnEFYr

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 opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2014-01-18 02:09:35 »

http://www.java-gaming.org/topics/lwjgl-tutorial-series-textures/30680/msg/283521/view.html

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 opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« 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 opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« 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
« 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...

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

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!