Jump to content

Guppy

Members
  • Posts

    775
  • Joined

  • Last visited

Posts posted by Guppy

  1. As I continue on this today something has changed - keyhitstate and keydownstate will both only ever hold 1 character, holding down for instance shift and a will result in only the last key pressed being set to true.

     

    The same is true for holding down multiple characters.

     

     std::string inputBuffer="";
     int c=0;
     for( int i=0; i < 256; i++ ){
    		 if (window->keyhitstate[i]){
    			 inputBuffer+=static_cast<char>(i);
    			 inputBuffer+=" ["+std::to_string(i)+"]";
    			 inputBuffer+=",";
    			 c++;
    		 }
     }
     if ( c > 0 ) {
    	 inputBuffer=std::to_string(c)+" characters: "+inputBuffer;
     }
     window->FlushKeys();
    

     

    I figured this was due to the beta code, but even after uninstalling leadwerks and re-installing and rebuilding my project the problem persists.

     

     

    So something else is afoot here, but what?

  2. (this is a bit long winded - you can just skip to the Question bit if you like)

     

    I'm currently writing an even system to wrap around ( among other things ) the Leadwerks input, this dispatches events that follows this design

     

    post-7741-0-39020400-1410205354.jpg

     

     

    Now the event manger dispatches them as Event* but some listeners may want to make use of the more specialized version so it needs to know if it is capable of that before attempting a downcast as the true type is not known at compile time.

     

    There are several approaches to solve this;

     

    1) give event a "virtual std::string getEventClass()=0;" and compare to that

    The drawback here are string comparison ( which you could solve with hashing ) and inheritance ( a mouseEvent is still UI event but will fail the check )

     

    2) A variation of the above where each class must push a hash of their class name onto a stack, and the stack is then checked.

    This works but is somewhat cumbersome as anyone creating a new event class must remember to push the class name onto the stack or risk breaking the chain.

     

    3) use dynamic_cast

    this was my first idea, using the code below;

     

     template <class cmpType>
     bool isType(const cmpType* src){
    	 return dynamic_cast<const cmpType*>(this) != 0;
     }
    

     

    It works but leaves a lot to be desired for readability and anoyingly you need to pass an instance of what your trying to compare to rather than just a class. So I took to the web trying to see if anyone had solved the contract ( / acyclic visitor / reflective visitor ) pattern in C++. What I found was a lot of people saying the sky would fall if one were to use dynamic_cast - but nobody offered an opinion as to why.

     

     

    Question:

     

    Why is dynamic_cast evil?

    • Upvote 1
  3. This is where I'm tempted to simply post a snarky "could you possibly be a bit more vague?"

     

    But really you have very little information in your post for anyone trying to help you, perhaps include;

    • What version of leadwerks your using
    • How you attempted to integrate it
    • what you have already tried in order to fix it

    Also this is a very handy document that far to few people have read;

    http://www.catb.org/esr/faqs/smart-questions.html

  4. Is there a way to get raw key presses in Leadwerks?

     

    I mean getting an the actuall letter "A" rather than a Leadwerks::Key::A

     

    My first naive approach after noticing that window->keyhitstate was 256 long was to simply convert it to ascii;

     

        std::string inputbuffer="";
        for( int i=0; i < 256; i++ ){
    	    if (window->keyhitstate[i]){
                   [size=3]inputbuffer[/size]+=static_cast<char>(i);
    	    }
        }
        window->FlushKeys();
    

     

    However that gets me all keys as uppercase and f1-12 as lower case letters - and even if it worked there is a very high risk of getting inputs out of order

     

    I worry that reading the keys manually will either prevent leadwerks input from working or yield no results as leadwerks already emptied the keyboard buffer.

  5. Spent all morning figuring this one out and distilling it to it's very essence;

     

    if you do

     

    Leadwerks::Window::GetCurrent()->GetMousePosition();

     

    inside app::start

     

    the world will fall though you - or more specific; CSG boxes wont get drawn and barrels, etc will start falling while the FPS controller just hangs there.

     

     

    Reason I'm trying to do the above is to have my gui class as encapsulated and easy to use as possible - so rather than requiring the user to pass a valid window instance it just grabs the current if none are specified.

     

    I've several workaround ( like initializing on first draw call, etc ) but I don't understand why it's happing this way, I mean there should be no difference between calling through one pointer or another.

  6. I don't think loading libs for a sandboxed game is possible and I think that's what the leadwerks game player can only use and that's the easiest way to get people to check the game out. That rules out custom C++ build too as the game player seems to run it's own exe. It would be nice to have this built into the editor like DerRidda says. Even if it's not the most secure it'll be something.

     

    That same would be true of gui's - unless you fancy writing a complete gui manager in lua you will be using an external lib.

     

    But it may be a moot point as I just noticed that there was no .so emitted from my build, instead I got;

     

    /usr/bin/ld: /home/morten/.local/share/Steam/SteamApps/common/Leadwerks/Library/Linux/Debug/Leadwerks.a(Package.o): relocation R_X86_64_32S against `_ZTVN9Leadwerks7PackageE' can not be used when making a shared object; recompile with -fPIC
    /home/morten/.local/share/Steam/SteamApps/common/Leadwerks/Library/Linux/Debug/Leadwerks.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    

     

    had hoped that I could depend on getting the symbols from the executable running the lua instance, seems not :(

  7. It should be possible to create a lua lib that that can do the above for you

     

    [/size]
    require("libLua-cryptloader")
    cryptloader:LoadDir("Data/","password");
    

     

    ofcourse you'd need to obfuscate the password a bit wink.png

     

    Managed to write and build a shared lib to do just this before I remebered that the linux version cannot load it yet and I've no way of compiling it on windows... oh well later ^^

  8. It should be possible to create a lua lib that that can do the above for you

     

    [/size]
    require("libLua-cryptloader")
    cryptloader:LoadDir("Data/","password");
    

     

    ofcourse you'd need to obfuscate the password a bit ;)

    • Upvote 2
  9. I've been usingLeadwerks::Texture::RGB and Leadwerks::Texture::RGBATo pass to

    Leadwerks::Texture::Create(_width,_height,LEformat)

    But I also need to create textures with one color channel and one Llumiance channel + alpha (GL_LUMINANCE8_ALPHA8) - I've been using Leadwerks::Texture::Intensity16 for this which gets me the correct buffer size but when I bind the texture it just shows as black. So what should I use instead?

×
×
  • Create New...