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 - kloffy

Pages: [1] 2
1
General / Re: Implementing gamle loop with alpha state blending
« on: February 26, 2014, 03:03:56 pm »
The OP question is an interesting one. I would love to see an elegant implementation of a system that interpolates between states as described in Gaffer's article.

2
Also on your second one? my ProjectileObjects has parameters how can I make it so with make_shared call?
Simply pass the constructor parameters to the make_shared function. They will be forwarded.

3
That is because a pointer is not a shared_ptr. In C++11 this will work:

vector<  shared_ptr< SpriteAssets > > _projectiles;
_projectiles.emplace_back( new ProjectileObjects() );

Otherwise, just create a shared_ptr:

vector<  shared_ptr< SpriteAssets > > _projectiles;
_projectiles.push_back( make_shared<ProjectileObjects>() );

4
1.  using multiple namespaces is a BAD idea.  if you have multiple libraries with the same class or method and have declared both libraries as a namespace you are gonna have bad conflicts.
1. My tutor had our template SFML project setup with these but ill get rid of them as I agree ill end up running into problems and namespaces are really just lazy coding.
Just to make this clear in case it was not: The Hatchet was referring to the "using namespace"-statements, and not the namespaces themselves. Namespaces are a good practice.

5
Try:

std::list<Enemy*>::const_iterator temp = enemies.begin();

6
General discussions / Re: A new logo for SFML
« on: May 02, 2013, 10:36:44 pm »
I think it looks a little bit cramped now. I guess there's not much space in that green bar. You could try making the text smaller, but then it will probably be hard to read. Anyway, that's just nit-picking...

7
General discussions / Re: SFML 2 and its new website released
« on: April 29, 2013, 08:01:58 pm »
Congratulations, excellent work!

8
General discussions / Re: A new logo for SFML
« on: April 29, 2013, 02:03:32 pm »
I think this one is the best:


Great choice! I really like how this one evolved into a very polished design.

9
General discussions / Re: A new logo for SFML
« on: April 23, 2013, 07:24:35 pm »
I thought Waylorn's concept deserved to be given a serious try. I've incorporated it with Cornstalks' font.

Full disclosure: I used the bird from the Hollister logo for reference. The similarity might be a problem...

[attachment deleted by admin]

10
General discussions / Re: A new logo for SFML
« on: April 22, 2013, 03:51:19 am »
Waylorn's ideas are really neat. Love the spine tailed swift. Bonus points for picking bird species that match the trajectories.  :D

11
It is planned for a future version, don't worry.
Amazing, I can't wait to be able to do this through the official API.  :D

12
There was a thread about this a while ago (not sure where it went, forum search is kind of broken). Basically, it would be really useful to have the ability to change the window style without recreating the window (and with it the OpenGL context). In particular, this allows a very fast "lightweight" fullscreen mode by resizing the window and hiding the border. I posted a working implementation for Windows:

void setStyle(sf::Window& window, sf::Uint32 style)
{
    HWND handle = window.getSystemHandle();
    DWORD win32Style = WS_VISIBLE;

    if (style == sf::Style::None)
    {
        win32Style |= WS_POPUP;
    }
    else
    {
        if (style & sf::Style::Titlebar) win32Style |= WS_CAPTION | WS_MINIMIZEBOX;
        if (style & sf::Style::Resize)   win32Style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
        if (style & sf::Style::Close)    win32Style |= WS_SYSMENU;
    }

    SetWindowLongPtr(handle, GWL_STYLE, win32Style);

    // Force changes to take effect
    SetWindowPos(handle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_DRAWFRAME);
}

