Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick AngelCodeFont - Rotated characters on: 2013-03-31 00:56:08
Wow! Using LWJGL just got way easier. Shocked

My new render code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
glClear(GL_COLOR_BUFFER_BIT);
       
glClearColor(red, green, blue, 0F);
       
spriteBatch.begin();
    font.drawText(spriteBatch, "red: " + red, 10, 10);
    font.drawText(spriteBatch, "green: " + green, 10, 30);
    font.drawText(spriteBatch, "blue: " + blue, 10, 50);
spriteBatch.end();

I only read the first five articles in your wiki and I've the feeling I learned more than I did with any other tutorial about lwjgl/opengl. I surely continue reading them.
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick AngelCodeFont - Rotated characters on: 2013-03-30 15:23:12
More modern approaches are always welcome!

I looked into your code and ended up with the following (mostly taken from FontTest.java):
Font loading:
1  
2  
font = new BitmapFont(Util.getResource("font/press_start_2p_4.fnt"), Util.getResource("font/press_start_2p_4.png"));
batch = new SpriteBatch();

Text drawing:
1  
2  
3  
4  
5  
6  
7  
8  
glPushMatrix();
    //draw text
    batch.begin();
        font.drawText(batch, "red: " + formatter.format(red),10, 380);
        font.drawText(batch, "green: " + formatter.format(green),10, 360);
        font.drawText(batch, "blue: " + formatter.format(blue),10, 340);
    batch.end();
glPopMatrix();

Loading and drawing work just fine, but the background still won't change its colour.
The background drawing routine is the same as in the first post.
As far as I can see, I did everything according to your example.
Am I doing something wrong with the "fonting" or is the error in the background code?
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick AngelCodeFont - Rotated characters on: 2013-03-29 21:20:32
Thanks a lot! Works like a charm now.
Always good to know such things.

The odd thing is, that the background doesn't change its colour although I change the values of the variables.
If I remove all font-related code it works just fine.

Any suggestions?
4  Java Game APIs & Engines / Engines, Libraries and Tools / Slick AngelCodeFont - Rotated characters on: 2013-03-29 20:47:30
Hello everybody

Today I decided to experiment with the fonts functionality provided by the slick-library.
I keeped struggling with UnicodeFont/TrueTypeFont and ended up using AngelCodeFont.
Using Hiero it was pretty easy to convert my .ttf into a .fnt and the coresponding .png (if someone's interested in the files: press_start_2p_4.png (warning: it's white on white) and press_start_2p_4.fnt).

In my class I load the texture as follows:
1  
font = new AngelCodeFont("font/press_start_2p_4.fnt", new Image("font/press_start_2p_4.png"));

Then I set up my orthographic view:
1  
2  
3  
4  
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 200, 0, 200, -1, 1);
glMatrixMode(GL_MODELVIEW);

The opengl related part of my rendering cylce looks like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
glClear(GL_COLOR_BUFFER_BIT);
           
glPushMatrix();
    //draw background
    glBegin(GL_QUADS);
        glColor3f(red, green, blue);
        glVertex2f(0, 0);
        glColor3f(red, green, blue);
        glVertex2f(200, 0);
        glColor3f(red, green, blue);
        glVertex2f(200, 200);
        glColor3f(red, green, blue);
        glVertex2f(0, 200);
    glEnd();
glPopMatrix();
           
glPushMatrix();
    //draw text
    font.drawString(10, 380, "red: " + formatter.format(red));
    font.drawString(10, 360, "green: " + formatter.format(green));
    font.drawString(10, 340, "blue: " + formatter.format(blue));
glPopMatrix();

The variables red, green and blue are alterable by pressing certain keys on the numpad. That way you can adjust the background colour at runtime.
As you can see on the last few lines of code, I'm "printing" the current values of these variables onto the screen.

When I now start the application this is what I get:


I tried to do this, so the texture gets rotated in the buffer:
1  
font = new AngelCodeFont("font/press_start_2p_4.fnt", new Image("font/press_start_2p_4.png", true));

But this doesn't help at all, because the coordinates in the .ftn file are still the same and do not refer to the new character positions.

Has anyone any idea what could cause my problem?
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
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!