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

Show Posts

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.


Topics - Robert42

Pages: [1]
1
Feature requests / FindSFML.cmake use HINTS instead of/additional to PATHS
« on: November 22, 2015, 11:21:58 pm »
The current implementation of FindSFML.cmake is using the cmake command find_path together with the PATHS argument.
My Request is to use HITNS additional to PATHS

Story:
I am using sfml for two projects. one is using sfml version 2.1 from the ubuntu packages. I want to keep working with this version (in order not to force the whole team to install sfml manually)
For another project I started using sfgui, which has sfml 2.3 as prerequirement.

So I downloaded the compiled version of SFML. (I am using the precompiled version, as I am planning to also work on a computer on my university, where I don't have root privileges, so I don't want to need to install the dev versions of all dependencies)

Problem:
The current FindSFML.cmake script finds always the sfml version installed with the ubuntu packages, although I am using SFML_ROOT to override the path.

The Problem is, that the PATHS attribute will cause cmake to look first at the default locations (I think it is CMAKE_MODULE_PATH, but I am not 100% sure), bevore checking the paths of the PATHS attribute. I've modified the FindSFML.cmake script to use HINTS, they are checked before the CMAKE_MODULE PATH. SO instead of

# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
    ${SFML_ROOT}
    $ENV{SFML_ROOT}
    ~/Library/Frameworks
    /Library/Frameworks
    /usr/local
    /usr
    /sw
    /opt/local
    /opt/csw
    /opt)

# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
          PATH_SUFFIXES include
          PATHS ${FIND_SFML_PATHS})

I have now

# define the list of search paths for headers and libraries
set(FIND_SFML_PATHS
    ${SFML_ROOT}
    $ENV{SFML_ROOT}
    ~/Library/Frameworks
    /Library/Frameworks
    /usr/local
    /usr
    /sw
    /opt/local
    /opt/csw
    /opt)

 #################### ADDED
set(FIND_SFML_HINTS
    ${SFML_ROOT}
    $ENV{SFML_ROOT}
  )

# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
          PATH_SUFFIXES include
          HINTS ${FIND_SFML_HINTS} ################### ADDED
          PATHS ${FIND_SFML_PATHS})

What now?
This fix is working perfectly for me, so I wanted to share it with you :)
I you thik that's usefull, use it as you whish

2
General discussions / Clean C++ Design
« on: May 23, 2013, 09:54:41 pm »
Hey!

I am overwhelmed by the design of SFML. I like how intuitive it is to use. I wish which there were more Libraries with such a clean design.

I am programming C++ since about 10 Years. Most of the time I was hacking, until I got my hands on the book Clean Code by Robert C. Martin. Since then I am trying to improve the quality of my own code.

The Next book I am planning to read is the book "Modern C++ Design" written by Andrei Alexandrescu.

@Laurent & other Clean Coder: Do you know further Resources (books, websites) which might be useful to improve ones C++ Software Design

3
Graphics / Crash when using RenderTexture
« on: September 18, 2012, 07:48:10 pm »
I could only reproduce it on my Linux Mint 13 64bit Laptop with onboard Intel graphic (Mobile Intel GM45 Express Chipset).

It's working without problems on my PC with NVidia Graphic-Card (also Linux Mint 13 64bit)

Here's the minimal Code to reproduce:

#include <SFML/Graphics.hpp>
 #include <SFML/OpenGL.hpp>
 
 int main()
 {
     // Create the main window
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
     sf::RenderWindow* RENDER_WINDOW = &window;
 
 
     // Start the game loop
     while (window.isOpen())
     {
         // Process events
         sf::Event event;
         while (window.pollEvent(event))
         {
             // Close window : exit
             if (event.type == sf::Event::Closed)
                 window.close();
                 
             if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Space)
             {            
              sf::RenderTexture render_texture;

              render_texture.create(800, 600);
              render_texture.setActive(true);

              render_texture.pushGLStates();
              render_texture.resetGLStates();
              glClearColor(0.f, 0.f, 0.f, 0.f);
              glClearDepth(1.f);

              glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

              render_texture.popGLStates();

              RENDER_WINDOW->setActive(true);
             }
         }
 
         // Clear screen
         window.clear();
 
         // Update the window
         window.display();
     }
 
     return EXIT_SUCCESS;
 }

Edit: it crashes when executing the  RENDER_WINDOW->setActive(true); line.

