   Fonts
  I'm researching about sources for OpenGL.I tried using the library GLFT, (I link the librarie FreeType in my project to use the GLFT), But at compile, appears the following errors:D:\...\GLFT_Font.cpp||In member function 'void GLFT_Font::open(const std::string&, unsigned int)':|D:\...\GLFT_Font.cpp|165|error: 'memset' is not a member of 'std'|D:\...\GLFT_Font.cpp||In member function 'void GLFT_Font::drawText(float, float, const char*, ...) const':|D:\...\GLFT_Font.cpp|270|error: 'vsnprintf' is not a member of 'std'|D:\...\GLFT_Font.cpp|276|error: 'strlen' is not a member of 'std'|||=== Build finished: 3 errors, 0 warnings ===|I was told to use the same Nehe, But I read on some sites that the method taught by Nehe is very heavy.The code of Nehe is not portable:Quote:A small note, this code is Windows specific. It uses the wgl functions of Windows to build the font. Apparently Apple has agl support that should do the same thing, and X has glx. Unfortunately I can't guarantee this code is portable. If anyone has platform independant code to draw fonts to the screen, send it my way and I'll write another font tutorial. I just want to write the FPS on the top of the screen. If someone can give me a light, and help me. I thankThanks[Edited by - VitaliBR on July 9, 2010 9:13:49 AM]
  I'm not sure why it try to find memset/vsnprintf/strlen in the std namespace, cause it's not. Does it really call std::memset()? Usually you just include <stdio.h> and <string.h> and your good.Still, using real complex fonts with whatever library, it's often too slow for real time graphic. Textured fonts are still being used in most games. NeHe actually have a tutorial for that, and it's portable.http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17   ;  Thanks,when the GLFT, yours .h includes:#include <string>#include <vector>#include <stdexcept>#include <cstdarg>#include <sstream>I can not see why the errors happen.I had just read the lesson of Nehe 13 (where the code is only for windows), had not seen the lesson 17. I'll take a look. thanks[Edited by - VitaliBR on July 9, 2010 11:17:08 AM];  I managed to load and render the font on the screen.Using the lesson from Nehehttp://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17but I can not leave her with his background (black) transparentLook:    //    // FONT    //    glLoadIdentity();    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);// Clear The Background Color To BlackglClearDepth(1.0); // Enables Clearing Of The Depth BufferglDepthFunc(GL_LEQUAL);// The Type Of Depth Test To DoglBlendFunc(GL_SRC_ALPHA,GL_ONE);// Select The Type Of BlendingglShadeModel(GL_SMOOTH);// Enables Smooth Color Shading    glEnable(GL_TEXTURE_2D);// Enable 2D Texture Mapping   glColor3f(0.0f, 1.0f, 0.0f);// Set Color To White   glPrint(5, 460,  "TEST.....FONT....NEHE", 0);glDisable(GL_TEXTURE_2D);Note:  Nehe used .bmp, I used .tgaBecause I already have loader of tga in my project. I opened the source of Nehe in Photoshop and saved as .tga   ;  I guess you don't enable blending.I strongly suggest you to get a book on openGL.You still seem to miss the "state machine" concept.   ;Quote:Original post by szecsI guess you don't enable blending.I strongly suggest you to get a book on openGL.You still seem to miss the "state machine" concept.I'm reading Red and Blue Book.I managed to enable the blending, I'm having some difficulty at times, because he was familiar with SDL (2D)switch to OpenGL is a breakthrough for me, but I am studying the "state machine" concept.If you have any books to tell meThanks :)   ;  I learned from The Red Book.Most of it is deprecated by now, but the basic concepts are there: transformations with a pretty good explanation (IMHO), the state machine thing, and some other stuff.State machine: to put it simply: if something is enabled, it will be enabled until you disable it (glEnable/glDisable) and it will be disabled until you enable it.So openGL stays in a particular state until you change an element of that state.You can't change states between glBegin and glEnd, but you can everywhere else. So you can render some stuff textured, some blended, some textured and blended, some untextured, some fogged, some non fogged, some lighted, some unlit etc.So we can say the render environment won't change until you change it. Everything will be rendered with the current render environment.Everything is part of the environment that affects rendering (projection, modelview matrices, viewport, currently bound texture, color, etc), and there is always an environment. The only exception of it is the primitive type setting: you have to call glBegin and glEnd.OpenGL designed in a way, that you don't need to set the render environment before every single draw calls. So it just uses the current environment. Even texture coordinates and normals are part of the environment, this way you don't have to set them, if you don't need them. if you send a vertex to the GPU, it will be in the current environment, so you need to set texture coordinates and normals before sending a vertex.One little exception is the glBegin / glEnd.Because, in a way, primitive types are a part of the environment too (that's why you can draw more than one primitives between glBegin and glEnd), but glEnd needs to be called.I think it's because you can't change most of the environment in the middle of a draw call: you can't have one vertex of a triangle textured/blended/whatever, while the other vertex the opposite characteristics (obviously texture coordinates and normals can be changed, and most of the times need to be changed from vertex to vertex).So you would have to call glEnd before state changes anyway, so I guess the glBegin/glEnd is designed this way for consistency and well readability.I hope that helps a bit. If you "feel" the state machine concept, everything will fall into place (multiple viewports, 2D HUD on top of the scene, multi-pass rendering, post/pre-processes, etc). and you will realise, that openGL is in fact easy.[Edited by - szecs on July 10, 2010 1:01:00 AM];  Thank you very much :)You helped me understand some things.I will enjoy it, because I do not see nescessidade to open a new thread just to ask this.I have a fps counter, but I can not limit it to 60 fps.My FPS counter:void FrameRate(){    static float framesPerSecond    = 0.0f;// This will store our fps    static float lastTime= 0.0f;// This will hold the time from the last frame    // Here we get the current tick count and multiply it by 0.001 to convert it from milliseconds to seconds.// SDL_GetTicks() returns milliseconds (1000 ms = 1 second) so we want something more intuitive to work with.    float currentTime = SDL_GetTicks() * 0.001f;    // Increase the frame counter    ++framesPerSecond;    if( currentTime - lastTime > 1.0f )    {// Here we set the lastTime to the currentTime.  This will be used as the starting point for the next second.// This is because SDL_GetTicks() counts up, so we need to create a delta that subtract the current time from.    lastTime = currentTime;   //The frame rate as a string   std::stringstream caption;// Copy the frames per second into a string to display in the window title barcaption << "RESCUE 1.0 - " << int(framesPerSecond) << " fps";   //Reset the caption   SDL_WM_SetCaption( caption.str().c_str(), NULL );   // Reset the frames per second   framesPerSecond = 0;    }}All sites that search say to use the Delay of SDL.But in my view, this is wrong. For he does not have an exact delay.vsync in OpenGL is impossible?Thank you[Edited by - VitaliBR on July 10, 2010 9:21:32 AM];Quote:Original post by VitaliBRvsync in OpenGL is impossible?Yes, you can't vsync in OpenGL itself (AFAIK), but you can use SDL to limit the FPS. Put the following line after SDL_Init and before SDL_SetVideoMode:SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, swap_control);With swap_control being an integer. 0 means no difference, 1 is 60Hz for me, 2 is 30Hz...   ;  There's no way it automatically detects the frequency configured on the computer player?I noticed that in window mode the vsyn not work, right?   