Hello Guest

Font renderer : Nothing appear to the screen !

  • 22 Replies
  • 19607 Views
*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: Font renderer : Nothing appear to the screen !
« Reply #15 on: November 13, 2013, 19:46:10 »
I wrote that function expecting the traditional OpenGL / mathematical coordinates system where y = 0 is at the bottom and y increases as you move towards the top. So with that system, the position you give the drawText() method is the top left hand corner. You however are using the GUI type system where y = 0 is at the top and y increases as you move down. So for you, the position is the bottom right hand corner. So when you pass in a y coordinate of 0 (ie at the top of the screen), the text gets drawn up out of the visible range.


Take the time to learn what the projection matrix means.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Font renderer : Nothing appear to the screen !
« Reply #16 on: November 14, 2013, 11:58:45 »
Thank you so much for your help ! I think I will put your username (quew8) to my future credits window !
You have helped so much when the game starts and you continue today !

And thanks for your answer I will search info on matrix modes. Again I don't know how I can thank you, you have saved many times BrickBroken ! If you accept your username will be added to credits window like that (Developpers : Yuri6037 and Quew8) !

Now the system works but only one question : Why texts are upside down !
« Last Edit: November 14, 2013, 12:12:05 by Yuri6037 »

*

Offline abcdef

  • ****
  • 336
Re: Font renderer : Nothing appear to the screen !
« Reply #17 on: November 14, 2013, 16:36:59 »
its upside down because of the opengl coordinate system. You have y = 0 as your first row, opengl has it as its last row (When looking at the screen top to bottom). When you enter your y coordinate enter height-y instead

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Font renderer : Nothing appear to the screen !
« Reply #18 on: November 14, 2013, 17:43:34 »
Not working !
That's only put the text at the bottom left corner of the screen !

EDIT : I know what do you mean but I can not make my glOrtho to be 0, width, 0, height because my game has been created for working with 0, width, height, 0 so you need to find a solution tu get the text correctly rendered without need to change glOrtho !
« Last Edit: November 14, 2013, 18:08:20 by Yuri6037 »

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: Font renderer : Nothing appear to the screen !
« Reply #19 on: November 14, 2013, 23:03:46 »
Right sorry, should have thought of that. Change my function to this:

Code: [Select]
public static void drawLineOfText(String line, float xPos, float yPos, float charWidth, float charHeight, float xGap) {
        glBindTexture(GL_TEXTURE_2D, charSheetTextureId);
        glBegin(GL_QUADS);
        glColor3f(1, 1, 1);
        for(int i = 0; i < line.length(); i++) {
            int code = (int) line.charAt(i);
            int gridX = code % 16;
            int gridY = ( code - gridX ) / 16;
            float texX = (float) gridX / 16;
            float texY = (float) gridY / 16;
           
            glTexCoord2f(texX, texY);
            glVertex2f( ( ( xGap + charWidth ) * i ) + xPos, yPos - charHeight);
           
            glTexCoord2f(texX, texY + (1f / 16f) );
            glVertex2f( ( ( xGap + charWidth ) * i ) + xPos, yPos);
 
            glTexCoord2f(texX + (1f / 16f), texY + (1f / 16f));
            glVertex2f( ( ( xGap + charWidth ) * i ) + xPos + charWidth, yPos);
 
            glTexCoord2f(texX + (1f / 16f), texY);
            glVertex2f( ( ( xGap + charWidth ) * i ) + xPos + charWidth, yPos - charHeight);
        }
        glEnd();
    }
Essentially I just flipped the y coordinates so the top tex coord has the bottom position coord and vice versa.

As for the credits, I would be delighted but I really don't think you have to go to those measures. I certainly wouldn't consider myself a co-developer. I've written about 10 lines which you had to adapt to integrate into everything else. So thank you but I cannot accept.

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Font renderer : Nothing appear to the screen !
« Reply #20 on: November 15, 2013, 15:13:32 »
Thanks for your code I think I will be able to get rid of my FontRenderer now.
I think I will have to contact you for another problem soon (creating defillement bar like Microsot Word). In effect that's not finished !

About credits, as I haven't got your agreements your username will not appear to the credits window.

Here is the future programm :
- Adding fonts*,
- Adding colored fonts*,
- Adding enchanted effect on fonts*,
- Adding fonts state (Italic, Bold, ...)*,
- Adding fonts sizes support,

- Killing java sound api uses,
- Creating a sound system using LWJGL-OpenAL (with paulscode),
- Review of Networking System (need to change some deprecated functions),
- Adding defillement bar for ChatArea (This is the area witch is displayed when the server send the correct request for it. Let's players to speak together before the game starts.)*,
- Creating a Tesselator class for making special quads,...*,
- Adapting RenderEngine, ColorRenderer, FontRenderer, Tesselator to be called by the game addons system & manager. This uses OpenGL and LuaJ to work. But there will be an OpenGL context witch will be not found*,
- Makes the launcher detecting OpenGL, OpenAL and Java exceptions and display automaticaly the crash report who is saved by the game (I will maybe have some problems detecting OpenGL rendering errors)*,

This character ('*') tell the points where LWJGL-OpenGL will interact !

So like you can see the future developpement log on BrickBroken is very long. And in plus for Addons that has not ability to be loaded and used by Server so when you add a brick to the client, you will be kicked by server with a IOException of packetDestroyBrick witch don't know how to use 16 and plus bricks ids ! I will have at least some days to make the protocol of the game reading some bytes of addons and some big ids.


And Before all of that, I need to create the .lvlpack file because of non supporting multiple levels with custom musics !



Thank you,
Yuri6037

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Font renderer : Nothing appear to the screen !
« Reply #21 on: November 15, 2013, 17:53:03 »
So FontRenderer problem has been corrected all fonts drawing are online at 100% !
Only one problem the getStringWidth method is not working !

Here is the code :
Code: [Select]
--PRIVATE--

@quew8 :
Oh yeah with pure OpenGL (no other librarys for rendering), I get near to 1000 FPS ! WTF ? Before the game rested blocked at 200 FPS ! And no loading time ! No one ! You click one button, immediatly OpenGL display the window ! It's extremely quick ! There is now no lags... I love you OpenGL, but you are complicated to use !


@LWJGL
And thanks for this best library I have ever seen for rendering !
I can not make my RenderEngine laggy ! I don't know how ! I have tried 4096 by 4096 Texture sizes but always 500 FPS ingame !
« Last Edit: November 16, 2013, 16:31:43 by Yuri6037 »

*

Offline Yuri6037

  • ***
  • 104
  • Check out our website : http://www.sldt-team.net !
    • SLDT
Re: Font renderer : Nothing appear to the screen !
« Reply #22 on: November 16, 2013, 16:30:55 »
Last problem has been corrected ! So This subject is closed !