4
Window / Bug: no way to poll Alt+F4 event using sf::Style::None
« on: August 20, 2012, 11:18:55 pm »
Hi,

Alt+F4 behaves different, depending on the window-style:
  • sf::Style::Default You get a Close Event. fine.
  • sf::Style::Fullscreen You get a KeyPressed event. fine.
  • sf::Style::None You get neither a Close, nor a KeyPressed Event.

Tested using SFML 2.0 fetched and built today.

If you agree that's a bug, I can create a pull-request if you want

greetings, Robert

Edit: I am using LinuxMint 13 x64

5
SFML wiki / Gtkmm-Widget
« on: August 07, 2012, 09:57:44 pm »
Hi,

I needed to use SFML in a gtkmm based GUI and luckily I found some Code-Snippets in the old Wiki:
http://www.sfml-dev.org/wiki/en/sources/gtksfmlwidget

Before I can upload my Code-Changes to my online git repository I wanted to
  • Ask which License the Wiki is using.
  • Request a License note in the wiki regarding the Code Snippets (I searched, but couldn't find)


Open Source is about sharing, so I wanted to share the changes I've made to the gtkmm-example code (Tested on Linux Mint 12.04 64Bit, NVidia; SFML 2.0; gtkmm-2.4):
  • The Widget was flickering extremely when I resized the window, so I needed to disable the Widgets default double buffering by adding the following line to the end of the on_realize method:
this->set_double_buffered(false);
  • On neighbor Widgets, there were strange artifacts when I resized the widgets. The Workaround I used was to suppress the Widgets default drawing Method using a invisible Pattern:
this->get_window()->set_back_pixmap(Glib::RefPtr<Gdk::Pixmap>());
  • The on_idle Method presented in the snipped caused my application to crash as returning true caused the application to ignore the main loop. Instead I used the widgets on_expose Method.
  • To have the operating system dependend Code in only one place, I used the following Preprocessor Code to do most of the work:
#if defined(SFML_SYSTEM_WINDOWS)

#include <gdk/gdkwin32.h>
#define GET_WINDOW_HANDLE_FROM_GDK GDK_WINDOW_HANDLE

#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)

#include <gdk/gdkx.h>
#define GET_WINDOW_HANDLE_FROM_GDK GDK_WINDOW_XID

#elif defined(SFML_SYSTEM_MACOS)

#error Note: You have to figure out an analogue way to access the handle of the widget on a Mac-System

#else

#error Unsupported Operating System

#endif

In order to keep the Window handling Method within the on_realize Method simple:
        this->sf::RenderWindow::create(GET_WINDOW_HANDLE_FROM_GDK(m_refGdkWindow->gobj()));

I've attached the whole Code. Be aware that the current Version of gtkmm is 3.0 And The Code I've created is compatible to gtkmm 2.4.

[attachment deleted by admin]

6
SFML wiki / FAQ
« on: September 28, 2011, 10:05:25 pm »
Whan looking to the Forum, many people (including me) have asked for features to integrate to SFML, which won't be intigrated to SFML as they are too spezialized and/or don't match to the idea what SFML is suppoed to and what not.

In the Wiki, there's already a section "What is SFML?". what do you think about a "What is SFML not" section ?

What do you think about adding a direkt Link to teh Wiki's FAQ page to the main page of "www.sfml-dev.org"?

7
Graphics / sf::Texture flexibility
« on: September 19, 2011, 10:02:40 pm »
My Game with 3D Graphic needs mipmapping and tilable textures and so. Theese are special usages of Textures, and I think adding a sf::Texture::SetMipmapped(bool) and sf::Texture::SetTilable(bool)
is not a very good design.

My ideas how to solve this:
1) Create my own Texture class for my game or a wrapper class:
  - redundant Code
  - much work
  - my will probably get incompatible to nice SFML classes like RenderTexture
  + best control
  + no change in the SFML Library
 
2) add a virtual OnInitialize Function to sf::Textre in SFML 2.0
  + adding such special purpose effects becomes easy
  - Textures you have not created by yourself (like the internal one in RenderTexture) won't have theese effects
  - sf::Texture class has to be changed
  => not clean
 
3) add a callback OnInitialize to sf::Texture (in std::funtion<...> or even something like sigc::signal<...> style)
  + adding such special purpose effects becomes easy
  + special effects
  - sf::Texture class has to be changed
  - I can miss some textures
  => better than 2) but still not very clean
 
