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.


Messages - Robert42

Pages: 1 [2] 3
16
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]

17
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"?

18
Graphics / sf::Texture flexibility
« on: September 19, 2011, 10:49:36 pm »
Quote from: "Laurent"

My conclusion is that you're trying to use a class made for 2D in your 3D graphics engine. It cannot work. Even if sf::Texture is very close to what you need, you will always run into this kind of problems if you don't write your own class.


Ok, thanks. I'll do that. Much work, but it's worth it.

19
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.

20
Feature requests / sf::Color, making it union
« on: September 18, 2011, 08:48:35 pm »
Quote from: "Bozemoto"

union Color
{
   struct
   { GLubyte r,g,b,a; };
   GLuint data32;
};


Correct me if I am wrong, but alignment could be an problem here:
The CPU can access single members faster, if their address is aligned (for example every address%4=0)
In this case &g - &r would be 4, so changing data32 would have no effect on g, b or a

I don't know whether there are compiler activating alignment without asking or whether the C++standart forbids  alignment within unions.

21
Graphics / sf::GlResource for own resources
« on: September 18, 2011, 01:24:47 pm »
thx

22
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?

23
Feature requests / CustomFont
« on: September 17, 2011, 07:04:16 pm »
Quote from: "Laurent"
custom bitmap fonts may be implemented in the future:
http://www.sfml-dev.org/forum/viewtopic.php?t=5334


the custom bitmap fonts look like what I need. thx

24
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

25
Window / RenderWindow::Display is absurdly slow when drawing nothing
« on: September 16, 2011, 10:03:15 pm »
try to set a framerate limit sf::Window::SetFramerateLimit before entering the main loop with a limit < 1000 (for example 120).   and don't forget handle events.

That was the solution for me

26
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

27
Window / KeyCode Shift+Tab Bug
« on: September 15, 2011, 10:24:12 am »
Quote from: "Laurent"

This kind of problems will be solved when SFML handle correctly the keyboard layouts, which is planned for SFML 2.x.

thx

28
Window / Re: KeyCode Shift+Tab Bug
« on: September 12, 2011, 12:42:43 pm »
Hmm, I see now SFML has an issue tracker on github
https://github.com/SFML/SFML/issues

@Laurent: Do you wish us to report Bugs there?

29
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

30
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 ()

Pages: 1 [2] 3