I realize it may be more difficult on other platforms (haven't tried it), but it would be worth looking into. Understandably, Laurent already said that it will not make it into 2.0, so I am crossing my fingers for future versions.

13
General discussions / Re: SFML2 & OpenSceneGraph Examples
« on: March 09, 2013, 12:59:07 am »
Example 4: Mixed OSG/SFML Rendering

This is what eXpl0it3r already hinted at: Drawing from both APIs. This can be somewhat tricky due to the shared OpenGL state. Nevertheless, it is possible and here is one way to go about it:

#if defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:\"console\"")
#else
#pragma comment(linker, "/SUBSYSTEM:\"windows\" /ENTRY:\"mainCRTStartup\"")
#endif

#if defined(_DEBUG)
#pragma comment(lib, "sfml-graphics-d.lib")
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-system-d.lib")
#else
#pragma comment(lib, "sfml-graphics.lib")
#pragma comment(lib, "sfml-window.lib")
#pragma comment(lib, "sfml-system.lib")
#endif

#if defined(_DEBUG)
#pragma comment(lib, "osgd.lib")
#pragma comment(lib, "osgDBd.lib")
#pragma comment(lib, "osgGAd.lib")
#pragma comment(lib, "osgViewerd.lib")
#else
#pragma comment(lib, "osg.lib")
#pragma comment(lib, "osgDB.lib")
#pragma comment(lib, "osgGA.lib")
#pragma comment(lib, "osgViewer.lib")
#endif

#include <SFML/Graphics.hpp>

#pragma warning(push)
#pragma warning(disable: 4250)

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgGA/TrackballManipulator>
#include <osgViewer/Viewer>

#pragma warning(pop)

#include "sf2osg.h"

int main(int argc, char** argv)
{
        //osg::setNotifyLevel(osg::DEBUG_INFO);

        sf::RenderWindow window;
        window.setVerticalSyncEnabled(true);

        sf::VideoMode mode = sf::VideoMode::getDesktopMode();
        mode.width = 800;
        mode.height = 600;

        window.create(mode, "SFML+OSG Example");

        osg::ref_ptr<osg::Node> root = osgDB::readNodeFile("cow.osg");

        if (!root)
        {
                std::cerr << "Failed to load model." << std::endl;
                return 1;
        }

        sf::Vector2u size = window.getSize();

        sf::Font font;
        if (!font.loadFromFile("verdana.ttf"))
        {
                std::cerr << "Failed to load font." << std::endl;
                return 1;
        }

        sf::Text text("Hello SFML+OSG!", font, 24);
        sf::FloatRect bounds = text.getLocalBounds();
        text.setPosition((size.x-bounds.width)/2.0f, (size.y-bounds.height)/2.0f);

        osgViewer::Viewer viewer;
        osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = viewer.setUpViewerAsEmbeddedInWindow(0, 0, size.x, size.y);
        viewer.setCameraManipulator(new osgGA::TrackballManipulator);
        viewer.setSceneData(root.get());
        viewer.realize();

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        sf2osg::processEvent(*(gw->getEventQueue()), event);

                        switch(event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        case sf::Event::KeyPressed:
                                if (event.key.code == sf::Keyboard::Escape)
                                {
                                        window.close();
                                }
                                break;
                        case sf::Event::Resized:
                                window.setView(sf::View(sf::FloatRect(0.0f, 0.0f, float(event.size.width), float(event.size.height))));
                                gw->resized(0, 0, event.size.width, event.size.height);
                                break;
                        }
                }

                if (!window.isOpen()) break;

                window.setActive();

                viewer.frame();

                window.pushGLStates();

                window.draw(text);

                window.popGLStates();

                window.display();
        }

        return 0;
}

While it can be done, I am not convinced that it is actually a good idea. It may be better to just stick with one rendering API. If you're already using OSG, you might as well use it for all your drawing code.

14
General discussions / Re: SFML2 & OpenSceneGraph Examples
« on: March 08, 2013, 11:39:19 pm »
Example 3: Render Something

With the preparations out of the way, let us use the osgViewer to render a model.

#if defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:\"console\"")
#else
#pragma comment(linker, "/SUBSYSTEM:\"windows\" /ENTRY:\"mainCRTStartup\"")
#endif

#if defined(_DEBUG)
#pragma comment(lib, "sfml-graphics-d.lib")
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-system-d.lib")
#else
#pragma comment(lib, "sfml-graphics.lib")
#pragma comment(lib, "sfml-window.lib")
#pragma comment(lib, "sfml-system.lib")
#endif

#if defined(_DEBUG)
#pragma comment(lib, "osgd.lib")
#pragma comment(lib, "osgDBd.lib")
#pragma comment(lib, "osgGAd.lib")
#pragma comment(lib, "osgViewerd.lib")
#else
#pragma comment(lib, "osg.lib")
#pragma comment(lib, "osgDB.lib")
#pragma comment(lib, "osgGA.lib")
#pragma comment(lib, "osgViewer.lib")
#endif

#include <SFML/Graphics.hpp>

#pragma warning(push)
#pragma warning(disable: 4250)

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgGA/TrackballManipulator>
#include <osgViewer/Viewer>