4) use Strategy-Design-Pattern for sf::Texture class this way:
 
         (where Smooth has the same effect as sf::Texture with SetSmooth(true) and Blocky with SetSmooth(false))
  + adding such special purpose effects becomes very and flexible easy
  + clean evn the Texture::SetSmooth(true/false) idea gets a little cleaner
  - sf::Texture class has to be changed
  - big Design-Change
  - large number of objects
  - bindings for non OOP Languages will be nearly impossible
  - far away to SFMLs usually clean Design
  => for me it looks the best way (flexible and clean)
 
5) just call sf::Texture::Bind() of the Texture and call my glTex... Stuff afterwards
 - no way to find out whether a Texture has called glGenTextures internally in between - I have to take care of everything and can miss some changes of sf::Texture :(
 - not very clean
 + most easy to way implement your Tetxure Parameter without altering SFML
 
6) add a public method in sf::Texture to find out whether the internal Textur has changed and combine with 5)
 - absolutle not clean :shock:
 
 
 
 
 
Looks like there's no perfect solution. :(
 
What do you think? Do we need a change in sf::Texture? why? why not? Other ideas?

I didn't post this to the Feature Request Forum, because I want to discuss the different ideas with you folks.

8
Graphics / sf::GlResource for own resources
« on: September 18, 2011, 12:39:50 pm »
I wonder if it's a good idea to create own gl resources using sf::GlResource baseclass.

The documentation says the sf::GlResource class to be "for internal use only".

Does this mean "Bad Idea"?

I've taken a look on the source of the texture class. Are there other things to keep in Mind than calling EnsureGlContext(); before any OpenGL functions?

9
Feature requests / CustomFont
« on: September 17, 2011, 05:58:09 pm »
I don't know, whether this would fit to the idea of SFML.

An overlaodable CustomFont class we can use with a sf::Text object.

rough idea of usage:
Code: [Select]
class MyFont : CustomFont
{
  sf::Font fnt;

  void draw_character(UniCodeeChar char)
  {
    Texture t = fnt.GetTexture(char);

    //handle offset seomehow
   
    // draw green Circle around character
    // draw t with red color, and scalred along y axis
    // draw t with yellow Color
  }
};


To achieve in this case something like this:

(image removed)

A more usefull case for this class could be rendering Text with custom glow or smooth shadow aor any other text effects

10
Feature requests / Keyboard: Add Circumflex support
« on: September 15, 2011, 10:32:28 am »
A pretty small feature request:

Add a Circumflex Key-Code. Thats a quite common key used in Games to open a developer Terminal.

greetings, Robert

11
Window / KeyCode Shift+Tab Bug
« on: September 12, 2011, 11:02:44 am »
I am programming a GUI system and want to navigate through it using Tab and Shift+Tab

using Tab works perfect, but Shift+Tab sends KeyCode 0

I am using Ubuntu x64 and SFML 2.0

12
Window / sigsev qhen quitting after calling Window::create
« on: September 07, 2011, 03:18:54 pm »
I've used SFML 2.x (fetched and compiled today)

to reproduce compile the following code, run it.
press seval times (about 10 times) Tab and then quit with esc.

There are no errors on my PC (GTX 470, Ubuntu x64), but on my notebook (intel GM45, Ubuntu x64) this gets a sigsev.

Code: [Select]

#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <iostream>

void init_states()
{
  // Set color and depth clear value
  glClearDepth(1.f);
  glClearColor(0.f, 0.f, 0.f, 0.f);

  // Enable Z-buffer read and write
  glEnable(GL_DEPTH_TEST);
  glDepthMask(GL_TRUE);

  // Setup a perspective projection
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(90.f, 1.f, 1.f, 500.f);
}

