Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with 'Hello SFML'  (Read 18007 times)

0 Members and 1 Guest are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: Problem with 'Hello SFML'
« Reply #15 on: April 26, 2012, 03:53:56 pm »
I'm not sure how VS11 handles the /ignore flag but apparently it varies widely (base on this Stackoverflow question).

The second answer also links to George Chapples website where he's made a study on the linker flags and some seem too important to be ignored.
Quote
To specify any of these in a /ignore option is not an error and brings no complaint. The specification is just not acted on. Should the specified warning ever occur, a warning message will still be displayed, and if the /wx option is active, the warning will still be promoted to an error.

It seems VS doesn't (always) follow the specification.

Then again nobody will die if you ignore the warning.
Worst case scenario you can't set every a breakpoint in the SFML code. ;D

If you're really really really annoyed by the warning you still could download the whole package from GitHub and build it on your own.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #16 on: April 26, 2012, 10:13:06 pm »
New Problem .. I try SFML 2.0 under Ubuntu 10.04 LTS
Code: [Select]
||=== TestLinuxSFML, Debug ===|
||warning: libGLEW.so.1.7, needed by /home/ubuntu/sfml/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)|
||warning: libjpeg.so.8, needed by /home/ubuntu/sfml/lib/libsfml-graphics.so, not found (try using -rpath or -rpath-link)|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewDeleteFramebuffersEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUniformMatrix4fvARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_EXT_blend_func_separate'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_ARB_shading_language_100'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_stdio_dest@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewGetHandleARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewBindFramebufferEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewGenFramebuffersEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewCheckFramebufferStatusEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewAttachObjectARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_CreateCompress@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewRenderbufferStorageEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_ARB_fragment_shader'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUniform1fARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewFramebufferTexture2DEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewLinkProgramARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_set_defaults@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewGetObjectParameterivARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_destroy_compress@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_ARB_shader_objects'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUniform2fARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `glewInit'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_EXT_framebuffer_object'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_set_quality@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_ARB_texture_non_power_of_two'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewDeleteObjectARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `glewGetErrorString'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewCreateProgramObjectARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_write_scanlines@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUseProgramObjectARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewCreateShaderObjectARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUniform3fARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewGetInfoLogARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUniform1iARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewUniform4fARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewGenRenderbuffersEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewBlendFuncSeparateEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewGetUniformLocationARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewActiveTextureARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_start_compress@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_std_error@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewCompileShaderARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__GLEW_ARB_vertex_shader'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `jpeg_finish_compress@LIBJPEG_8.0'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewShaderSourceARB'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewBindRenderbufferEXT'|
/home/ubuntu/sfml/lib/libsfml-graphics.so||undefined reference to `__glewFramebufferRenderbufferEXT'|
||=== Build finished: 47 errors, 2 warnings (0 minutes, 0 seconds) ===|
Code: [Select]
root@ubuntu-dev:/home/ubuntu# sudo apt-get install libglew1.7-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Couldn't find package libglew1.7-dev

EDIT: 06.05.2012:

I have found libjpeg8:
#open a terminal as admin:
cd Downloads
wget http://www.ijg.org/files/jpegsrc.v8a.tar.gz
tar xvfz jpegsrc.v8a.tar.gz
cd jpeg-8a
./configure
make
make install
ldconfig

I have found libGLEW.so.1.7:
Download on Site: http://sourceforge.net/projects/glew/files/glew/1.7.0/ and Readme.txt.

