• Content count

  • Joined

  • Last visited

Community Reputation

171 Neutral

About aeroz

  • Rank
  1. Blur shader (2 passes)

    FBO, shaders, and those modern computer graphics concepts are very new to me. But they are very interesting! Thank you for the tips!
  2. Blur shader (2 passes)

    Thank you for the replies! Your solutions make sense. I'm actually implementing a kind of simple glow shader. I want to perform a blur with a specific color and then draw the original scene on top of it. What can I do if I want to have a background image behind the glow? Do you use alpha channels in the FBO's textures? I'm planning to do the following: - Draw background to screen - Draw part of the scene that should have the glow to Tex#1 with alpha channel. - Blur Tex#1. (using the 2 pass method you explained) - Draw Tex#1 to screen. (Background will still be visible because it has an alpha channel) - Draw full scene to screen. I'm not really sure if this is a good solution. Any comments are appreciated.
  3. I'm learning how to use GLSL shaders at the moment. I'm implementing a Gaussian blur shader which uses 2 passes, one for horizontal and one for vertical blur. My question is, do I need to create a texture target for each pass? This way I would render the scene to the first texture, then I would render the first texture to the second texture using the horizontal blur shader, and finally render the second texture to the screen using the vertical shader. I'm not sure if this is the right way. The second possibility I have is to render the scene to the same texture two times once with each shader (and add a * 0.5 to the end of each shader). But with this solution, all the scene geometry has to be drawn twice (and not just 2D textures). Is the double texture approach better? Is there another one? Thank you!
  4. Main game loop design

    Have a look at this article: [url=""]http://gafferongames...-your-timestep/[/url] It's from a game physics tutorial but this particular article is generic. It was quite helpful for me.
  5. I just tested the code under g++ and it compiles fine. Strange... (using #include <memory> and -std=c++0x)
  6. Looks like I have to prefix it with boost::. [url=""][/url] Thank you for the information!
  7. [quote name='SiCrane' timestamp='1327852674' post='4907348'] It looks like this is a argument dependent lookup (ADL) issue (also called Koenig lookup). Basically, before resolving the name of a function call, the compiler looks up all the arguments to the function call. If those arguments use namespace X, namespace X is added to the possible namespaces to look at when resolving the name of the function call. [/quote] Does that mean that Visual C++ is not standard compliant or is it the code?
  8. I was able to remove all the unimportant code from my project and got a minimal error producing example! [CODE] #include <boost/bind.hpp> #include <boost/make_shared.hpp> #include <boost/function.hpp> #include <string> class A { public: A(boost::function0<void>) {} }; void f() {} void g(std::string) {} int main() { using boost::make_shared; make_shared<A>( boost::bind(f) ); // no error make_shared<A>( boost::bind(g, "hoi") ); // error return 0; } [/CODE] Can you imagine why it doesn't compile? The error is same as before: [CODE] 1>c:\users\christian\documents\visual studio 2010\projects\minimalmakesharederror\main.cpp(18): error C2668: 'boost::make_shared' : ambiguous call to overloaded function 1> c:\libraries\boost_1_47\boost\smart_ptr\make_shared.hpp(198): could be 'boost::shared_ptr<T> boost::make_shared<A,boost::_bi::bind_t<R,F,L>>(A1 &&)' 1> with 1> [ 1> T=A, 1> R=void, 1> F=void (__cdecl *)(std::string), 1> L=boost::_bi::list1<boost::_bi::value<const char *>>, 1> A1=boost::_bi::bind_t<void,void (__cdecl *)(std::string),boost::_bi::list1<boost::_bi::value<const char *>>> 1> ] 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\xxshared(33): or 'std::tr1::shared_ptr<_Ty> std::tr1::make_shared<A,boost::_bi::bind_t<R,F,L>>(_Arg0 &&)' [found using argument-dependent lookup] 1> with 1> [ 1> _Ty=A, 1> R=void, 1> F=void (__cdecl *)(std::string), 1> L=boost::_bi::list1<boost::_bi::value<const char *>>, 1> _Arg0=boost::_bi::bind_t<void,void (__cdecl *)(std::string),boost::_bi::list1<boost::_bi::value<const char *>>> 1> ] 1> while trying to match the argument list '(boost::_bi::bind_t<R,F,L>)' 1> with 1> [ 1> R=void, 1> F=void (__cdecl *)(std::string), 1> L=boost::_bi::list1<boost::_bi::value<const char *>> 1> ] [/CODE] Note that the error is only there when the argument type of [b]g[/b] is in the std namespace.
  9. How to remove the left overs of SDL_FillRect?

    What I meant is that you should entirely remove SDL_FillRect from your code. (or do you want to have a rectangle there?) What does the OrangeGhostKnight surface look like? (or the base image) Is it black in the background? Try this: [CODE] SDL_BlitSurface(OrangeGhostKnightSurf,NULL,Screen,&OrangeGhostKnightRect); SDL_SetColorKey(OrangeGhostKnightSurf, SDL_SRCCOLORKEY |SDL_RLEACCEL, SDL_MapRGB(OrangeGhostKnightSurf->format,0, 0, 0)); SDL_Flip(Screen); [/CODE]
  10. 2d tile collision advice

    How do you want exactly the collision to be? And what is colliding with what? If the objects are all rectanges you could try AABB Collision Detection.
  11. How to remove the left overs of SDL_FillRect?

    With SDL_FillRect your are explicitly creating that black rectangle. And also try setting the color key before you blit the surface.
  12. Hi! I'm having a strange problem that I hope you guys can help me understand. I'm using Visual Studio 2010 SP1. The code compiles fine with the g++ compiler. I tried to reproduce the problem with minimum code, but I was not yet able to get the error. Here's my code: [CODE] SomeClass::SomeMethod() { using boost::make_shared; // this does work: make_shared<WidgetButton>( Rect(1,2,3,4), "hoi", boost::bind( &MainMenuState::onPressedButBack, this ), boost::bind( &MainMenuState::onPressedSound, this ) ); // this does not work: (produces the error below) make_shared<WidgetButton>( Rect(1,2,3,4), "hoi", boost::bind( &MainMenuState::onPressedOpenLevel, this, "hoi" ), boost::bind( &MainMenuState::onPressedSound, this ) ); // this does work: boost::make_shared<WidgetButton>( Rect(1,2,3,4), "hoi", boost::bind( &MainMenuState::onPressedOpenLevel, this, "hoi" ), boost::bind( &MainMenuState::onPressedSound, this ) ); } [/CODE] VS gives me this: [CODE] 1>..\src\game\states\MainMenuState.cpp(125): error C2668: 'boost::make_shared' : ambiguous call to overloaded function 1> C:\Libraries\boost_1_47\boost/smart_ptr/make_shared.hpp(330): could be 'boost::shared_ptr<T> boost::make_shared<WidgetButton,Rect,const char(&)[4],boost::_bi::bind_t<R,F,L>,boost::_bi::bind_t<R,boost::_mfi::mf0<R,MainMenuState>,boost::_bi::list1<A1>>>(Rect &&,A2,A3 &&,A4 &&)' 1> with 1> [ 1> T=WidgetButton, 1> R=void, 1> F=boost::_mfi::mf1<void,MainMenuState,const std::string &>, 1> L=boost::_bi::list2<boost::_bi::value<MainMenuState *>,boost::_bi::value<const char *>>, 1> A1=boost::_bi::value<MainMenuState *>, 1> A2=const char (&)[4], 1> A3=boost::_bi::bind_t<void,boost::_mfi::mf1<void,MainMenuState,const std::string &>,boost::_bi::list2<boost::_bi::value<MainMenuState *>,boost::_bi::value<const char *>>>, 1> A4=boost::_bi::bind_t<void,boost::_mfi::mf0<void,MainMenuState>,boost::_bi::list1<boost::_bi::value<MainMenuState *>>> 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xxshared(33): or 'std::tr1::shared_ptr<_Ty> std::tr1::make_shared<WidgetButton,Rect,const char(&)[4],boost::_bi::bind_t<R,F,L>,boost::_bi::bind_t<R,boost::_mfi::mf0<R,T>,boost::_bi::list1<A1>>>(_Arg0 &&,_Arg1,_Arg2 &&,_Arg3 &&)' [found using argument-dependent lookup] 1> with 1> [ 1> _Ty=WidgetButton, 1> R=void, 1> F=boost::_mfi::mf1<void,MainMenuState,const std::string &>, 1> L=boost::_bi::list2<boost::_bi::value<MainMenuState *>,boost::_bi::value<const char *>>, 1> T=MainMenuState, 1> A1=boost::_bi::value<MainMenuState *>, 1> _Arg0=Rect, 1> _Arg1=const char (&)[4], 1> _Arg2=boost::_bi::bind_t<void,boost::_mfi::mf1<void,MainMenuState,const std::string &>,boost::_bi::list2<boost::_bi::value<MainMenuState *>,boost::_bi::value<const char *>>>, 1> _Arg3=boost::_bi::bind_t<void,boost::_mfi::mf0<void,MainMenuState>,boost::_bi::list1<boost::_bi::value<MainMenuState *>>> 1> ] 1> while trying to match the argument list '(Rect, const char [4], boost::_bi::bind_t<R,F,L>, boost::_bi::bind_t<R,F,L>)' 1> with 1> [ 1> R=void, 1> F=boost::_mfi::mf1<void,MainMenuState,const std::string &>, 1> L=boost::_bi::list2<boost::_bi::value<MainMenuState *>,boost::_bi::value<const char *>> 1> ] 1> and 1> [ 1> R=void, 1> F=boost::_mfi::mf0<void,MainMenuState>, 1> L=boost::_bi::list1<boost::_bi::value<MainMenuState *>> 1> ] [/CODE] EDIT: the declaration of WidgetButton's constructor might be helpful for you: [CODE] WidgetButton( Rect area, const std::string& caption, boost::function0<void> clickedCallbackFunc, boost::function0<void> mouseOverCallbackFunc ); [/CODE] Nowhere I have "using namespace std;", so for me its weird that it tries to use "std::tr1::make_shared" and not "boost::make_shared". The other weird thing is that when slightly modify the 3rd argument to the WidgetButton constructor (see code), it works... As you can see I could just remove the using declaration and prepend boost:: to the make_shared call, but I want to understand why its not working. Looking forward to your replies!
  13. Inspector GUI

    You are welcome. I think I don't really need a tree. A list of properties should be enough (with support for arrays). But Boost.PropertyTree is already there, and it is easy to use. I will think about it...
  14. [quote]As for your updating of components the only things that jumps out at me is first what exactly your entity manager has to do? Why do components need to be enabled or disabled? And second, why are you storing pointers to components in both the entity and the component manager? Does the entity really need to be able to query it's components directly? Could you instead store a mapping from components to their owning entity in your component system and direct all queries through that? And at that point do you even really need an Entity class? Could your entities just be a unique id? [/quote] I think that removing the Entity class is a good idea. I'm planning on doing that too in may game, because the code doesn't depend on the Entity class by itself. In components, I have code like: getOwnerEntity()->getComponent<CompPhysics>(); This would be replaced by componentManager->getComponentInEntity<CompPhysics>(getOwnerEntityId());
  15. Inspector GUI

    [quote name='simpler' timestamp='1299618671' post='4783278'] I've never touched the boost library before (should i?) so I didn't grasp everything. [/quote] There are a lot of nice things in the boost library that help you with many tasks in C++, like smart pointers, function objects, signals, foreach. I use it quite often. The boost PropertyTree is something like [code]struct ptree { data_type data; // data associated with the node list< pair<key_type, ptree> > children; // ordered list of named children };[/code] If some part of the code is not clear because I'm using boost, just post the corresponding lines. [quote] But what you basicaly do is that you write and read from a "virtual" XML, [font="sans-serif"][size="2"]INI or JSON file?[/size][/font] [/quote] Yes I think I would do that, but you can also hardcode it, since the schema cannot be changed without changing the code. (Except you want to add something like a "display_name" entry for the GUI that you could change without breaking the code) [quote] [font="sans-serif"][size="2"]How would you handle the widgets if one changes the selected object? Will you delete all widgets that the last active object used and then create the new one as needed? It seems like the easiest way of doing it but if the last active object and the currently active object shares some widgets then it feels a bit unnecessary, but it mightn't be worth the effort to care about.[/size][/font] [/quote] In my case I would use some sort of tree view widget because my properties can have children. Every time the selected object changes I delete all entries in the tree and add the entries for the new object. I think you don't need to optimize things here, it should be fast enough... (But if you want you can for example pre-create some text edit widgets and label widgets and hide/show/edit them corresponding to the number and type of options you have) [font="sans-serif"][size="2"][quote][/size][/font][color="#1c2837"][size="2"][quote]Have a property container class that can hold different types of data (for example like boost's PropertyTree)[/quote][/size][/color] [color="#1c2837"][size="2"]It's that one that stores all the attributes, right?[/size][/color] [/quote] I don't know what you mean by attributes. If you mean the attributes of the different object classes, then yes, more or less (you only need to store the attributes that need to be stored...). The property list for my physics component would be something like [code] damping = { linear=0 angular=0 } shape = { comp_name="shape1" density=5 friction=0.3 restitution=0 } shape = { comp_name="shape2" density=1 friction=0.6 restitution=0.1 }[/code]