#pragma warning(pop)

#include "sf2osg.h"

int main(int argc, char** argv)
{
        //osg::setNotifyLevel(osg::DEBUG_INFO);

        sf::RenderWindow window;
        window.setVerticalSyncEnabled(true);

        sf::VideoMode mode = sf::VideoMode::getDesktopMode();
        mode.width = 800;
        mode.height = 600;

        window.create(mode, "SFML+OSG Example");

        osg::ref_ptr<osg::Node> root = osgDB::readNodeFile("cow.osg");
       
        if (!root)
        {
                std::cerr << "Failed to load model." << std::endl;
                return 1;
        }
       
        sf::Vector2u size = window.getSize();

        osgViewer::Viewer viewer;
        osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = viewer.setUpViewerAsEmbeddedInWindow(0, 0, size.x, size.y);
        viewer.setCameraManipulator(new osgGA::TrackballManipulator);
        viewer.setSceneData(root.get());
        viewer.realize();

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        sf2osg::processEvent(*(gw->getEventQueue()), event);

                        switch(event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        case sf::Event::KeyPressed:
                                if (event.key.code == sf::Keyboard::Escape)
                                {
                                        window.close();
                                }
                                break;
                        case sf::Event::Resized:
                                gw->resized(0, 0, event.size.width, event.size.height);
                                break;
                        }
                }

                if (!window.isOpen()) break;

                window.setActive();
               
                viewer.frame();

                window.display();
        }

        return 0;
}

In order for this to work, you can either configure the OSG_FILE_PATH environment variable to point to the OSG example data directory or copy the model (and associated data) into the working directory.

15
General discussions / Re: SFML2 & OpenSceneGraph Examples
« on: March 08, 2013, 11:23:33 pm »
Example 2: Inject Events

Since SFML is in charge of the window, it is necessary to forward events to OSG. This requires conversion functions, which are essentially huge switch statements. In order to keep the main application code simple, I threw them in a separate header.

#if defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:\"console\"")
#else
#pragma comment(linker, "/SUBSYSTEM:\"windows\" /ENTRY:\"mainCRTStartup\"")
#endif

#if defined(_DEBUG)
#pragma comment(lib, "sfml-graphics-d.lib")
#pragma comment(lib, "sfml-window-d.lib")
#pragma comment(lib, "sfml-system-d.lib")
#else
#pragma comment(lib, "sfml-graphics.lib")
#pragma comment(lib, "sfml-window.lib")
#pragma comment(lib, "sfml-system.lib")
#endif

#if defined(_DEBUG)
#pragma comment(lib, "osgd.lib")
#pragma comment(lib, "osgGAd.lib")
#pragma comment(lib, "osgViewerd.lib")
#else
#pragma comment(lib, "osg.lib")
#pragma comment(lib, "osgGA.lib")
#pragma comment(lib, "osgViewer.lib")
#endif

#include <SFML/Graphics.hpp>

#pragma warning(push)
#pragma warning(disable: 4250)

#include <osgViewer/Viewer>

#pragma warning(pop)

#include "sf2osg.h"

int main(int argc, char** argv)
{
        //osg::setNotifyLevel(osg::DEBUG_INFO);

        sf::RenderWindow window;
        window.setVerticalSyncEnabled(true);

        sf::VideoMode mode = sf::VideoMode::getDesktopMode();
        mode.width = 800;
        mode.height = 600;

        window.create(mode, "SFML+OSG Example");

        sf::Vector2u size = window.getSize();

        osgViewer::Viewer viewer;
        osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = viewer.setUpViewerAsEmbeddedInWindow(0, 0, size.x, size.y);
        viewer.realize();

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        sf2osg::processEvent(*(gw->getEventQueue()), event);

                        switch(event.type)
                        {
                        case sf::Event::Closed:
                                window.close();
                                break;
                        case sf::Event::KeyPressed:
                                if (event.key.code == sf::Keyboard::Escape)
                                {
                                        window.close();
                                }
                                break;
                        case sf::Event::Resized:
                                gw->resized(0, 0, event.size.width, event.size.height);
                                break;
                        }
                }

                if (!window.isOpen()) break;

                window.setActive();
               
                viewer.frame();

                window.display();
        }

        return 0;
}

I have attached the header file, since it is a bit long. It is not an exhaustive implementation, but it should cover the most common uses.

[attachment deleted by admin]

Pages: [1] 2
anything