Jump to content

Leadwerks faster in BlitzMax than C++


Cole Chapman
 Share

Recommended Posts

Very attention grabbing title. This is either a confirmation that the code is not accurate or its a confirmation that the title is correct (though that goes against what I know). Code is below. If anyone needs, I can upload both that includes the exes.

 

C++ File: 628 KB - Average FPS: 300 (Made with Dev C++)

//	====================================================================
//	This file was generated by LEBuilder
//	http://leadwerks.com/werkspace
//	====================================================================

#include "engine.h"
#include <iostream>
#include <string>

const int 	ScreenWidth = 800;
const int 	ScreenHeight = 600;
const char* MediaDir =  "C:/Leadwerks Engine SDK";
const char* AppTitle = "Leadwerks";

void ErrOut( const std::string& message ) { std::cerr << message << std::endl; }

//	-------------------------------
int main( int argn, char* argv[] )
{
// Initialize
if( !Initialize() )
	return 1;        
SetAppTitle( AppTitle ) ;
RegisterAbstractPath( MediaDir ); 

// Set graphics mode        
if( !Graphics(ScreenWidth,ScreenHeight) )
{                
	ErrOut( "Failed to set graphics mode."  );
	return 1;        
}

// Create framework object and set it to a global object so other scripts can access it
TFramework fw = CreateFramework();        
if( fw == NULL )        
{
	ErrOut( "Failed to initialize engine." );                
	return 1;        
}        

// Set Lua framework object        
SetGlobalObject( "fw", fw );                

// Set Lua framework variable        
BP lua = GetLuaState();        
lua_pushobject( lua, fw );        
lua_setglobal( lua, "fw" );        
lua_pop( lua, 1 );        

// Get framework main camera        
TCamera camera = GetLayerCamera( GetFrameworkLayer(0) );        
PositionEntity( camera, Vec3(0,0,-2) );        

// Create cube
TMaterial material = LoadMaterial( "C:/Leadwerks Engine SDK/Materials/Cobblestones/cobblestones.mat" );        
TMesh mesh = CreateCube();        
PaintEntity( mesh, material );        

// Create ground
TMesh ground = CreateCube();        
ScaleEntity( ground, Vec3(10,1,10) );        
PositionEntity( ground, Vec3(0,-2,0) );        
PaintEntity( ground, material );        

// Add some light
TLight light = CreateDirectionalLight();        
RotateEntity( light, Vec3(45,45,45) );        

// Spin cube until user hits Escape
while( !KeyHit() && !AppTerminate() )        
{                
	if( !AppSuspended() )
	{
		TurnEntity( mesh, Vec3( AppSpeed()*0.5f ) );     

		UpdateFramework();                
		RenderFramework();                

		Flip( 0 );        
	}
}                

return Terminate();
}

 

 

 

BlitzMax File: 2,141 KB - Average FPS: 465 (Made with BlitzMax...)

'       ====================================================================
'       This file was generated by LEBuilder
'       http://www.leadwerks.com/werkspace 
'       ====================================================================

SuperStrict

Framework leadwerks.ENGINE

Local world:TWorld
Local gbuffer:TBuffer
Local camera:TCamera
Local mesh:TMesh
Local light:TLight
Local ground:TMesh
Local material:TMaterial

GCSetMode(2)

RegisterAbstractPath( "C:/Leadwerks Engine SDK" ) 

Graphics(800,600)

world=CreateWorld()
If Not world RuntimeError "Failed to create world."

gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_DEPTH|BUFFER_COLOR0|BUFFER_COLOR1|BUFFER_COLOR2)

camera=CreateCamera()
PositionEntity camera,[0.0,0.0,-2.0]

material=LoadMaterial("abstract::cobblestones.mat")

mesh=CreateCube()
PaintEntity mesh,material

ground=CreateCube()
ScaleEntity ground,[10.0,1.0,10.0]
PositionEntity ground,[0.0,-2.0,0.0]
PaintEntity ground,material

light=CreateDirectionalLight()

RotateEntity light,[45.0,45.0,45.0]

Repeat
GCCollect()

TurnEntity mesh,[AppSpeed()*0.5,AppSpeed()*0.5,AppSpeed()*0.5]

If KeyHit(KEY_ESCAPE) Exit
If AppTerminate() Exit

UpdateAppTime()
UpdateWorld(AppSpeed())

SetBuffer(gbuffer)
RenderWorld()
SetBuffer(BackBuffer())
RenderLights(gbuffer)

SetBlend(1)
DrawText(UPS(), 0, 0)
SetBlend(0)

Flip(0)

Forever

gbuffer=Null
FreeEntity light
GCCollect()
End

 

Some flaw in the code maybe?

Link to comment
Share on other sites

In the BMX code you are just rendering to a simple gbuffer. The C++ code is using the Framework object, which has a lot more effects and uses HDR by default.

My job is to make tools you love, with the features you want, and performance you can't live without.

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...