Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (521)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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 - screen sized background image  (Read 1156 times)
0 Members and 1 Guest are viewing this topic.
Offline LiquidNitrogen
« Posted 2014-02-23 06:04:09 »

this seems like it must be way too obvious...

i want to display a 800x600 background image on an 800x600 screen. it appears that i will have to load it into a 1024x1024 texture since non power of 2 textures dont work properly. im used to working with arbitrary image sizes and this doesnt seem like a very tidy approach. am i missing something or do i just have to start thinking differently when using opengl?

Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2014-02-23 06:05:43 »

LWJGL doesn't force you to use POT images, I don't know why you think that. You can load an 800x600 resolution image.

Offline LiquidNitrogen
« Reply #2 - Posted 2014-02-23 06:12:03 »

i think that because i was loading some 200x200 textures and they appeared with a black border around 2 sides, i assumed that it was increasing the texture size to 256x256 without scaling the texture, cos as soon as i changed my image file to 256x256 it was fine.

excuse me if im wrong, ive been sick in bed for 3 weeks and i still cant think straight Clueless

ill go and try to write the 5 lines of code it would take to verify lol

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline LiquidNitrogen
« Reply #3 - Posted 2014-02-23 07:30:08 »

i had another go at testing it out and it still appears to be loading my 800x600 image file into the nearest POT sized texture that it will fit into...

im using this to load the textures:

1  
2  
InputStream in = getClass().getResourceAsStream("res/"+name);
Texture texture1 = TextureLoader.getTexture("PNG", in);


perhaps im loading the images in the wrong way?


my rendering code seems to function perfectly fine..
1  
2  
3  
4  
      glTexCoord2f(0.0f,1.0f); glVertex2f(0.0f,0.0f);
      glTexCoord2f(1.0f,1.0f); glVertex2f(800f,0.0f);
      glTexCoord2f(1.0f,0.0f); glVertex2f(800f,600f);
      glTexCoord2f(0.0f,0.0f); glVertex2f(0.0f,600f);



if i stretch the image file to 1024x1024 in my image editor, it appears as intended in my program, but if i load it from the 800x600 file it appears to be shrunk. this is why i think its a POT issue. i cant imagine its just my graphics card because i havnt noticed this problem when running anyone elses programs.

Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #4 - Posted 2014-02-23 07:46:32 »

Well you're texture coordinates seem a little flipped, although that shouldn't matter. Can I see your TextureLoader.getTexture function?

Offline LiquidNitrogen
« Reply #5 - Posted 2014-02-23 07:55:28 »

the TextureLoader is from slickutil.

perhaps i should be using libgdx, i probably dont need the lower functionality of opengl at this point.

Offline Longarmx
« Reply #6 - Posted 2014-02-23 16:43:33 »

I believe in the texCoord you use texture.getWidth(); or texture.getHeight(); instead of 1.0f

Offline opiop65

JGO Kernel


Medals: 159
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #7 - Posted 2014-02-23 16:45:30 »

OpenGL texture coordinates are "normalized" (0.0 - 1.0). texture.getWidth() would produce the same result though because OpenGL clamps the values, so anything over 1 would still be 1. I have a feeling that's not what you're talking about though and I sound like an idiot Tongue

Offline deathpat
« Reply #8 - Posted 2014-02-23 17:15:18 »

slickutils creates power of 2 size textures in your back, that's why you have strange stretching/padding results Wink I don't remember if there is some kind of parameter to pass to the loader to disable this thing, you should check this.

OpenGL supports non POT textures for ages, so it's not an OpenGL issue.

work in progress : D A E D A L U S
Offline matheus23

JGO Kernel


Medals: 112
Projects: 3


You think about my Avatar right now!


« Reply #9 - Posted 2014-02-23 18:29:10 »

I believe in the texCoord you use texture.getWidth(); or texture.getHeight(); instead of 1.0f

I think it's texture.getImageWidth() / texture.getWidth() or something similar...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Longarmx
« Reply #10 - Posted 2014-02-23 19:05:45 »

Quote
Note the differences:
1  
2  
3  
1. Texture.getImageWidth() -> the width of the loaded image in pixels for glVertex2f (e.g. 384 px)
2. Texture.getTextureWidth() -> the converted power-of-two size (e.g. 512 px)
3. Texture.getWidth() -> the normalized width of the texture for glTexCoord2f (e.g. 0.75)


http://www.java-gaming.org/topics/lwjgl-trouble-new-to-opengl-all-together/26105/msg/227480/view.html#msg227480

Offline LiquidNitrogen
« Reply #11 - Posted 2014-02-23 20:16:44 »

thanks everyone, now i have a much clearer idea of what to look into!

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.

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

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

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

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

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

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

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

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

CopyableCougar4 (65 views)
2014-11-01 23:36:41

DarkCart (150 views)
2014-11-01 14:51:03
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!