LWJGL Forum

Programming => OpenGL => Topic started by: Yuri6037 on November 01, 2013, 16:48:26

Title: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 01, 2013, 16:48:26
I tried to make a font renderer, I arived to create one but nothing is appearing to the screen ! I have verified all the rendering code, LWJGL initialization, Crach Reporter, Display creator and BrickBroken Launcher, but the method is correctly called and display is ok and the rendering code too. I have seen the CrashReporter but no errors are detected. So i don't understand why nothing is appearing to the screen !

Here is the text rendering code (renderEngine is RenderEngine or the main game render engine class) :



--PRIVATE--


Thanks by advance,
Yuri6037
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 02, 2013, 16:40:28
Nobody knows why my code is giving me nothing ?

I realy need that code to work for finishing the new version of my game !
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 03, 2013, 09:21:23
Nobody...
So my game will never been finished...

I don't understand why nobody knows that !


Please let me know if nobody can help ! I have to know if I need to close or not this topic !
Title: Re: Font renderer : Nothing appear to the screen !
Post by: abcdef on November 06, 2013, 14:37:25
Yuri6037

You don't really make it easy for people to comment.

1) We have no idea if you have a texture loaded correctly and that it contains text
2) Have you tried passing in a texture you know works to test whether it displays anything?
3) Have you tried putting your texture in a piece of code that you know works and can display textures
4) Have you got all your Open GL flags setup correctly?
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 06, 2013, 22:11:53
Thanks for answer,
Like I have said before, the render engine which contains mounting textures voids, is functioning. Otherwise the main class brick broken will not be able to load ! The font texture is 1024 by 1024 (it contains all chars in ASCII code), maybe it's gl constants at game init.
Like I said the whole game renders correctly only texts are not drew !
If you want I can post the lwjgl initialization void.


Wrote with my iPad,
Yuri6037
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 on November 07, 2013, 17:00:41
That would be helpful.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 07, 2013, 20:10:51
So, here's the LWJGL initialization :

--PRIVATE--


Thanks for answer,
Yuri6037
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 10, 2013, 09:54:05
Allways nobody !

I don't know how to fix that ! Please help !

Would you wan't some other code ask me for the code you wan't !

I can give you the RenderEngine code if you wan't ! But if I post the render engine here, please not to copy - paste it for your 2d games projects ! Ok ?

I have spend many time on creating this RenderEngine, so please not kill this project...

Here is the RenderEngine class :

--PRIVATE--


Now ColorRenderer class :

--PRIVATE--


And the FontRenderer class :

--PRIVATE--


And in if you wan't, here is the textures :
The missing texture file (32 by 32) :
--You do not have permission to access StoneLine servers--
Now the font texture file (1024 by 1024) :
--You do not have permission to access StoneLine servers--

Thanks by advance,
And another time please not copy these codes, I give you the permission for view and test these codes but you may not bring these for you. Otherwise you will kill the BrickBroken project !

Yuri6037
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 on November 10, 2013, 13:44:06
Look: if no one sees any problems in your code and no one has any ideas, then we cannot help. I'm going to write a little, self contained exemplar for you. I will actually write this up in an IDE and compile and run it to ensure it works. Hopefully you'll be able to compare and contrast that with your own to see what the problem might be. I'll post it up when I'm done.

Your "font texture file" doesn't seem to contain anything. It would be easier for me to have one but I don't particularly want to bother making my own.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 10, 2013, 15:06:51
That's normal because letters are white it seams like your screen make the forum white !
You need right clicking + save image or simply go in this link :
--You do not have permission to access StoneLine servers-- --> Font texture
--You do not have permission to access StoneLine servers-- --> Missing texture
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 on November 10, 2013, 15:28:12
Oh yeah. I just looked at it on my phone and I can see it on there but not on my desktop. I'll add it to the list of annoyances with Chrome (it only brings the list to 2). I did actually download it but Window's #%£#!! ing image preview thing didn't show me anything either. Why do I ever rely on Windows? OK, I'll get back to programming.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 on November 10, 2013, 16:31:02
So here it is. http://pastebin.com/80NSu3pL (http://pastebin.com/80NSu3pL). Use as much or as little as you like. If there is any particular thing you don't understand then I can explain it. If you find whatever it is in your code that is stopping your renderer working, then I can probably explain that too. But just to stress, this works. I've tested it. It's a little simplistic and I would never even think about releasing this as production code but it should suit your purposes. The idea of it is a self-contained and (more or less) minimalistic example.

In terms of debugging, I think I have given you about as much help as is possible. Certainly as much as I am willing.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 11, 2013, 16:25:18
Thank you very much for taking your time to do this code for me...

But I'm so sorry to say you that : It's not working ! Nothing appear to the screen !

No errors ! I have simply replace my function by your function but nothing ! Nothing ! I think my graphic card simple does not handles text position with floats !

If you have another solution tell me. If you need some other codes, ask me. I'm realy lost ! I can not find any solution to resolve this problem. I have tried a solution that was working : drawing text without texture but with quads (and strangely with floats for coords and size) !

I don't know what I can do !

Here is the new code of FontRenderer class :

--PRIVATE--
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 on November 11, 2013, 16:49:44
The idea was to compare the two for anything that's different. Anything that is could be the cause of the problem. Try running the example on its own. See if it works then.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 13, 2013, 17:04:39
Your example is working a lot of !
No lags !
I got about 1200 FPS !


And I have advanced a little !

When I was developping for Minecraft with Minecraft Forge, I needed to implement another Gui part.

When I have tried to draw some texts, I got nothing, like BrickBroken ! And after putting two unknown functions the text appeared : --PRIVATE-- and --PRIVATE--.

Do you understand now ?
The problem is that when putting these methods in BrickBroken, colored Quads are not rendered or rendered with transparency, so I don't know how I can implement these functions.

Yuri6037

EDIT : TESTED but nothing on the screen same problem ! I don't know. We have tested all we can but always nothing on the screen !

EDIT2 : YEEEEEEAAAAAAAAHHHHHH !!!! I have found the origin of the main problem ! Here :
There are two problematics lines of codes :
- one line of initialization who reduce the text two verry little not readable : --PRIVATE--;
- and this line kill the text : --PRIVATE-- (only change the x - y coords by 0,0)
Please help me !

EDIT3 : It seams that changing y coord may kill the text ! But questions are : WHY ? WTF ?!
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 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.

(https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcStiWoprFX-UNMmnobHt-tAobYnxPoej5dKx1uOKsE39OPS_TZOIw)
Take the time to learn what the projection matrix means.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 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 !
Title: Re: Font renderer : Nothing appear to the screen !
Post by: abcdef 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
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 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 !
Title: Re: Font renderer : Nothing appear to the screen !
Post by: quew8 on November 14, 2013, 23:03:46
Right sorry, should have thought of that. Change my function to this:


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.
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 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
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 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 :

--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 !
Title: Re: Font renderer : Nothing appear to the screen !
Post by: Yuri6037 on November 16, 2013, 16:30:55
Last problem has been corrected ! So This subject is closed !