mirror of
https://github.com/Poikilos/b3view.git
synced 2023-10-03 07:58:48 -07:00
Command line loading
This commit is contained in:
parent
f831ae2bd9
commit
51ae518d77
19
Engine.cpp
19
Engine.cpp
@ -72,14 +72,6 @@ void Engine::drawBackground()
|
|||||||
SColor( 255, 224, 224, 255 ));
|
SColor( 255, 224, 224, 255 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::loadMesh( const wstring &fileName )
|
|
||||||
{
|
|
||||||
if( m_LoadedMesh != 0 )
|
|
||||||
m_LoadedMesh->remove();
|
|
||||||
|
|
||||||
m_LoadedMesh = m_Scene->addAnimatedMeshSceneNode( m_Scene->getMesh( fileName.c_str() ));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::checkResize()
|
void Engine::checkResize()
|
||||||
{
|
{
|
||||||
if(( m_WindowSize->Width != m_Driver->getScreenSize().Width ) || ( m_WindowSize->Height != m_Driver->getScreenSize().Height ))
|
if(( m_WindowSize->Width != m_Driver->getScreenSize().Width ) || ( m_WindowSize->Height != m_Driver->getScreenSize().Height ))
|
||||||
@ -131,10 +123,7 @@ Engine::Engine()
|
|||||||
|
|
||||||
// Set Engine enabled
|
// Set Engine enabled
|
||||||
m_RunEngine = true;
|
m_RunEngine = true;
|
||||||
|
|
||||||
// Load test model
|
|
||||||
m_LoadedMesh = 0;
|
m_LoadedMesh = 0;
|
||||||
loadMesh( L"test.b3d" );
|
|
||||||
|
|
||||||
// Store actual window size
|
// Store actual window size
|
||||||
m_WindowSize = new dimension2d<u32>();
|
m_WindowSize = new dimension2d<u32>();
|
||||||
@ -148,6 +137,14 @@ Engine::~Engine()
|
|||||||
delete m_WindowSize;
|
delete m_WindowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::loadMesh( const wstring &fileName )
|
||||||
|
{
|
||||||
|
if( m_LoadedMesh != 0 )
|
||||||
|
m_LoadedMesh->remove();
|
||||||
|
|
||||||
|
m_LoadedMesh = m_Scene->addAnimatedMeshSceneNode( m_Scene->getMesh( fileName.c_str() ));
|
||||||
|
}
|
||||||
|
|
||||||
void Engine::run()
|
void Engine::run()
|
||||||
{
|
{
|
||||||
u32 timePerFrame = ( u32 ) ( 1000.0f / 60 );
|
u32 timePerFrame = ( u32 ) ( 1000.0f / 60 );
|
||||||
|
6
Engine.h
6
Engine.h
@ -55,14 +55,14 @@ private:
|
|||||||
void drawAxisLines();
|
void drawAxisLines();
|
||||||
void drawBackground();
|
void drawBackground();
|
||||||
void checkResize();
|
void checkResize();
|
||||||
IGUIEnvironment *getGUIEnvironment() const;
|
IGUIEnvironment *getGUIEnvironment() const;
|
||||||
void loadMesh( const wstring &fileName );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
~Engine();
|
~Engine();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
void loadMesh( const wstring &fileName );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENGINE_H
|
#endif // ENGINE_H
|
||||||
|
@ -3,14 +3,15 @@
|
|||||||
// PRIVATE
|
// PRIVATE
|
||||||
void UserInterface::setupUserInterface()
|
void UserInterface::setupUserInterface()
|
||||||
{
|
{
|
||||||
|
// Menu
|
||||||
IGUIContextMenu *menu = m_Gui->addMenu();
|
IGUIContextMenu *menu = m_Gui->addMenu();
|
||||||
menu->addItem( L"File", UIE_FILEMENU, true, true );
|
menu->addItem( L"File", UIE_FILEMENU, true, true );
|
||||||
|
|
||||||
|
// File Menu
|
||||||
IGUIContextMenu *fileMenu = menu->getSubMenu( 0 );
|
IGUIContextMenu *fileMenu = menu->getSubMenu( 0 );
|
||||||
fileMenu->addItem( L"Load", UIC_FILE_LOAD );
|
fileMenu->addItem( L"Load", UIC_FILE_LOAD );
|
||||||
fileMenu->addItem( L"Quit", UIC_FILE_QUIT );
|
fileMenu->addItem( L"Quit", UIC_FILE_QUIT );
|
||||||
|
|
||||||
|
|
||||||
// Set Font for UI Elements
|
// Set Font for UI Elements
|
||||||
m_GuiFont = m_Gui->getFont( "arial.xml" );
|
m_GuiFont = m_Gui->getFont( "arial.xml" );
|
||||||
m_Gui->getSkin()->setFont( m_GuiFont );
|
m_Gui->getSkin()->setFont( m_GuiFont );
|
||||||
|
1
View.cpp
1
View.cpp
@ -52,6 +52,7 @@ View::~View()
|
|||||||
// IEventReceiver
|
// IEventReceiver
|
||||||
bool View::OnEvent( const SEvent &event )
|
bool View::OnEvent( const SEvent &event )
|
||||||
{
|
{
|
||||||
|
// If it's not a mouse event, just return unhandled
|
||||||
if( event.EventType != EET_MOUSE_INPUT_EVENT )
|
if( event.EventType != EET_MOUSE_INPUT_EVENT )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
48
main.cpp
48
main.cpp
@ -1,5 +1,11 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "Engine.h"
|
#include "Engine.h"
|
||||||
|
|
||||||
|
wchar_t * getWideCharString( char *str );
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
|
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
|
||||||
@ -7,9 +13,51 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
|
|||||||
int main( int argc, char **argv )
|
int main( int argc, char **argv )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
// Parse commandline to check if a filename argument has been passed
|
||||||
|
#ifdef WIN32
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
|
||||||
|
LPWSTR *args;
|
||||||
|
args = CommandLineToArgvW( GetCommandLineW(), &argc );
|
||||||
|
|
||||||
|
argv = ( char ** ) malloc( sizeof( char * ) * argc );
|
||||||
|
for( int index = 0; index < argc; index ++ )
|
||||||
|
{
|
||||||
|
int argumentBufferLength = wcslen( args[index] ) + 1;
|
||||||
|
argv[index] = ( char * ) malloc( sizeof( char ) * argumentBufferLength );
|
||||||
|
sprintf_s( argv[index], argumentBufferLength, "%ws", args[index] );
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalFree( args );
|
||||||
|
#endif
|
||||||
|
|
||||||
Engine *engine = new Engine();
|
Engine *engine = new Engine();
|
||||||
|
if( argc >= 2 )
|
||||||
|
{
|
||||||
|
wchar_t *initialFileName = getWideCharString( argv[1] );
|
||||||
|
engine->loadMesh( wstring( initialFileName ));
|
||||||
|
free( initialFileName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
engine->loadMesh( L"test.b3d" );
|
||||||
|
|
||||||
engine->run();
|
engine->run();
|
||||||
|
|
||||||
delete engine;
|
delete engine;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
for( int index = 0; index < argc; index ++ )
|
||||||
|
free( argv[index] );
|
||||||
|
free( argv );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
wchar_t * getWideCharString( char *str )
|
||||||
|
{
|
||||||
|
wchar_t *dest = ( wchar_t * ) malloc( sizeof( wchar_t ) * ( strlen( str ) + 1 ));
|
||||||
|
mbstowcs( dest, str, strlen( str ));
|
||||||
|
|
||||||
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
win32/b3view.suo
BIN
win32/b3view.suo
Binary file not shown.
@ -54,7 +54,7 @@
|
|||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>D:\Prj\irrlicht-1.7.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>D:\Prj\irrlicht-1.7.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
@ -72,16 +72,17 @@
|
|||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>D:\Prj\irrlicht-1.7.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>D:\Prj\irrlicht-1.7.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalLibraryDirectories>D:\Prj\irrlicht-1.7.1\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\Prj\irrlicht-1.7.1\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>Irrlicht.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>Irrlicht.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<EntryPointSymbol>WinMain</EntryPointSymbol>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user