Jump to content

Problem with Framework and LEO


ArBuZ
 Share

Recommended Posts

Hi! Ive tried to use framework directly that included in dll. Here is the simple code. When I try to move any camera of any layer the program gives an error.

 

//	====================================================================
//	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
//	Written by Rimfrost Software
//	http://www.rimfrost.com 
//	====================================================================

#include "leo.h"
using namespace LEO ;

int WINAPI WinMain( HINSTANCE hInstance,
				HINSTANCE hPrevInstance,
				LPSTR lpCmdLine,
				int nShowCmd ) 
{
Engine engine( "Gma", 1024, 768) ;
Engine::SetAbstractPath( "C:/Gma/Gma" ) ;
Engine::SetFilters() ;


Framework fw;
fw.Create();

fw.renderer.SetBloom(false);
fw.renderer.SetHDR(false);

//THIS CAUSE ERROR!
fw.main.GetCamera().SetPosition(Vec3(0,0,-5));


Material material("abstract::cobblestones.mat") ;
Cube	 mesh( CREATENOW ) ;
mesh.Paint( material ) ;

Cube ground( CREATENOW ) ;
ground.SetScale( 10, 1, 10 );
ground.SetPosition( 0, -2, 0 );
ground.Paint( material ) ;

DirectionalLight light( CREATENOW ) ;
light.SetRotation( 45 , 45, 45 );

// Game loop
while( !Keyboard::I****() && !Engine::IsTerminated() )
{
	if( !Engine::IsSuspended() ) // We are not in focus!
	{
		// Rotate cube
		mesh.Turn( Vec3( 0.5f*AppSpeed() ) ) ;


		fw.Update();
		fw.Render();

		Engine::Flip(0) ;
	}
}

// Done
return engine.Free() ;
}

 

But if I use API (not LEO) everything goes well:

//	====================================================================
//	This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard
//	Written by Rimfrost Software
//	http://www.rimfrost.com 
//	====================================================================

#include "leo.h"
using namespace LEO ;

int WINAPI WinMain( HINSTANCE hInstance,
				HINSTANCE hPrevInstance,
				LPSTR lpCmdLine,
				int nShowCmd ) 
{
Engine engine( "Gma", 1024, 768) ;
Engine::SetAbstractPath( "C:/Gma/Gma" ) ;
Engine::SetFilters() ;


Framework fw;
fw.Create();

fw.renderer.SetBloom(false);
fw.renderer.SetHDR(false);

//THIS CAUSES ERROR!
//fw.main.GetCamera().SetPosition(Vec3(0,0,-5));

       //THIS WORKS!!!!
PositionEntity(GetLayerCamera(fw.main),Vec3(0, 0, -3.5));


Material material("abstract::cobblestones.mat") ;
Cube	 mesh( CREATENOW ) ;
mesh.Paint( material ) ;

Cube ground( CREATENOW ) ;
ground.SetScale( 10, 1, 10 );
ground.SetPosition( 0, -2, 0 );
ground.Paint( material ) ;

DirectionalLight light( CREATENOW ) ;
light.SetRotation( 45 , 45, 45 );

// Game loop
while( !Keyboard::I****() && !Engine::IsTerminated() )
{
	if( !Engine::IsSuspended() ) // We are not in focus!
	{
		// Rotate cube
		mesh.Turn( Vec3( 0.5f*AppSpeed() ) ) ;


		fw.Update();
		fw.Render();

		Engine::Flip(0) ;
	}
}

// Done
return engine.Free() ;
}

 

This works too

Camera cam=GetLayerCamera(fw.main);
cam.SetPosition( 0, 0, -3.5 );

 

But this doesnt:

Camera cam=fw.main.GetCamera();
cam.SetPosition(0,0,-5);

 

 

Maybe Im doing somethig wrong. Sorry if this problem is allready discribed on the forum.

Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

OK, I found a hack for leoLayer.h which makes it work in Debug mode also. Just need Josh to update it. The good thing is, it makes GetWorld() and GetCamera() functions a bit faster too, since they use now a pointer instead of calling framework functions each time.

 

It allows also more LUA/BlitzMax style coding now, since you can say now:

fw.main.camera.SetPosition(0,0,-5);

and of course the strict OOP syntax works also:

fw.GetMain().GetCamera().SetPosition(Vec3(0,0,-5));

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Intel Core i7 975 @ 3.33GHz, 6GB ram, GTX 560 Super OC, Windows 7 Pro 64bit

Link to comment
Share on other sites

Thank you Lumooja.

Ive noticed also that sometimes entity of any class in LEO becomes NULL or badptr in some cases. I cant remeber now how did that happen. But I had to use API instead of LEO.

 

And by the way

fw.GetMain()

is absent in dll framework.

 

And everything works if I use framewerk.cpp (not DLL). I think that something wrong with LEO.

Q6600@2.4GHz - 9600GT - 4GB DDR2@800MHz - Windows7 x64

3ds max / photoshop CS3 / C++

http://www.arbuznikov.com

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...