int main()
{
    sf::ContextSettings Settings;
    Settings.DepthBits         = 32; // Request a 24 bits depth buffer
    Settings.StencilBits       = 8;  // Request a 8 bits stencil buffer
    Settings.AntialiasingLevel = 4;  // Request 2 levels of antialiasing
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close, Settings);
 
    // Create a clock for me
    sf::Clock Clock;

    init_states();
   
    App.SetFramerateLimit(640);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.PollEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                App.Close();
             
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Tab))
            {
              App.Create(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close);
              init_states();
            }

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

        // Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls
        App.SetActive();

        // Clear color and depth buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
       
        //a += 0.1f;
        glRotatef(Clock.GetElapsedTime() * 0.001f * 50.f, 1.f, 0.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 0.001f * 30.f, 0.f, 1.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 0.001f * 90.f, 0.f, 0.f, 1.f);

        // Draw a cube
        glBegin(GL_QUADS);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f( 50.f,  50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);

            glVertex3f(-50.f, -50.f, 50.f);
            glVertex3f(-50.f,  50.f, 50.f);
            glVertex3f( 50.f,  50.f, 50.f);
            glVertex3f( 50.f, -50.f, 50.f);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f(-50.f,  50.f,  50.f);
            glVertex3f(-50.f, -50.f,  50.f);

            glVertex3f(50.f, -50.f, -50.f);
            glVertex3f(50.f,  50.f, -50.f);
            glVertex3f(50.f,  50.f,  50.f);
            glVertex3f(50.f, -50.f,  50.f);

            glVertex3f(-50.f, -50.f,  50.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f,  50.f);

            glVertex3f(-50.f, 50.f,  50.f);
            glVertex3f(-50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f,  50.f);

        glEnd();
       
        static int i=0;
        std::cout<<"rendered frame "<<i++<<"\n";
       

        // Finally, display rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


This is the callstack:
Code: [Select]
#0  0x00007ffff3d993c6 in ?? () from /lib/x86_64-linux-gnu/libdrm_intel.so.1
#1  0x00007ffff4924ace in ?? () from /usr/lib/dri/i965_dri.so
#2  0x00007ffff450f91c in _mesa_reference_buffer_object ()
   from /usr/lib/dri/libdricore.so
#3  0x00007ffff457da4e in ?? () from /usr/lib/dri/libdricore.so
#4  0x00007ffff454c59f in _mesa_HashDeleteAll ()
   from /usr/lib/dri/libdricore.so
#5  0x00007ffff457dd50 in _mesa_release_shared_state ()
   from /usr/lib/dri/libdricore.so
#6  0x00007ffff4518749 in _mesa_free_context_data ()
   from /usr/lib/dri/libdricore.so
#7  0x00007ffff492774e in intelDestroyContext () from /usr/lib/dri/i965_dri.so
#8  0x00007ffff491cc30 in ?? () from /usr/lib/dri/i965_dri.so
#9  0x00007ffff6c53655 in ?? () from /usr/lib/mesa/libGL.so.1
#10 0x00007ffff7bcd485 in sf::priv::GlxContext::~GlxContext (this=0x969fe0,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/Linux/GlxContext.cpp:118
#11 0x00007ffff7bcd544 in sf::priv::GlxContext::~GlxContext (this=0x969fe0,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/Linux/GlxContext.cpp:131
#12 0x00007ffff7bc5aaf in sf::priv::GlContext::GlobalCleanup ()
---Type <return> to continue, or q <return> to quit---
    at /home/robert/FLOSS/SFML/src/SFML/Window/GlContext.cpp:128
#13 0x00007ffff7bc7021 in sf::GlResource::~GlResource (this=0x7fffffffe060,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/GlResource.cpp:78
#14 0x00007ffff7bca1d3 in sf::Window::~Window (this=0x7fffffffe060,
    __in_chrg=<value optimized out>)
    at /home/robert/FLOSS/SFML/src/SFML/Window/Window.cpp:80
#15 0x0000000000401b61 in main ()

13
Feature requests / Window::SetSize(0, 0)
« on: August 29, 2011, 10:38:28 pm »
Hello Guys,

First: I am new to SFML and already love it! So I want to contribute with a small Feature-Request ;)

I had a small issue today. My Applicatio crashed with the message:
Code: [Select]
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  12 (X_ConfigureWindow)
  Value in failed request:  0x0
  Serial number of failed request:  64
  Current serial number in output stream:  64


After one hour work I figured out I accidentally called Widnow::SetSize with width==0 and height==0

It's no problem for me anymore, but for other new users it could be nice if some sort af error message (warning in console?) could telll them illegal size values has been used. Maybe we could use in Window.cpp something like this?
Code: [Select]
////////////////////////////////////////////////////////////
void Window::SetSize(unsigned int width, unsigned int height)
{
    if(width <= 0)
        Err() << "Window width must be > 0" << std::endl;

    if(height <= 0)
        Err() << "Window height must be > 0" << std::endl;

    if (myWindow)
        myWindow->SetSize(width, height);
}


PS: I could reproduce it on two different Linux-Computers (one with NVidia and one with Intel GPU) so I don't think this to be a problem of my drivers.

best regards,
Robert

Pages: [1]
anything