Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  SPGL Shader/render State examples  (Read 3644 times)
0 Members and 1 Guest are viewing this topic.
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Posted 2007-12-09 13:30:30 »

Howdy

I've been picking through spgl with a view to appropriating the clever stuff that I haven't the fortitude to reinvent, starting with the com.shavenpuppy.jglib.renderer stuff.
I suspect that if I mess up the implementation of the State object, I'll bork the sorting and any performance benefit will disappear.

Does anyone have any concrete examples of State objects, and/or the Shaders that produce them, that I can peruse? Even trivial ones would be a great help.

Cheers
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2007-12-09 15:36:55 »

Yeah, I do believe I used it to render the backgrounds in Alien Flux. But it's very simple stuff unfortunately.

The trick is to get your States sorted so that the most expensive state changes are called least often.

Cas Smiley

Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #2 - Posted 2007-12-09 19:17:37 »

Yeah, I do believe I used it to render the backgrounds in Alien Flux. But it's very simple stuff unfortunately.

Anything is good. Is the source available anywhere? I take it you don't use it anymore? I suppose it's just sprites all over the shop for your stuff nowadays...

Just as a sanity check of what I'm thinking:

from most expensive to least
  • Shader programs
  • texture id
  • server attributes
  • client attributes
  • any more?

Encode the expensive stuff into the top bits of the sort order, and the expensive changes should be minimised.

Are there any gotchas with the radix sort? Do I need to worry about the range of sort order values being too expansive?

Cheers
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2007-12-10 01:41:28 »

I'll dig up some source when I get home. As for RadixSort, as far as I know there are no gotchas at all. Just make sure you give different integer IDs to each state as appropriate (texture ID for example makes a good sort index for it).

Cas Smiley

Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #4 - Posted 2007-12-10 11:46:40 »

Champion, I'll see how that goes.

Next to fall under my avaricious eye: Font rendering...
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2007-12-10 13:50:11 »

My font rendering code is quite nice but really it needs to be ditched and incorporated in to the sprite engine so that glyphs are just sprites.

Cas Smiley

Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #6 - Posted 2007-12-17 10:50:31 »

Well that went well.


Java output on the top, followed by mine, and then the packed texture.

Changes made:
  • Glyphs hold their own image data, rather than the Font
  • Floating-point layout
  • More dynamic - glyphs can be added as needed
  • Font generator substantially refactored
  • Uses the rectangle packer

I've flung it all up Google code if anyone wants a look.

So, in summary, huzzah for the spgl!

edit: Incidentally, does anyone have any recommendations for fonts that definitely have kerning values? I've scanned through the 103 fonts on this system and not found any kerning pairs, so I'm wondering if there aren't any or if I've borked the kerning computation.

edit2: Nevermind, found the problem (which, incidentally, existed in SPGL too). Text rendering with kerning now works.
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2007-12-20 15:00:28 »

