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

Pages: [1] 2 3 ... 6
1
General / Re: Compile error when writing own class. - HELP!
« on: January 09, 2009, 09:31:02 am »
Quote from: "YellowShadow"

Code: [Select]

#ifndef PLAYER_H
#define PLAYER_h

#include <string>

#include <SFML/Graphics.hpp>

class Player
{
    private:
        sf::RenderWindow window;
    public:
       Player(std::string name, sf::Vector2 position, sf::RenderWindow window);
};

#endif


Code: [Select]

#include "Player.h"

Player::Player(std::string name, sf::Vector2 position, sf::RenderWindow *window)
    : name(name), position(position), window(window)
{

}




also not good .. declaration wants a copy but implementation wants a pointer.. if I where you I would change window variable to be a pointer.

2
Feature requests / "Huge Sprites"
« on: December 13, 2008, 01:11:47 pm »
Quote from: "Imbue"
Quote from: "nitram_cero"
While reading the code, I found out that each sf::Image also keeps a local (system memory) copy of the pixels.
I'm not 100% sure, but I don't think you can trust the graphics card to store images for very long (like hitting alt-tab may wipe the memory).


I belive that is only a problem on DirectX version <= 9.
OpenGL and DX10 should not have that problem.

3
Feature requests / Re: Message Boxes
« on: December 02, 2008, 06:21:07 pm »
Quote from: "efeXor"
(Yes i know you can do it using the winapi but it requires alot of stuff being setup).


win32 api message box is not that hard to do :)
Code: [Select]

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int main(void)
{
    MessageBoxA(NULL, "text", "Title!!", MB_OKCANCEL | MB_ICONEXCLAMATION)
    return 0;
}

4
Window / Window creation crashes
« on: November 27, 2008, 10:23:39 am »
Quote from: "T.T.H."

On the other hand it scares me a bit that enabling an optimization of the compiler produces code which causes horrific behavior on processors not having the features necessary for said optimization. Is it common like that?


Which is why you have to know what you tell your compiler to do! The scary thing is that Visual Studio neatly hides all this so people usually have no clue what they tell the compiler to do for them. If you tell your compiler to SSE2 optimize your code you will not support older machines.
Quote from: "T.T.H."

Is there no "fall back path" during runtime in case the feature is missing? is the behavior really that horrific (crashes without any hint on what went wrong)?

If there was a fall back it would probably make it much slower then just running without SSE which wouldn't make sense. If you want to support older machines and have SSE optimizations you will have to compile multiple exes.

5
SFML wiki / Translate French pages into English.
« on: November 23, 2008, 04:50:23 pm »
http://translate.google.com/translate_t

works quite well for me when i want to check out the French articles :)

6
SFML projects / Would be fine if...
« on: November 19, 2008, 09:06:12 pm »
what kind of game are you making?

you could look up something called double dispatch if you want to have different behavior depending on what 2 items collide... [/url]

7
Graphics / svn: Image.LoadFromFile and Image.Create crashes
« on: November 17, 2008, 01:19:06 pm »
umm see the thread 2 posts down perhaps ?...

http://www.sfml-dev.org/forum/viewtopic.php?t=726

8
Feature requests / Add support for custom refresh rates
« on: November 08, 2008, 11:41:18 am »
Quote from: "Tungsten"
Uh , i think you misunderstood that statement.

The current svn-version of sfml will default back to 60hz no matter what refresh rate you use in desktop mode. You will always end up with 60 hz in fullscreen mode.

The change adds support for the user to specify the refresh rate used in fullscreen mode nothing else. If the specified refresh rate is not a supported mode it will fail and default back to the "best" mode supported by the card.

If you do not specify a value it will be set to 60. If that is not a supported refresh rate(which is highly unlikely) it will also fail and default back to the "best" mode supported by the card. That functionality is already implemented in sfml by the IsValid() method in the VideoMode class.

Of course you can change the behaviour so if no refresh rate value is specified it will try to pick the current desktop refresh rate but that might also fail if you use a different fullscreen resolution compared to your desktop resolution.