*** Now, SFML2.0 works on Ubuntu 10.04 and Code::Blocks ***
« Last Edit: May 06, 2012, 09:35:07 am by HeinzK »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with 'Hello SFML'
« Reply #17 on: April 26, 2012, 10:49:06 pm »
Yeah, that's why building from sources is the best solution when the library is not available in your distro's repositories. I compiled SFML on a Debian/unstable, so it is linked against more recent versions of its dependencies.
However, I didn't think my compiled binaries would keep a reference to the complete filename with version (libGLEW.so.1.7) but rather to libGLEW.so. I don't know if I can solve that.
Laurent Gomila - SFML developer

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #18 on: April 27, 2012, 07:46:00 am »
Thank you for Infos. Now I go on holiday .. come back 02.05.2012 .. see you later ..  :)
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #19 on: May 02, 2012, 09:24:02 pm »
Ubuntu: I’ve now build the SFML 2.0 binaries.
'Debug' is working now!
But 'release' still with Problems:
Code: [Select]
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::setCurrentSize(unsigned int) const':|
Font.cpp|| undefined reference to `FT_Set_Pixel_Sizes'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::getLineSpacing(unsigned int) const':|
Font.cpp|| undefined reference to `FT_Set_Pixel_Sizes'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::getKerning(unsigned int, unsigned int, unsigned int) const':|
Font.cpp|| undefined reference to `FT_Set_Pixel_Sizes'|
Font.cpp|| undefined reference to `FT_Get_Char_Index'|
Font.cpp|| undefined reference to `FT_Get_Char_Index'|
Font.cpp|| undefined reference to `FT_Get_Kerning'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::cleanup()':|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::~Font()':|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::loadFromStream(sf::InputStream&)':|
Font.cpp|| undefined reference to `FT_Init_FreeType'|
Font.cpp|| undefined reference to `FT_Open_Face'|
Font.cpp|| undefined reference to `FT_Select_Charmap'|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::loadFromMemory(void const*, unsigned int)':|
Font.cpp|| undefined reference to `FT_Init_FreeType'|
Font.cpp|| undefined reference to `FT_New_Memory_Face'|
Font.cpp|| undefined reference to `FT_Select_Charmap'|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::loadFromFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':|
Font.cpp|| undefined reference to `FT_Init_FreeType'|
Font.cpp|| undefined reference to `FT_New_Face'|
Font.cpp|| undefined reference to `FT_Select_Charmap'|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::~Font()':|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::loadGlyph(unsigned int, unsigned int, bool) const':|
Font.cpp|| undefined reference to `FT_Set_Pixel_Sizes'|
Font.cpp|| undefined reference to `FT_Load_Char'|
Font.cpp|| undefined reference to `FT_Get_Glyph'|
Font.cpp|| undefined reference to `FT_Glyph_To_Bitmap'|
Font.cpp|| undefined reference to `FT_Bitmap_Embolden'|
Font.cpp|| undefined reference to `FT_Glyph_To_Bitmap'|
Font.cpp|| undefined reference to `FT_Done_Glyph'|
Font.cpp|| undefined reference to `FT_Outline_Embolden'|
Font.cpp|| undefined reference to `FT_Glyph_To_Bitmap'|
/usr/local/lib/libsfml-graphics-s.a(Font.cpp.o)||In function `sf::Font::getDefaultFont()':|
Font.cpp|| undefined reference to `FT_Init_FreeType'|
Font.cpp|| undefined reference to `FT_New_Memory_Face'|
Font.cpp|| undefined reference to `FT_Select_Charmap'|
Font.cpp|| undefined reference to `FT_Done_Face'|
Font.cpp|| undefined reference to `FT_Done_FreeType'|
/usr/local/lib/libsfml-graphics-s.a(ImageLoader.cpp.o)||In function `sf::priv::ImageLoader::writeJpg(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&, unsigned int, unsigned int)':|
ImageLoader.cpp|| undefined reference to `jpeg_std_error'|
ImageLoader.cpp|| undefined reference to `jpeg_CreateCompress'|
ImageLoader.cpp|| undefined reference to `jpeg_stdio_dest'|
ImageLoader.cpp|| undefined reference to `jpeg_set_defaults'|
ImageLoader.cpp|| undefined reference to `jpeg_set_quality'|
ImageLoader.cpp|| undefined reference to `jpeg_start_compress'|
ImageLoader.cpp|| undefined reference to `jpeg_write_scanlines'|
ImageLoader.cpp|| undefined reference to `jpeg_finish_compress'|
ImageLoader.cpp|| undefined reference to `jpeg_destroy_compress'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 1 seconds) ===|
PS:
Try without SFML_STATIC is SUCCESSFULL!
PSS:
I want to use SFML_STATIC in Release.
I need help, please:
Code: [Select]
undefined reference to `FT_Set_Pixel_Sizes'  .. see above ..
« Last Edit: May 03, 2012, 01:24:53 pm by HeinzK »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with 'Hello SFML'
« Reply #20 on: May 03, 2012, 03:10:25 pm »
Static SFML on Linux? This is useless, unless you have a very good reason.

Can you explain me how you compile this SFML release/static build?
Laurent Gomila - SFML developer

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #21 on: May 03, 2012, 04:22:02 pm »
Quote
Can you explain me how you compile this SFML release/static build?
Code: [Select]
a) Download+Extract: <LaurentGomila-SFML-2.0-rc-17-g1187c29.tar.gz>
b) Release
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=TRUE .
make
sudo make install
c) Debug:
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=TRUE .
make
sudo make install
d) Release-Static:
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=FALSE .
make
sudo make install
e) Debug-Static:
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=FALSE .
make
sudo make install
Quote
Static SFML on Linux? This is useless, unless you have a very good reason.
Later, when my program is ready, I would like to have it as a 'stand alone'.
But, I am not sure myself. I am new on SFML and I am very new on Linux/Ubuntu.
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with 'Hello SFML'
« Reply #22 on: May 03, 2012, 04:33:16 pm »
But the errors that you show, they are produces when you build your own project, right? A static library is not linked to its dependencies, therefore you have to link FreeType, libjpeg, etc. to your own app when you link to SFML static libraries.

Quote
Later, when my program is ready, I would like to have it as a 'stand alone'.
Then just pack the SFML libraries with the executable, and run it with a little script that does this:
Code: [Select]
export LD_LIBRARY_PATH=. && ./myprogram
But once SFML 2.0 is out and packaged into the official Linux repositories, there will be no good reason (but many bad reasons!) to provide it yourself, it's better to let people install the version that is specifically compiled for their own Linux distribution.
Laurent Gomila - SFML developer

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #23 on: May 03, 2012, 04:56:42 pm »
Thank you, now I understand the errors .. and .. I will try and learn further ..  :)
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #24 on: May 04, 2012, 09:25:41 am »
Code: [Select]
sf::Font MyFont;
// Load from a font file on disk
if (!MyFont.LoadFromFile("arial.ttf"))
{
    // Error...
}
If I go right in the assumption that the full path always must be used? (Win7/64, VS2010)
In the above form, it doesn't work with me.
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with 'Hello SFML'
« Reply #25 on: May 04, 2012, 09:30:40 am »
Where did you put the arial.ttf file?
Laurent Gomila - SFML developer

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #26 on: May 04, 2012, 10:15:24 am »
From Windows. I altered the code to:
Code: [Select]
  std::string sFnt = std::getenv("WINDIR");
  sFnt += "\\Fonts\\COUR.TTF";
  sf::Font k_Font;
  //if (!k_Font.loadFromFile("COUR.TTF"))
  if (!k_Font.loadFromFile(sFnt))
  {
    txtS.setString("FontFehler");
  }
In this case, it works. (I thought that Fonts always are loaded there without path statement ::))
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with 'Hello SFML'
« Reply #27 on: May 04, 2012, 11:01:19 am »
Quote
I thought that Fonts always are loaded there without path statement
No :)
A font in SFML is like any other resource, when you load it from a file it searches the file relatively to the current working directory, and that's it.
Laurent Gomila - SFML developer

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #28 on: May 04, 2012, 03:45:33 pm »
Win7/64, VS2010: My first 'game' with SFML (only a 'joke'). I am testing the keyboard input:
Hint: Later in my planned game will i have a framerate=30 >> ::sleep(33);.
Code: [Select]
#include "stdafx.h"
#ifdef _WIN32
  int APIENTRY _tWinMain
               (
                 HINSTANCE hInstance,
                 HINSTANCE hPrevInstance,
                 LPTSTR lpCmdLine,
                 int nCmdShow
               )
#else
  int main(void)
#endif
{
  #ifdef _DEBUG 
    sf::RenderWindow window(sf::VideoMode(950, 150), "SFML works!");
  #else
    //sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML works!", sf::Style::Fullscreen);
    sf::RenderWindow window(sf::VideoMode(950, 150), "SFML works!");
  #endif

  sf::Text txtS("Hello SFML");

  #ifdef _WIN32
    std::string sFnt = std::getenv("WINDIR");  //> Warnung unterdrücken: 4996;:
    sFnt += "\\Fonts\\COUR.TTF";

    sf::Font k_Font;
    if (!k_Font.loadFromFile(sFnt))
    {
      txtS.setString("FontFehler");

    }
  #else
    std::string sFnt = "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf" ;
    //std::string sFnt = "/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Bold.ttf" ;
    sf::Font k_Font;
    if (!k_Font.loadFromFile(sFnt))
    {
      txtS.setString("FontFehler");
     
    }
  #endif

  sf::Text txtK("");   //> Zeig TastaturStatus:
  txtK.move(20.0, 50.0);
  txtK.setScale(0.5, 0.5);
  txtK.setFont(k_Font);

  sf::Text txtM("");   //> Markiere einige Tasten:
  txtM.move(20.0, 70.0);
  txtM.setScale(0.5, 0.5);
  txtM.setFont(k_Font);

  sf::Text txtZ("");   //> Markiere Zusatzinfo:
  txtZ.move(20.0, 90.0);
  txtZ.setScale(0.5, 0.5);
  txtZ.setFont(k_Font);

  sf::Text txtC("");   //> Codeinfo:
  txtC.move(20.0, 110.0);
  txtC.setScale(0.5, 0.5);
  txtC.setFont(k_Font);

  sf::Event k_Event;
  window.setKeyRepeatEnabled(true);

  const long k_lKc = sf::Keyboard::KeyCount;
  long k_KeyTst[k_lKc];
  long i = 0;

  //> TastaturStatus=0:
  for (i = 0; (i < k_lKc); i++)
  {
    k_KeyTst[i] = 0;
 
  }

  while (window.isOpen())
  {
    //> EVENTS:

    while (window.pollEvent(k_Event))
    {             
      if
      (
        (k_Event.type == sf::Event::LostFocus)
        ||
        (k_Event.type == sf::Event::GainedFocus)     
        ||
        (k_Event.type == sf::Event::Resized)
      )
      {
        //> TastaturStatus=0:
        for (i = 0; (i < k_lKc); i++)
        {
          k_KeyTst[i] = 0;
 
        }

      }
     
      //> Eine oder mehrere Tasten gedrückt:
      if (k_Event.type == sf::Event::KeyPressed)       
      {
        long lKyC = k_Event.key.code;

        if
        (
          (lKyC > -1)
          &&
          (lKyC < k_lKc)
        )
        {
          if (k_KeyTst[lKyC] < LONG_MAX)
          {
            k_KeyTst[lKyC]++;

          } else
          {
            k_KeyTst[lKyC] = 1;

          }
        }
      }

      //> Eine oder mehrere Tasten losgelassen:
      if (k_Event.type == sf::Event::KeyReleased)       
      {
        long lKyC = k_Event.key.code;

        if
        (
          (lKyC > -1)
          &&
          (lKyC < k_lKc)
        )
        {
          k_KeyTst[lKyC] = 0;

        }
      }

      if (k_Event.type == sf::Event::Closed)
      {
        window.close();   //> Und raus ..:

      }
    }

    std::string sTxtK;  //> TastaturZustand: "_" | "1" .. "9", "X":
    sTxtK = "";
    std::string sTxtM;  //> Markierung einiger Tasten:
    sTxtM = "";
    std::string sTxtZ;  //> Zusatzbemerkung zu einigen Tasten:
    sTxtZ = "";
    std::string sTxtC;  //> TastenKeyCode:
    sTxtC = "KeyCode =";

    for (i = 0; (i < k_lKc); i++)
    {
      if (k_KeyTst[i] > 0)
      {
        //> Taste ist gedrückt:

        char cX[256];

        if (k_KeyTst[i] < 10)
        {
          #ifdef _WIN32
            _itoa_s(k_KeyTst[i], cX, 256, 10);
          #else
            sprintf(cX, "%ld", k_KeyTst[i]);
          #endif 

          sTxtK += cX;   //> "1" .. "9":

        } else
        {
          sTxtK += "X";

        }

        sprintf(cX, " %ld", i);
        sTxtC += cX;

      } else
      {
        //> Taste ist nicht gedrückt:

        sTxtK += "_"; 
 
      }

      //> Markierungen:

      switch (i)
      {
        case sf::Keyboard::A:
        {
          sTxtM += "A";
          sTxtZ += " ";
          break;
        }

        case sf::Keyboard::B:
        {
          sTxtM += "B";
          sTxtZ += " ";
          break;
        }

        case sf::Keyboard::K:
        {
          sTxtM += "K";
          sTxtZ += " ";
          break;
        }

        case sf::Keyboard::L:
        {
          sTxtM += "L";
          sTxtZ += " ";
          break;
        }

        case sf::Keyboard::LAlt:
        {
          sTxtM += "a";
          sTxtZ += "L";
          break;
        }

        case sf::Keyboard::RAlt:
        {
          sTxtM += "a";
          sTxtZ += "R";
          break;
        }

        case sf::Keyboard::LControl:
        {
          sTxtM += "c";
          sTxtZ += "L";
          break;
        }

        case sf::Keyboard::RControl:
        {
          sTxtM += "c";
          sTxtZ += "R";
          break;
        }

        case sf::Keyboard::LBracket:
        {
          sTxtM += "[";
          sTxtZ += " ";
          break;
        }

        case sf::Keyboard::RBracket:
        {
          sTxtM += "]";
          sTxtZ += " ";
          break;
        }
         
        default:
        {
          sTxtM += " ";
          sTxtZ += " ";
          break;
        }
      }       
    }

    txtK.setString(sTxtK);
    txtM.setString(sTxtM);
    txtZ.setString(sTxtZ);
    txtC.setString(sTxtC);

    window.clear();

    window.draw(txtS);       
    window.draw(txtK);
    window.draw(txtM);
    window.draw(txtZ);
    window.draw(txtC);

    window.display();

    #ifdef _WIN32
      Sleep(33);
    #else
      usleep(33);
    #endif

  }
  return 0;
}
Download the *.exx: http://www.zwianer.de/Download/SFML_Win32_ZwiAner.exx and rename to *.exe.
Example K-Key:

Press and hold the K-key .. when released then is the statusline again empty .. just like I wants.
There a 3 problems:
a) LAlt-Key:

Press and hold the LAlt-Key .. when released (in most cases) no effect! (You must press another Key to 'released' the LAlt-Key.)
b) RAlt-Key:

Press and hold the RAlt-Key .. the LControl appear at the same time!
c) K-Key and L-Key (at the same time):

Press the K-Key for a second .. hold it .. and press the L-Key additional.
Only the second key is updated as 'pressed'.
In a few cases (when pressed both at same time) .. both Key are updated as 'pressed'.
« Last Edit: May 07, 2012, 10:09:46 am by HeinzK »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

HeinzK

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • ZwiAner
    • Email
Re: Problem with 'Hello SFML'
« Reply #29 on: May 06, 2012, 05:48:19 pm »

Download program: http://www.zwianer.de/Download/SFML_Lin32_ZwiAner
Any Problems are similar described like above reply!
I have a lot of new problems:
Examples:

Press the RAlt-Key .. event.key.code return 0 not 37.

The Button left next at Backspace:
Windows: Backcode=47 .. Ubuntu: Backcode=51 (an some times 0).
The next Button one more left:
Windows: Backcode=46 .. Ubunto: Backcode=0

Code 46 und 47 is described as LBracket/RBracket.
But the buttons are not at the right place at english keyboard (my opinion).

etc.

I am a little confused ..  :o .. please help me.
« Last Edit: May 07, 2012, 10:09:15 am by HeinzK »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

 

anything