Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (542) Games in Android Showcase (133) games submitted by our members Games in WIP (604) 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
 glTexCoord for images with many tiles?  (Read 1670 times) 0 Members and 1 Guest are viewing this topic.
Glass

Senior Newbie

 « Posted 2012-03-26 17:45:37 »

Take a look at this image

http://i.imgur.com/9EdMG.png

It's a 78*24 image of the alphabet, with each letter in a 6*6, so 52 total squares.

Wouldn't using glTexCoord to get a single letter out of that image get kind of tedious?

GL11.glTexCoord2f(0,0);

GL11.glTexCoord2f(1/13,0);

GL11.glTexCoord2f(1/13,1/4);

GL11.glTexCoord2f(0,1/4);

Since 1/13 of 78 is 6 and 1/4 of 24 is 6, is this kind of what I'm looking to do, to single out a letter? I'm just making sure this is the way to go. Thanks

EDIT: The 1/13 and 1/4 would be decimals in the actual code so that it would actually work, this is just so that it'll read easier(just like the glVertex3f isn't there)
sproingie

JGO Kernel

Medals: 202

 « Reply #1 - Posted 2012-03-26 18:26:42 »

That's how you do it all right, but you don't do it by hand.  You take advantage of the fact that the sub-images are all uniform size and write a class to do the calculations and generate the vertices for you.  There's many implementations of this class out there; take a look at just about any "tile map" implementation (I have one, but it's in Scala).

Glass

Senior Newbie

 « Reply #2 - Posted 2012-03-26 19:18:55 »

Thank you; looks like I'm on the right track then. Getting it to calculate all that automatically sounds like a good(and necessary) step from here, I'll try to work that out next.
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.
 CopyableCougar4 (14 views) 2014-12-28 02:10:29 BurntPizza (17 views) 2014-12-27 22:38:51 Mr.CodeIt (13 views) 2014-12-27 04:03:04 TheDudeFromCI (17 views) 2014-12-27 02:14:49 Mr.CodeIt (25 views) 2014-12-23 03:34:11 rwatson462 (56 views) 2014-12-15 09:26:44 Mr.CodeIt (46 views) 2014-12-14 19:50:38 BurntPizza (92 views) 2014-12-09 22:41:13 BurntPizza (113 views) 2014-12-08 04:46:31 JscottyBieshaar (86 views) 2014-12-05 12:39:02
 Rayvolution 50x BurntPizza 30x basil_ 29x HeroesGraveDev 25x LiquidNitrogen 24x appel 18x kpars 18x Riven 16x princec 16x KevinWorkman 15x gouessej 13x NegativeZero 13x pitbuller 13x KudoDEV 12x SHC 11x Ecumene 11x
 How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50
 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