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 ));
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if(( m_WindowSize->Width != m_Driver->getScreenSize().Width ) || ( m_WindowSize->Height != m_Driver->getScreenSize().Height ))
|
||||
@ -131,10 +123,7 @@ Engine::Engine()
|
||||
|
||||
// Set Engine enabled
|
||||
m_RunEngine = true;
|
||||
|
||||
// Load test model
|
||||
m_LoadedMesh = 0;
|
||||
loadMesh( L"test.b3d" );
|
||||
|
||||
// Store actual window size
|
||||
m_WindowSize = new dimension2d<u32>();
|
||||
@ -148,6 +137,14 @@ Engine::~Engine()
|
||||
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()
|
||||
{
|
||||
u32 timePerFrame = ( u32 ) ( 1000.0f / 60 );
|
||||
|
2
Engine.h
2
Engine.h
@ -56,13 +56,13 @@ private:
|
||||
void drawBackground();
|
||||
void checkResize();
|
||||
IGUIEnvironment *getGUIEnvironment() const;
|
||||
void loadMesh( const wstring &fileName );
|
||||
|
||||
public:
|
||||
Engine();
|
||||
~Engine();
|
||||
|
||||
void run();
|
||||
void loadMesh( const wstring &fileName );
|
||||
};
|
||||
|
||||
#endif // ENGINE_H
|
||||
|
@ -3,14 +3,15 @@
|
||||
// PRIVATE
|
||||
void UserInterface::setupUserInterface()
|
||||
{
|
||||
// Menu
|
||||
IGUIContextMenu *menu = m_Gui->addMenu();
|
||||
menu->addItem( L"File", UIE_FILEMENU, true, true );
|
||||
|
||||
// File Menu
|
||||
IGUIContextMenu *fileMenu = menu->getSubMenu( 0 );
|
||||
fileMenu->addItem( L"Load", UIC_FILE_LOAD );
|
||||
fileMenu->addItem( L"Quit", UIC_FILE_QUIT );
|
||||
|
||||
|
||||
// Set Font for UI Elements
|
||||
m_GuiFont = m_Gui->getFont( "arial.xml" );
|
||||
m_Gui->getSkin()->setFont( m_GuiFont );
|
||||
|
1
View.cpp
1
View.cpp
@ -52,6 +52,7 @@ View::~View()
|
||||
// IEventReceiver
|
||||
bool View::OnEvent( const SEvent &event )
|
||||
{
|
||||
// If it's not a mouse event, just return unhandled
|
||||
if( event.EventType != EET_MOUSE_INPUT_EVENT )
|
||||
return false;
|
||||
|
||||
|
48
main.cpp
48
main.cpp
@ -1,5 +1,11 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Engine.h"
|
||||
|
||||
wchar_t * getWideCharString( char *str );
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
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 )
|
||||
#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();
|
||||
if( argc >= 2 )
|
||||
{
|
||||
wchar_t *initialFileName = getWideCharString( argv[1] );
|
||||
engine->loadMesh( wstring( initialFileName ));
|
||||
free( initialFileName );
|
||||
}
|
||||
else
|
||||
engine->loadMesh( L"test.b3d" );
|
||||
|
||||
engine->run();
|
||||
|
||||
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>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<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>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@ -72,16 +72,17 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<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>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>D:\Prj\irrlicht-1.7.1\lib\Win32-visualstudio;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>Irrlicht.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EntryPointSymbol>WinMain</EntryPointSymbol>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user