Aaaah i see :) and now i agree with you :)

9
Window / Re: Custom Cursor
« on: November 07, 2008, 09:35:28 pm »
Quote from: "ElChupacabra"
How can I set a custom cursor(like a crosshair) for a given RenderWindow? Are there some Methods in SFML for this?


Paint a cursor the way you whant it to look in a graphics program such as Paint.NET/Gimp or if you can afford it Photshop.

Then set that sprite at the current mouse position. might also be a good idea to make sure it is renderd last (is on top of everything else)

10
Feature requests / sfml equivalent of GetMessage()
« on: November 07, 2008, 09:32:36 pm »
Quote from: "kfriddile"

Haha, you've just described why I decided not to use sfml.  It is a third party library that would force my program to have memory leaks.  The choice is still yours whether or not to use such a library, so control over your program's memory usage is still ultimately yours.


Or since SFML uses the zlib license, take the parts of SFML you like. Or even better fix the memory leak and use that ;).. and if you fix the leak earn brownie points by submitting a patch :) .. it's open source for a reason!

11
Feature requests / Re: Add support for custom refresh rates
« on: November 07, 2008, 09:26:53 pm »
Quote from: "Tungsten"
If you are using a CRT-monitor it will default to 60 Hz when using fullscreen mode. Instead of using a refresh rate locker for certain resolutions add a member to the VideoMode class.


A better solution would be to use the refresh rate currently selected by the user.. or you will probably be hated by all the gamers that play your game that have a monitor capable of higher refresh rates. That makes it safer to use to. in case someone has a monitor that does not support 60hz :)

12
Graphics / Draw on an Image?
« on: October 18, 2008, 11:08:32 am »
Quote from: "Wizzard"
Quote from: "Apprauuuu"
Hmm but this runs a bit slow when I draw 2000 tiles per frame -.-
Am I able to use this function with OpenGl itself and include it into the program??

You can use OpenGL with the graphics package, but it'll slow down the speed of the Draw member of RenderWindow.
This means that you will speed up your tile rendering performance, but slow down the rendering performance of everything else.
However, SFML is faster at rendering sprites than most APIs like it; perhaps you are doing something wrong.


It doesn't have to be.. if you inherit a class from sf::Drawable you can render it using OpenGL without having to preserve SFMLs states. that is what i did with my particle system and it works quite well :)

13
General / 2 Problems
« on: October 16, 2008, 10:51:01 am »
Quote from: "T.T.H."
First I strongly believe in "never change a running system"


well.. it obviously doesn't run stable anymore does it ;) well all jokes aside .. updating graphics drivers is a pretty safe thing to do. (i have never ever encountered errors in updating graphics drivers (though quite a few errors have been solved when doing this)) and The game you named Warcraft 3 and Guild Wars are quite old :) but then again since sfml is a 2d api one would expect it to run well on old hardware...

14
Feature requests / DLL convenience wrapper
« on: October 16, 2008, 10:44:54 am »
Quote from: "Core Xii"
If it works, thanks. I couldn't do this myself. OgreDynLib.h includes OgrePrerequisites.h, which in turn includes OgrePlatform.h, OgreStdHeaders.h and OgreMemoryAllocatorConfig.h; Which include a bunch of STL headers. Got much too entangled for me to handle.


You should never try to dig that deep at once. start by checking out the class definition and see what the class actually uses. it is quite obvious that this class uses very little of Ogres internal functions. oh and yes it works i played with it some more yesterday and as an example loaded up the functions SDL_SetError and SDL_GetError from sdl.dll and used called them and it worked :)

here is the way i did it:
1. fix obvius errors (like removing Ogre includes, inheritances, and preprocessor commands)
2. hit compile
3. fix errors (like Ogre::String and ogre log/exceptions)
4. goto 2 until no more errors
5. tests it out and fix runtime errors(actualy i never got any runtime errors.. i just had to figure out how to casts the void* returned from getSymbol to a usable function pointer)

