Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (576) Games in Android Showcase (154) games submitted by our members Games in WIP (626) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 glTexCoord for images with many tiles?  (Read 1743 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.

 ClaasJG (39 views) 2015-04-30 20:33:25 Riven (24 views) 2015-04-30 13:25:12 ClaasJG (42 views) 2015-04-27 13:36:51 BurntPizza (50 views) 2015-04-23 03:42:11 theagentd (51 views) 2015-04-22 16:23:07 Riven (62 views) 2015-04-16 10:48:47 Duke0200 (75 views) 2015-04-16 01:59:01 Fairy Tailz (57 views) 2015-04-14 20:13:12 Riven (62 views) 2015-04-12 21:36:37 bus hotdog (87 views) 2015-04-10 02:39:32
 theagentd 25x BurntPizza 19x Spasi 16x kingroka123 11x wessles 11x alwex 11x Hanksha 9x Ecumene 8x ra4king 7x chrislo27 7x Olo 7x kevglass 7x princec 6x Riven 6x trollwarrior1 5x EgonOlsen 5x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How 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:27
 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