ooh what problem was that? (Not that I've ever had a problem  Huh)

Cas Smiley

Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #8 - Posted 2007-12-20 19:35:46 »

On line 474 of FontConverter you call drawGlyphVector() directly on the special graphics object, rather than using a TextLayout - which is apparently where the kerning information appears from. - and passing in the graphics object. The Javadocs refer to using a TextLayout, it just doesn't happen in the code.

Also, Java doesn't render with kerning by default, you need to derive the font with the appropriate TextAttribute map. Haven't tested that one myself, but that's what the docs say.

The code that works for me is linked above.

Hmmm, sounding like a bit of an ingrate here Undecided I'm not, honest!
Offline brackeen

Junior Devvie





« Reply #9 - Posted 2007-12-21 01:24:22 »

Oh, interesting. I had been trying to figure out how to get kerning info, but it my experience KERNING_ON didn't do anything (even with fonts that obviously have kerning in other apps).

What font are you using?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #10 - Posted 2007-12-21 10:12:28 »

Running

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
   private static void kerningHunt()
   {
      String[] fonts =
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
      System.out.println( fonts.length + " Available font families : " );

      for( String fontname : fonts )
      {
         System.out.println( "Hunting for kerning in " + fontname );
         FontFactory ff = new FontFactory( fontname );

         boolean found = false;

         for( int i = 0; i < defaultCharSet.length() && !found; i++ )
         {
            for( int j = 0; j < defaultCharSet.length() && !found; j++ )
            {
               char prev = defaultCharSet.charAt( i );
               char next = defaultCharSet.charAt( j );
               float k = ff.computeKerning( prev, next );

               if( k != 0 )
               {
                  found = true;
                  System.out.println( "\tkerning found!" );
                  // System.out.println( "\t" + prev + " -> " + next +
                  // " = " + k );
               }
            }
         }
      }
   }


Gave me the output

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
106 Available font families : 
Hunting for kerning in AlArabiya
   kerning found!
Hunting for kerning in AlBattar
   kerning found!
Hunting for kerning in AlHor
   kerning found!
Hunting for kerning in AlManzomah
   kerning found!
Hunting for kerning in AlMateen-Bold
Hunting for kerning in AlMohanad
   kerning found!
Hunting for kerning in AlMothnna-Bold
Hunting for kerning in AlYermook
   kerning found!
Hunting for kerning in AnjaliOldLipi
Hunting for kerning in AR PL ShanHeiSun Uni
Hunting for kerning in AR PL ZenKai Uni
Hunting for kerning in Arab
   kerning found!
Hunting for kerning in Bitstream Charter
Hunting for kerning in Bitstream Vera Sans
   kerning found!
Hunting for kerning in Bitstream Vera Sans Mono
Hunting for kerning in Bitstream Vera Serif
   kerning found!
Hunting for kerning in Century Schoolbook L
Hunting for kerning in Cortoba
   kerning found!
Hunting for kerning in Courier 10 Pitch
Hunting for kerning in DejaVu Sans
   kerning found!
Hunting for kerning in DejaVu Sans Condensed
   kerning found!
Hunting for kerning in DejaVu Sans Light
   kerning found!
Hunting for kerning in DejaVu Sans Mono
Hunting for kerning in DejaVu Serif
   kerning found!
Hunting for kerning in DejaVu Serif Condensed
   kerning found!
Hunting for kerning in Dialog
Hunting for kerning in DialogInput
Hunting for kerning in Dimnah
   kerning found!
Hunting for kerning in Dingbats
Hunting for kerning in Electron
   kerning found!
Hunting for kerning in FreeMono
Hunting for kerning in FreeSans
   kerning found!
Hunting for kerning in FreeSerif
   kerning found!
Hunting for kerning in Furat
   kerning found!
Hunting for kerning in Garuda
Hunting for kerning in Gentium
   kerning found!
Hunting for kerning in GentiumAlt
   kerning found!
Hunting for kerning in Granada
   kerning found!
Hunting for kerning in Graph
   kerning found!
Hunting for kerning in Hani
   kerning found!
Hunting for kerning in Haramain
   kerning found!
Hunting for kerning in Hor
   kerning found!
Hunting for kerning in Japan
   kerning found!
Hunting for kerning in Jet
   kerning found!
Hunting for kerning in Kayrawan
   kerning found!
Hunting for kerning in Khalid
   kerning found!
Hunting for kerning in Kochi Gothic
Hunting for kerning in Kochi Mincho
Hunting for kerning in Lohit Gujarati
Hunting for kerning in Lohit Hindi
Hunting for kerning in Lohit Punjabi
Hunting for kerning in Lohit Tamil
Hunting for kerning in Loma
   kerning found!
Hunting for kerning in Lucida Bright
Hunting for kerning in Lucida Sans
Hunting for kerning in Lucida Sans Typewriter
Hunting for kerning in Luxi Mono
Hunting for kerning in Luxi Sans
   kerning found!
Hunting for kerning in Luxi Serif
   kerning found!
Hunting for kerning in Mallige
Hunting for kerning in MalOtf
Hunting for kerning in Mashq
   kerning found!
Hunting for kerning in Mashq-Bold
   kerning found!
Hunting for kerning in Metal
   kerning found!
Hunting for kerning in MgOpen Canonica
   kerning found!
Hunting for kerning in MgOpen Cosmetica
Hunting for kerning in MgOpen Modata
   kerning found!
Hunting for kerning in MgOpen Moderna
   kerning found!
Hunting for kerning in Monospaced
Hunting for kerning in Mukti Narrow
Hunting for kerning in Nada
   kerning found!
Hunting for kerning in Nagham
   kerning found!
Hunting for kerning in Nice
   kerning found!
Hunting for kerning in Nimbus Mono L
Hunting for kerning in Nimbus Roman No9 L
Hunting for kerning in Nimbus Sans L
Hunting for kerning in Norasi
   kerning found!
Hunting for kerning in OpenSymbol
Hunting for kerning in Ostorah
   kerning found!
Hunting for kerning in Ouhod-Bold
Hunting for kerning in Petra
   kerning found!
Hunting for kerning in Phetsarath OT
Hunting for kerning in Purisa
Hunting for kerning in Rachana_w01
Hunting for kerning in Rasheeq-Bold
Hunting for kerning in Rehan
   kerning found!
Hunting for kerning in Salem
   kerning found!
Hunting for kerning in SansSerif
Hunting for kerning in Serif
Hunting for kerning in Shado
   kerning found!
Hunting for kerning in Sharjah
   kerning found!
Hunting for kerning in Sindibad
   kerning found!
Hunting for kerning in Standard Symbols L
Hunting for kerning in Tarablus
   kerning found!
Hunting for kerning in Tholoth
   kerning found!
Hunting for kerning in Tlwg Typist
Hunting for kerning in TlwgMono
Hunting for kerning in TlwgTypewriter
Hunting for kerning in UnBatang
Hunting for kerning in UnDotum
Hunting for kerning in URW Bookman L
Hunting for kerning in URW Chancery L
Hunting for kerning in URW Gothic L
Hunting for kerning in URW Palladio L
Hunting for kerning in utkal
Hunting for kerning in Vemana2000


I tried to attach the list of kerning values that I found, but it's too big for the boards Roll Eyes
Offline ryanm

Senior Devvie


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #11 - Posted 2007-12-21 10:32:52 »

Also, I don't find any kerning information unless I derive the source font like so:

1  
2  
3  
Map<TextAttribute, Object> attributes = new HashMap<TextAttribute, Object>();
attributes.put( TextAttribute.KERNING, TextAttribute.KERNING_ON );
srcFont = java.awt.Font.decode( fontName ).deriveFont( attributes );
Offline brackeen

Junior Devvie





« Reply #12 - Posted 2007-12-21 19:58:34 »

Ah, you know what it is, a Java 6 implementation by a certain, uh, "fruit" company currently ignores KERNING_ON. Weird. The Sun implementation uses it.

BTW you don't have to use TextLayout or the faux Graphics2D - using font.layoutGlyphVector() has kerning.

Sorry to hijack the thread!
Offline princec

« JGO Spiffy Duke »


Medals: 429
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2007-12-22 11:18:55 »

Yeah, can't say I ever noticed kerning not working using the code as it is. It Just Worked.

Cas Smiley

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.

rwatson462 (28 views)
2014-12-15 09:26:44

Mr.CodeIt (19 views)
2014-12-14 19:50:38

BurntPizza (35 views)
2014-12-09 22:41:13

BurntPizza (70 views)
2014-12-08 04:46:31

JscottyBieshaar (32 views)
2014-12-05 12:39:02

SHC (44 views)
2014-12-03 16:27:13

CopyableCougar4 (40 views)
2014-11-29 21:32:03

toopeicgaming1999 (108 views)
2014-11-26 15:22:04

toopeicgaming1999 (94 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
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!