• Content count

  • Joined

  • Last visited

Community Reputation

207 Neutral

About Kasya

  • Rank
  1. Hello, I have been trying to integrate awesomium UI to OSG. What I am trying to do is to create a HUD overlay and then design the whole UI in html. Here is the code. Ill explain the unclear stuff in the comments: [CODE] void GraphicsSystem::createHUD() { //geometry of hudGeode, projectionMatrix etc. here. Details are not relevant for my problem. osg::StateSet * ss = new osg::StateSet; ss->setTextureAttributeAndModes(0, hudTexture, osg::StateAttribute::ON); ss->setMode(GL_BLEND, osg::StateAttribute::ON); ss->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); ss->setRenderBinDetails(11, "RenderBin"); hudGeode->setStateSet(ss); } void GraphicsSystem::renderHUD(unsigned char * data) { image->setImage(800,600,1,4,[b]GL_BGRA[/b], GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE, 1); hudTexture->setImage(image); } //hudTexture and image are members of the class GraphicsSystem [/CODE] and here is the awesomium update view function: [CODE] void AwesomiumUI::updateView() { const awe_renderbuffer * rbuffer = awe_webview_render(view); awe_renderbuffer_save_to_png(rbuffer, str2awe("test.png"), false); const unsigned char * buffer = awe_renderbuffer_get_buffer(rbuffer); Base::sys()->sendEvent(new Event1<const unsigned char*>("renderHUD", buffer)); } [/CODE] When I run it I get the following error: [quote]Warning: detected OpenGL error 'invalid enumerant' at after RenderBin::draw(..)[/quote] Couple things I know for sure:[list] [*]AwesomuimUI's render buffer is not empty because [b]awe_renderbuffer_save_to_png[/b] is saving a file test.png correctly [*]The StateSet does not have any issues because I have created a trigger to change the texture dynamically and it worked. [*]The problem is maybe in the image->setImage(...). Maybe the formattings of render buffers in Awesomium and OSG are different. I am still looking it up. [/list] If anyone can help me, I would really appreciate it. Thanks in advance, Gasim EDIT: I have fixed the issue. The problem was I was not using the right texture type. Awesomium is using GL_BGRA. I have bolded it in the code above. But I still need help. The texture is flipped vertically. How can I flip it back using osg?
  2. [font=Arial,][url="http://womble.decadent.org.uk/c++/template-faq.html#type-syntax-error"]http://womble.decadent.org.uk/c++/template-faq.html#type-syntax-error[/url][/font] Here is some info on that. Btw You can use: [code] return this->value; //compiled for me [/code]
  3. I haven't implemented it yet. its in my draft. Currently I am reading a lot of articles about all kinds of MT and implementing them and solving problems. So, I am going to start continuing my game engine after understanding MT really good.
  4. [quote][color=#1C2837][size=2]... which has no reference to the actual object where the event is taking place. If two entities are hit for 50, which one do you change?[/quote] [/size][/color] [color=#1C2837][size=2] [/size][/color] [size="2"][color="#1c2837"]I have figured that one out. Since, game entities are all stored in one single thread, sending events will be sent in sequential order to the other.[/color][/size] [size="2"][color="#1c2837"] [/color][/size] [size="2"][color="#1c2837"]I have found lots of articles. Currently reading and implementing them.[/color][/size] [size="2"][color="#1c2837"] [/color][/size] [size="2"][color="#1c2837"]Thank you everyone for help![/color][/size]
  5. Oh. I now read it again and found out that my design was flawn. Now i changed my draft. [quote][color=#1C2837][size=2]The events will need to include what object the event occurred on, or some identifier that allows the recipient to handle the event properly.[/size][/color][/quote] Handlers take care of that: [code]typedef std::map<String, Handler> HandlerMap[/code] where String is the event's name. [quote][color=#1C2837][size=2]And yes, doing a whole lot of synchronization between threads destroys performance, and yes, designing a system to avoid that effectively is hard.[/size][/color][/quote] Do you know any good open source game engines with effective MT support. I just want to read the code and see how they implemented it. Or is there any good resource (book or article) where its covered pretty well. Thanks in advance, Gasim [color=#1C2837][size=2][/size][/color]
  6. Hello, I am learning MT (using boost.threads) right now. And I have been google-ing all day today about Multithreading, its issues and how to prevent them. But, I still don't understand one thing about communication between threads. I am trying to make an event handler to communicate between threads but I am getting confused everytime i start to think about it. Here is my scenario: I have 3 threads for now: Core, Graphics, and Scripting Each thread has a game system. Game systems have functions to handle the events sent by the components. The events are always read only (they are ONLY created by the Component). Core Thread: It runs Logger, Filesystem, Input, Game Entities (should I change it to a new thread?) Graphics Game System (also thread): Contains all the instances of models, animations etc (using OSG) and renders every graphics related object Scripting Game System (also thread): Contains and Runs Python Scripts. Everything works asynchronously. But here is whats confusing me and not letting me move forward. I have a HealthComponent and for testing purposes I put: [code] if(parent->attribute("health") < 50) { GameSystemHandler::passEvent(new Event1<String>("ChangeAnimation", "AnimationCrippling")); //it sends events to all the game systems (is in the core thread). } [/code] Now, if two entities got shot hard that they lost 70 health out of 100, How GraphicsSystem is going to take care of changing both entities' animations. Isn't it going to overlap?? And the same for Scripting. If two of them says to run some script that has: [code] engine.current_object.doSomething(); [/code] How does the threading know which [b]current_object[/b] it is? In both of these casec, do I have to use mutexes to stop one until the other one finishes? If I do, wouldn't that be a HUGE bottleneck and MT is going to be the same performance of a single threaded environment (concurrency is going to get destroyed due to the syncs). I am really new to the MT theory. Please help me out! Thanks in advance, Gasim
  7. I have finally figured it out. There has to be. thread.join in order to make it execute. Edited my code just in case someone needs it. I have one question though. Is that a good idea to use locks in that scenario, considering that I there is going to be a lot of log messages during development stage? Am I going to lose performance in that case due to sync?
  8. Thank you for fast replies. I have updated the code. But it still doesn't work. I didn't get one right output out of ~15. [img]http://public.gamedev.net/public/style_emoticons/default/blink.gif[/img] Can it be a hardware issue? I am running it on Intel Atom N270 on Ubuntu Linux (don't comment please i know its terrible)
  9. Hello,I need help making a thread safe logging system. Here is my code (works on single thread): [code]class Logger { public: typedef std::vector<LogListener *> ListenerList; private: boost::mutex mutex; ListenerList listeners; public: Logger(); ~Logger(); Logger * write(const String &line); }; Logger * Logger::write(const String &text) { boost::unique_lock<boost::mutex> lock(mutex); //mutex.lock(); for(ListenerList::iterator i = listeners.begin(); i != listeners.end(); ++i) { (*i)->write(text); } //mutex.unlock(); //both didn't work return this; } class FileLogListener : public LogListener { std::ofstream stream; public: FileLogListener(const String &str) : stream(str.c_str(), std::ios::out | std::ios::app) { } void write(const String &text) { stream << text << std::endl; } }; class CoutLogListener : public LogListener { public: CoutLogListener() { } void write(const String &text) { std::cout << text << std::endl; } }; class Base { private: //... static Logger * logger; public: //... static Logger * log() { return logger; } }; Logger::Logger() : mutex(), listeners() { listeners.push_back(new CoutLogListener); listeners.push_back(new FileLogListener("file.txt")); } [/code] [code]//Thread 1 void func1() { Base::log()->write("Thread 1 Test"); } //Thread 2 void func2() { Base::log()->write("Thread 2 test"); } int main() { Base::setLogger(new Logger); boost::thread t1(&func1); boost::thread t2(&func2); t1.join(); t2.join(); return 0; }[/code] [font="Times New Roman"][size="2"]"file.txt" becomes a mess when I run the code (thread 1 is sometimes shown twice, sometimes thread 2 is shown twice, sometimes its correct, sometimes only one is shown once). What am I doing wrong?[/size][/font] [font="Times New Roman"][size="2"]I am on Ubuntu Linux [/size][/font] [font="Times New Roman"][size="2"]Thanks in advance,[/size][/font] [font="Times New Roman"][size="2"]Gasim[/size][/font]
  10. You can put the D3D9ResourceOwner inside the D3D9ResourceManager (there should be only one resource owner, right?) and use the variable from the class member instead of function parameter.
  11. Engine Programming

    Why don't you want to have your own engine which uses other libraries like sfml or allegro?
  12. Thank you for the information. It makes more sense now.
  13. Hello, I have been working on my component based game object design. The thing I got stuck is what is actually Game Logic? Is it, for example, players health, ammo, and other in-game related stuff? If yes, should I consider my "game object" as a game logic element.? The thing I am trying to make is, every subsystem has its own container which stores the id of the component and the entity depending on the subsystem: Graphics -> MeshEntity ParticlePhysics -> ParticleEntity //physics is not main concern, so not worried about this one RigidBodyPhysics -> RigidBodyEntity //"" "" "" "" Logic -> LogicEntity and each subsystem updates its data in its own world and the events occur between subsystems rather than between components. So, Game Object is more of a helper class to combine these stuff and remove from subsystems with one system call like: [code]delete myObject;[/code] (which will trigger deletion of entities in the subsystems it uses) If the GameObject is a Logic Element, I can just use (e.g) health_component, ammo_component etc, and totally remove Logic Subsystem and use HealthSubSystem, AmmoSubSystem etc btw. is this a good design for a game entity class in terms of performance and memory? I hope I could explain what my problem and idea. Sorry for english (not my primary language. working on fixing it). Thanks, Kasya
  14. Hello, I have tried to test my first program in OSG ([url="http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/BasicGeometry"]http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/BasicGeometry[/url]). But I have gotten a problem here. the 3d model overlaps first one from left and comes from right side( Picture: [url="http://imgur.com/rGDf9"]http://imgur.com/rGDf9[/url] ). How can i put limits there, so the object didn't come from right side. Thanks, Kasya