Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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 1803 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 Opiop
« 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:

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..
      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 Opiop
« 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 Opiop
« 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: 122
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 »

Note the differences:
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)

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.

bilznatch (17 views)
2015-08-04 11:03:17

SHC (38 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (44 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (40 views)
2015-07-25 00:14:37

BurntPizza (48 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!