Jump to content

Paul

Members
  • Posts

    83
  • Joined

  • Last visited

Posts posted by Paul

  1. True you can't return typed structures from procedures, but you can return the pointer though there is no type safety then.

     

    Procedure.i GetThingMatrix (*athing.TThing , atry.l)
    Protected result.TVec16
    
    leGetThingMatrix(*athing, atry, result)
    ProcedureReturn result
    EndProcedure
    

     

    I really have no intention myself of using Leadwerks with PureBasic, as you can see PureBasic is too limited when dealing with 3rd party libraries. I'm doing this if anyone else wants to use PureBasic, though there really doesn't appear to be much interest.

  2. I have uploaded the new header generator.

    I did not prefix the constants with LE like Josh suggested because i'm not sure you want it.

    If Purebasic #KEY_ESCAPE already exists then the value is probably also 27 so we could perhaps just comment it out ?

    Never mind turns out PureBasic doesn't use them. I forgot to prefix the #.

     

    Unlike C++ header and Pascal Header i don't generate "function wrappers" in purebasic because i don't know how to. From what i have read in the manual Purebasic cannot return a structure as the result of a function, so this was a showstopper for me.
    Which version of the manual you have? 4.40 returns them fine.

     

    Anyway, functions are not so interresting (except if you want to traduce easily C++ code that uses them) because procedure performance is better.

    With a procedure returning 1 result, you can use your variable n times after. But with a function you could be tempted to test n times the result of the function wich is slower. And even if you affect the function to a variable, you are still slower because the function creates a temporary variable to transmit the result while a procedure can do it directly.

    Sorry? A procedure is PureBasic's version of a function.
  3. Basically to get it working I've added these macros and functions.

    To make Initialize and Terminate consistent with the rest of the Leadwerks functions they are too prefixed with Le.

    Procedure lePrint(string.s)
    Static con=#False
    
    If con=#False
    	con=OpenConsole()
    EndIf
    
    If con
    	PrintN(string)
    EndIf
    EndProcedure
    
    
    Procedure ExitFunc(lib.i,f.s)
    lePrint("ERROR: unable to find DLL function: "+f)
    CloseLibrary(lib)
    lePrint("PRESS ENTER TO EXIT.")
    Input()
    EndProcedure
    
    
    
    Global le_lib.i=#Null
    
    
    Macro DoubleQuote
    "
    EndMacro
    
    Macro _leInitFunc(a)
    Global Le#a#.LE#a=GetFunction(le_lib,DoubleQuote#a#DoubleQuote)
    If Le#a=#Null
    	ExitFunc(le_lib,DoubleQuote#a#DoubleQuote)
    	ProcedureReturn 0
    EndIf
    EndMacro
    
    Macro _leInitAllFuncs()
    _leInitFunc(RegisterAbstractPath);
    _leInitFunc(AbstractPath);
    _leInitFunc(Graphics);
    ... and so on...
    EndMacro
    
    Macro _leInitialize(le_dll)
    le_lib=OpenLibrary(#PB_Any,le_dll)
    If le_lib
    	_leInitAllFuncs()
    Else
    	lePrint(le_dll+" can't be loaded.")
    EndIf
    EndMacro
    
    Procedure.l LeInitialize(allowenginedebug.l=1)
    Protected dllfilename.s
    
    If allowenginedebug=1
    	CompilerIf #PB_Compiler_Debugger=1 
    		dllfilename="engine.debug.dll"
    	CompilerElse
    		dllfilename="engine.dll"
    	CompilerEndIf
    Else
    	If allowenginedebug=2
    		dllfilename="engine.debug.dll"
    	Else
    		dllfilename="engine.dll"
    	EndIf
    EndIf
    _leInitialize(dllfilename)
    
    ProcedureReturn (#Null<>le_lib)
    EndProcedure
    
    Procedure LeTerminate()
    LeEndRender()
    CloseLibrary(le_lib)
    le_lib=#Null
    EndProcedure
    

     

    If you do want the commands with their original names (no Le in front). I've made a list of macros that follow like this:

    Macro RegisterAbstractPath : LeRegisterAbstractPath : EndMacro
    Macro AbstractPath : LeAbstractPath : EndMacro
    Macro Graphics : LeGraphics : EndMacro
    ...
    

    However the must appear after the LeInitialize() function.

  4. Ok, I've done abit of work on the generated header. It works like the c header using macros to load the functions, a better way would be making a proper PureBasic lib (which I wont attempt just yet).

     

    I have managed to get a simpe example working

    If Initialize()
    SetAppTitle("Hello World (window title)")
    Graphics(640,480)
    CreateWorld()
    Repeat
    	DrawText("Hello World!",32,32)
    	UpdateWorld()
    	Flip()
    Until keyHit(27) Or AppTerminate()
    Terminate()
    EndIf	
    

    However I've had to use alot of macro trickery to replace some of PureBasic's own commands as there seems to be no way to exclude libraries.

    Also some constants are ignored by PureBasic because they conflict with its own of the same name, thats why I'm using 27 instead of #KEY_ESCAPE.

  5. Is there a way to make vegetation layers via code?

    For example terrain can be created and modified with the terrain commands, do any vegetation commands exist? I could only find SetVegetationShadowMode().

  6. In C++ it's '();' to call a function, and '=;' to define a variable. Sure, they are a bit shorter, but someone who has never programmed would not know what they mean.

    '=' assigns the variable a value.

    If they choose this preprocessor mess to program in they should never be allowed to program.

  7. Is this being shown in the leadwerks engine? Did you get L3DT or Leadwerks editor to place the textures?

     

    I usually make something in L3DT, export the heightmap to Leadwerks editor and use the terrain paint settings to automatically place the textures. I end up with some stripey or splotchy mess, and the textures don't blend in well together.

  8. Can anyone suggest terrain editing software and textures?

    Currently I'm using L3DT standard but having difficulty making the terrain how I want it.

    I also need some suggestions on textures, I'm using the ones that came with the leadwerks engine and the texture pack but on my terrain they look an eyesore; I can't get my terrain to look natural like the ones in the Gallery.

  9. It works only in Release mode, in Debug mode I get also the error, and the camera entity is sometimes NULL and sometimes some lower value than the real camera value.

    Seems rather like a bug in Visual Studio C++ to me, since how can something work in Release but not in Debug?

    I'll try to find a hack which makes it work in Debug mode also.

    More than likely Debug mode is catching problem that is going unnoticed in Release mode.
×
×
  • Create New...