31
Feature requests / Recreating the projektion matrix onwindow rescale
« on: April 27, 2008, 12:22:42 pm »
great thx
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
glViewport(0, 0, 512, 512);
(though maybe not understandable :wink: )
one possibility would be to have a seconde array of sockets and then using == for testing..
#include <SFML/System/Vector2.hpp>
//..
//.. Rest of the code here
//..
////////////////////////////////////////////////////////////
/// gets the size of a given character if renderet with this font
///
/// \param c : The character, whose size should be returned
/// \param s : The style of the character (default: Regular)
/// \param scale : Scale of the string (default: 1)
///
/// \return the Vector2f containing the size of the character
///
////////////////////////////////////////////////////////////
Vector2f GetCharSize(wchar_t c, int s=0, float scale=1);
Vector2f GetCharSize(char c, int s=0, float scale=1);
////////////////////////////////////////////////////////////
/// Gets the Vector2f containing the size of a single Character
////////////////////////////////////////////////////////////
Vector2f Font::GetCharSize(wchar_t c, int s, float scale)
{
float Factor = scale / myCharSize;
Vector2f retValue(0,0);
std::map<wchar_t, Font::Character>::const_iterator It = myCharacters.find(c);
if (It == myCharacters.end())
{
return (retValue);
}
const Character& CurChar = It->second;
const IntRect& Rect = CurChar.Rect;
float Advance = CurChar.Advance * Factor;
// use Advance as size.y of the character
retValue.x += Advance;
// get size.x for this character
float CharHeight = (myCharSize + Rect.Bottom) * Factor;
retValue.y = CharHeight;
if (s & 1)
{
retValue.x += 1 * Factor;
retValue.y += 1 * Factor;
}
// Add a slight width if we're using the italic style
if (s & 2)
{
retValue.x += 0.208f * scale;
}
// Add a slight height if we're using the underlined style
if (s & 4)
{
if (retValue.y < scale + 4 * Factor)
retValue.y += 4 * Factor;
}
return retValue;
}
////////////////////////////////////////////////////////////
/// Gets the Vector2f containing the size of a single Character
////////////////////////////////////////////////////////////
Vector2f Font::GetCharSize(char c, int s, float scale)
{
return GetCharSize((wchar_t)(c),s,scale);
}
Vector2f Font::GetCharSize(char c, int s, float scale)
{
return GetCharSize((char)(c),s,scale);
}
Vector2f Font::GetCharSize(char c, int s, float scale)
{
return GetCharSize((wchar_t)(c),s,scale);
}
[/code]
void changeSize(int w, int h) {
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h == 0)
h = 1;
float ratio = 1.0* w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0, 0, w, h);
// Set the correct perspective.
gluPerspective(45,ratio,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0,0.0,5.0,
0.0,0.0,-1.0,
0.0f,1.0f,0.0f);
}