Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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  
  LWJGL basic problem with texture  (Read 1291 times)
0 Members and 1 Guest are viewing this topic.
Offline akzyl

Senior Newbie





« Posted 2012-01-25 21:58:05 »

Hello.
I decide to learn LWJGL and now after few basic tutorials I wont to load my first texture.
My first step was copy paste this code
http://lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_1_-_Loading_Images_for_LWJGL
and unfortunately I have problem namely
http://img546.imageshack.us/img546/6348/picsk.png
as you can see there are some strength line.
Size loaded texture is 40x40 and system out
1  
2  
3  
4  
5  
>> Image width: 40
>> Image height: 40
>> Texture width: 64
>> Texture height: 64
>> Texture ID: 1

for me it looks like object texture is too big but I could be wrong, so how to fix this?
Online princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2012-01-25 22:15:23 »

What's it supposed to look like?

Cas Smiley

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #2 - Posted 2012-01-25 22:17:42 »

You're using a non power of two texture, which isn't supported by opengl like you are using it.

Just use textures which are power of two sizes is the simplest solution. A bit more fiddling is needed to support non power of two textures but it is possible.

Its a common problem people run into when starting with opengl, just google for it, plenty of solutions out there.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline akzyl

Senior Newbie





« Reply #3 - Posted 2012-01-25 22:27:24 »

What's it supposed to look like?

Cas Smiley
Without this blue line in yellow circles
http://img849.imageshack.us/img849/5126/pic1cu.png

kappa
I found, thanks.
Offline theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #4 - Posted 2012-01-26 03:17:02 »

 - The texture loader you use makes the resulting texture dimensions a power of two.
 - The lines are due to filtering. The standard wrap setting is GL_REPEAT which means that if you were to send in a texture coordinate that is higher than 1.0 or lower than 0.0 then it would simply repeat the texture multiple times over the triangle. This combined with linear filtering causes the right edge to possible get mixed together with the left edge even if you have texture coordinates that are NOT over 1.0 or under 0.0 due to  bilinear filtering catching the closest 4 texture samples and mixing them. In your case simply changing the wrap mode to GL_CLAMP_TO_EDGE (in GL12) which is a special wrap mode that disallows any wrapping between the texture edges.

You're using a non power of two texture, which isn't supported by opengl like you are using it.
Wrong since 2003. Support for NPOT textures is even integrated in core in OpenGL 2.0.

Just use textures which are power of two sizes is the simplest solution. A bit more fiddling is needed to support non power of two textures but it is possible.
No fiddling  at all if you do manual loading. Just don't calculate power of two dimensions and supply the data just like normal to glTex2D. Where's the fiddling? Okay, you do have to keep your dimension sizes to multiples of 4 unless you write a single line to change unpack alignment to 1. -_- This also saves memory.

Myomyomyo.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #5 - Posted 2012-01-26 11:48:56 »

You're using a non power of two texture, which isn't supported by opengl like you are using it.
Wrong since 2003. Support for NPOT textures is even integrated in core in OpenGL 2.0.
Sure, but my reply is referring to how akzyl was trying to make it work (his code only uses OpenGL 1.1).

No fiddling  at all if you do manual loading. Just don't calculate power of two dimensions and supply the data just like normal to glTex2D. Where's the fiddling? Okay, you do have to keep your dimension sizes to multiples of 4 unless you write a single line to change unpack alignment to 1. -_- This also saves memory.
However he is not manually loading it but using Slick-Util which does require some fiddling Smiley
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.

trollwarrior1 (31 views)
2014-11-22 12:13:56

xFryIx (72 views)
2014-11-13 12:34:49

digdugdiggy (51 views)
2014-11-12 21:11:50

digdugdiggy (45 views)
2014-11-12 21:10:15

digdugdiggy (39 views)
2014-11-12 21:09:33

kovacsa (63 views)
2014-11-07 19:57:14

TehJavaDev (68 views)
2014-11-03 22:04:50

BurntPizza (66 views)
2014-11-03 18:54:52

moogie (81 views)
2014-11-03 06:22:04

CopyableCougar4 (81 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!