common errors was
1. platform defines (sfml has these in it's system lib so i just switched to those
2. String (is a ogre typedef of std::string) so i replaced all String with std::string
3. exchanged all ogre exceptions and logger calls to std::cerr calls
4. it inherits from some kind of ogre allocator... which i do not know what it does and have no intentions to find out... so it got removed completely.. and i have noticed no errors.

learning how to refactor other peoples code is a great skill to know, especially if you want to start working as a programmer. (since changing/fixing other peoples code is what you will most likely do all day long ;) )

15
Feature requests / DLL convenience wrapper
« on: October 15, 2008, 09:58:01 pm »
Quote from: "Core Xii"
Right but I'd need to link to Ogre. Bit of a big an engine to link to for one class.


umm as laurent has pointed out a lot of times.. this class is dead simple to rip out.. i did it in ~15min including a test run.

here it is btw.. one thing to remember though is that since this is slightly modified OGRE code it will fall into the LGPL license.

header file
Code: [Select]

#ifndef _DynLib_H__
#define _DynLib_H__

#include <string>
#include "sfml/System.hpp"

#if defined(SFML_SYSTEM_WINDOWS)
#    define DYNLIB_HANDLE hInstance
#    define DYNLIB_LOAD( a ) LoadLibraryExA( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )

struct HINSTANCE__;
typedef struct HINSTANCE__* hInstance;

#elif defined(SFML_SYSTEM_LINUX)
#    define DYNLIB_HANDLE void*
#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
#    define DYNLIB_UNLOAD( a ) dlclose( a )

#elif defined(SFML_SYSTEM_MACOS)
#    define DYNLIB_HANDLE CFBundleRef
#    define DYNLIB_LOAD( a ) mac_loadExeBundle( a )
#    define DYNLIB_GETSYM( a, b ) mac_getBundleSym( a, b )
#    define DYNLIB_UNLOAD( a ) mac_unloadExeBundle( a )
#endif

namespace sf
{
class DynLib
    {
protected:
std::string mName;
std::string dynlibError(void);
    public:
        DynLib( const std::string& name );
        ~DynLib();
        void load();
        void unload();
const std::string& getName(void) const { return mName; }
        void* getSymbol( const std::string& strName ) const throw();
    protected:
        DYNLIB_HANDLE m_hInst;
    };
}

#endif




and the cpp file:

Code: [Select]

#include "DynLib.h"
#include <iostream>
#if defined(SFML_SYSTEM_WINDOWS)
#   define WIN32_LEAN_AND_MEAN
#   include <windows.h>
#endif

#if defined(SFML_SYSTEM_MACOS)
#   include "macPlugins.h"
#endif

namespace sf
{
    DynLib::DynLib( const std::string& name )
    {
        mName = name;
        m_hInst = NULL;
    }
    DynLib::~DynLib()
    {
    }
    void DynLib::load()
    {
std::string name = mName;
#if defined(SFML_SYSTEM_LINUX)
        // dlopen() does not add .so to the filename, like windows does for .dll
        if (name.substr(name.length() - 3, 3) != ".so")
           name += ".so";
#endif
        m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
        if( !m_hInst )
            std::cerr << "Could not load dynamic library " << mName << ".  System Error: " << dynlibError() << "DynLib::load" ;
    }

    void DynLib::unload()
    {
        if( DYNLIB_UNLOAD( m_hInst ) )
{
            std::cerr << "Could not unload dynamic library " << mName << ".  System Error: " << dynlibError() << "DynLib::unload";
}

    }

    void* DynLib::getSymbol( const std::string& strName ) const throw()
    {
        return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
    }
    std::string DynLib::dynlibError( void )
    {
#if defined(SFML_SYSTEM_WINDOWS)
        LPVOID lpMsgBuf;
        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
        std::string ret = (char*)lpMsgBuf;
        LocalFree( lpMsgBuf );
        return ret;
#elif defined(SFML_SYSTEM_LINUX)
        return std::string(dlerror());
#elif defined(SFML_SYSTEM_MACOS)
        return std::string(mac_errorBundle());
#else
        return std::string("");
#endif
    }

}



so now i saved you all 15min of work ;)

Pages: [1] 2 3 ... 6