Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (761)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (846)
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  
  Texture problems  (Read 1564 times)
0 Members and 1 Guest are viewing this topic.
Offline weston
« Posted 2004-12-18 00:21:22 »

I've just started writing a 2D game, my first with lwjgl, and I noticed that the image I loaded was a bit skewed. The image was much wider and shorter than it should be. The image is a 24-bit png. The projection setup I'm using looks like this:

GLU.gluOrtho2D(0, Game.gameWidth, 0, Game.gameHeight);

I'm trying to map an image to a quad so that the corners of the image meet up with the corners of the quad, code looks like this:

     GL11.glTranslatef(x, y, 0);
         GL11.glTexCoord2f(1f, 0); GL11.glVertex2f(400, 0);
         GL11.glTexCoord2f(1f, 1f); GL11.glVertex2f(400, 400);
         GL11.glTexCoord2f(0, 1f); GL11.glVertex2f(0, 400);
         GL11.glTexCoord2f(0, 0); GL11.glVertex2f(0, 0);

I tried a different image that doesn't use transparency and it draws a black square the actual size of the image with the actual image occupying the lower-lefhand side of that square, heres a screen:

the current color is set to red, so I don't know why the square is black. Btw, I'm using KevGlass's TextureLoader class from space invaders 104. Any ideas?

for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Offline weston
« Reply #1 - Posted 2004-12-18 00:33:41 »

ah crud, figured it out... I forgot that I need to use power of two textures, the images were mishapen cause kev's texture  loader class uses the closes size that is a power of two if you give an image with illegal dimensions. I do have another texture problem though. I have two textures, one of them is 256x256 and the other is 512x128, I measured the time required to load the two textures and its about 1200 milliseconds, 1000 if I don't flip the images first. That seems way too long, is it?

for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Offline CaptainJester

JGO Knight

Medals: 12
Projects: 2
Exp: 14 years

Make it work; make it better.

« Reply #2 - Posted 2004-12-18 01:45:43 »

If you start or are using v0.94 of LWJGL, it now includes basic DevIL support.  You can check out NeHe Lesson 6 tutorial for how to use it.

Pages: [1]
  ignore  |  Print  

EgonOlsen (351 views)
2018-06-10 19:43:48

EgonOlsen (344 views)
2018-06-10 19:43:44

EgonOlsen (292 views)
2018-06-10 19:43:20

DesertCoockie (516 views)
2018-05-13 18:23:11

nelsongames (843 views)
2018-04-24 18:15:36

nelsongames (829 views)
2018-04-24 18:14:32

ivj94 (1259 views)
2018-03-24 14:47:39

ivj94 (395 views)
2018-03-24 14:46:31

ivj94 (1058 views)
2018-03-24 14:43:53

Solater (413 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!