mirror of https://github.com/Poikilos/b3view
improved window resize handling and various bugs
parent
51ae518d77
commit
1b8831cbc9
26
B3View.pro
26
B3View.pro
|
@ -17,24 +17,10 @@ HEADERS += Engine.h \
|
|||
CONFIG += warn_off
|
||||
|
||||
# Irrlicht
|
||||
# it's tailored to use svn on linux, and the stable build on windows
|
||||
unix {
|
||||
IRRLICHTBASE = /home/er/tmp/irrlicht/trunk
|
||||
}
|
||||
win32 {
|
||||
IRRLICHTBASE = d:/libs/irrlicht-1.7.1
|
||||
}
|
||||
IRRLICHTBASE = /home/er/tmp/irrlicht/trunk
|
||||
INCLUDEPATH += $$IRRLICHTBASE/include
|
||||
|
||||
unix {
|
||||
LIBS += -L$$IRRLICHTBASE/source/Irrlicht \
|
||||
-lIrrlicht \
|
||||
-lX11 \
|
||||
-lGL \
|
||||
-lXxf86vm
|
||||
}
|
||||
|
||||
win32 {
|
||||
LIBS += -L$$IRRLICHTBASE/lib/Win32-gcc \
|
||||
-lIrrlicht
|
||||
}
|
||||
LIBS += -L$$IRRLICHTBASE/source/Irrlicht \
|
||||
-lIrrlicht \
|
||||
-lX11 \
|
||||
-lGL \
|
||||
-lXxf86vm
|
||||
|
|
27
Engine.cpp
27
Engine.cpp
|
@ -79,12 +79,30 @@ void Engine::checkResize()
|
|||
m_WindowSize->Width = m_Driver->getScreenSize().Width;
|
||||
m_WindowSize->Height = m_Driver->getScreenSize().Height;
|
||||
|
||||
f32 aspectRatio = (f32) m_WindowSize->Width / m_WindowSize->Height;
|
||||
debug() << "Setting aspect to: " << aspectRatio << endl;
|
||||
m_Scene->getActiveCamera()->setAspectRatio( aspectRatio );
|
||||
// Send custom event
|
||||
IEventReceiver *eventReceiver = m_Device->getEventReceiver();
|
||||
|
||||
SEvent event;
|
||||
event.EventType = EET_USER_EVENT;
|
||||
event.UserEvent.UserData1 = UEI_WINDOWSIZECHANGED;
|
||||
|
||||
eventReceiver->OnEvent( event );
|
||||
}
|
||||
}
|
||||
|
||||
s32 Engine::getNumberOfVertices()
|
||||
{
|
||||
IMesh *mesh = m_LoadedMesh->getMesh()->getMesh( 0, 255, -1, -1 );
|
||||
|
||||
int vertices = 0;
|
||||
for( int bufferIndex = 0; bufferIndex < mesh->getMeshBufferCount(); bufferIndex ++ )
|
||||
vertices += mesh->getMeshBuffer( bufferIndex )->getVertexCount();
|
||||
|
||||
cout << vertices << endl;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
/* //////////////////////////////////////////////////////////////////////////
|
||||
PUBLIC METHODS
|
||||
/////////////////////////////////////////////////////////////////////// */
|
||||
|
@ -143,6 +161,7 @@ void Engine::loadMesh( const wstring &fileName )
|
|||
m_LoadedMesh->remove();
|
||||
|
||||
m_LoadedMesh = m_Scene->addAnimatedMeshSceneNode( m_Scene->getMesh( fileName.c_str() ));
|
||||
Utility::dumpMeshInfoToConsole( m_LoadedMesh );
|
||||
}
|
||||
|
||||
void Engine::run()
|
||||
|
@ -161,7 +180,9 @@ void Engine::run()
|
|||
drawBackground(); // Draw Background
|
||||
drawAxisLines(); // Draw XYZ Axis
|
||||
m_Scene->drawAll(); // Draw Scenegraph
|
||||
|
||||
m_UserInterface->getGUIEnvironment()->drawAll();
|
||||
m_UserInterface->drawStatusLine();
|
||||
|
||||
m_Driver->endScene();
|
||||
|
||||
|
|
1
Engine.h
1
Engine.h
|
@ -56,6 +56,7 @@ private:
|
|||
void drawBackground();
|
||||
void checkResize();
|
||||
IGUIEnvironment *getGUIEnvironment() const;
|
||||
s32 getNumberOfVertices();
|
||||
|
||||
public:
|
||||
Engine();
|
||||
|
|
|
@ -33,5 +33,13 @@ bool EventHandler::OnEvent( const SEvent &event )
|
|||
iter->second->OnEvent( event );
|
||||
}
|
||||
|
||||
// Window resize handling - send to all subscribers
|
||||
if( event.EventType == EET_USER_EVENT && event.UserEvent.UserData1 == UEI_WINDOWSIZECHANGED )
|
||||
{
|
||||
map<EventReceiverType,IEventReceiver *>::iterator iter;
|
||||
for( iter = m_EventReceivers->begin(); iter != m_EventReceivers->end(); iter ++ )
|
||||
iter->second->OnEvent( event );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,11 @@ enum EventReceiverType
|
|||
ERT_3DVIEW = 2
|
||||
};
|
||||
|
||||
enum UserEventIdentifier
|
||||
{
|
||||
UEI_WINDOWSIZECHANGED = 1
|
||||
};
|
||||
|
||||
class EventHandler : public IEventReceiver
|
||||
{
|
||||
private:
|
||||
|
|
356
Makefile
356
Makefile
|
@ -1,125 +1,231 @@
|
|||
#############################################################################
|
||||
# Makefile for building: B3View
|
||||
# Generated by qmake (2.01a) (Qt 4.6.0) on: Mi 21. Apr 16:30:29 2010
|
||||
# Project: B3View.pro
|
||||
# Template: app
|
||||
# Command: c:\qt\2009.05\qt\bin\qmake.exe -spec c:\Qt\2009.05\qt\mkspecs\win32-g++ -win32 -o Makefile B3View.pro
|
||||
#############################################################################
|
||||
|
||||
first: debug
|
||||
install: debug-install
|
||||
uninstall: debug-uninstall
|
||||
MAKEFILE = Makefile
|
||||
QMAKE = c:\qt\2009.05\qt\bin\qmake.exe
|
||||
DEL_FILE = del
|
||||
CHK_DIR_EXISTS= if not exist
|
||||
MKDIR = mkdir
|
||||
COPY = copy /y
|
||||
COPY_FILE = $(COPY)
|
||||
COPY_DIR = xcopy /s /q /y /i
|
||||
INSTALL_FILE = $(COPY_FILE)
|
||||
INSTALL_PROGRAM = $(COPY_FILE)
|
||||
INSTALL_DIR = $(COPY_DIR)
|
||||
DEL_FILE = del
|
||||
SYMLINK =
|
||||
DEL_DIR = rmdir
|
||||
MOVE = move
|
||||
CHK_DIR_EXISTS= if not exist
|
||||
MKDIR = mkdir
|
||||
SUBTARGETS = \
|
||||
debug \
|
||||
release
|
||||
|
||||
debug: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug
|
||||
debug-make_default: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug
|
||||
debug-make_first: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug first
|
||||
debug-all: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug all
|
||||
debug-clean: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug clean
|
||||
debug-distclean: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug distclean
|
||||
debug-install: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug install
|
||||
debug-uninstall: $(MAKEFILE).Debug FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Debug uninstall
|
||||
release: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release
|
||||
release-make_default: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release
|
||||
release-make_first: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release first
|
||||
release-all: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release all
|
||||
release-clean: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release clean
|
||||
release-distclean: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release distclean
|
||||
release-install: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release install
|
||||
release-uninstall: $(MAKEFILE).Release FORCE
|
||||
$(MAKE) -f $(MAKEFILE).Release uninstall
|
||||
|
||||
Makefile: B3View.pro c:/Qt/2009.05/qt/mkspecs/win32-g++/qmake.conf c:/Qt/2009.05/qt/mkspecs/qconfig.pri \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/qt_functions.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/qt_config.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/exclusive_builds.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/default_pre.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/default_pre.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/debug.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/debug_and_release.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/default_post.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/default_post.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/warn_off.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/rtti.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/exceptions.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/stl.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/shared.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/windows.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/win32/thread_off.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/resources.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/uic.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/yacc.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/lex.prf \
|
||||
c:/Qt/2009.05/qt/mkspecs/features/include_source_dir.prf
|
||||
$(QMAKE) -spec c:\Qt\2009.05\qt\mkspecs\win32-g++ -win32 -o Makefile B3View.pro
|
||||
c:\Qt\2009.05\qt\mkspecs\qconfig.pri:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\qt_functions.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\qt_config.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\exclusive_builds.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\default_pre.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\default_pre.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\debug.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\debug_and_release.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\default_post.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\default_post.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\warn_off.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\rtti.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\exceptions.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\stl.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\shared.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\windows.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\win32\thread_off.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\resources.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\uic.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\yacc.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\lex.prf:
|
||||
c:\Qt\2009.05\qt\mkspecs\features\include_source_dir.prf:
|
||||
qmake: qmake_all FORCE
|
||||
@$(QMAKE) -spec c:\Qt\2009.05\qt\mkspecs\win32-g++ -win32 -o Makefile B3View.pro
|
||||
|
||||
qmake_all: FORCE
|
||||
|
||||
make_default: debug-make_default release-make_default FORCE
|
||||
make_first: debug-make_first release-make_first FORCE
|
||||
all: debug-all release-all FORCE
|
||||
clean: debug-clean release-clean FORCE
|
||||
distclean: debug-distclean release-distclean FORCE
|
||||
-$(DEL_FILE) Makefile
|
||||
FORCE:
|
||||
|
||||
$(MAKEFILE).Debug: Makefile
|
||||
$(MAKEFILE).Release: Makefile
|
||||
#############################################################################
|
||||
# Makefile for building: build/B3View
|
||||
# Generated by qmake (2.01a) (Qt 4.7.0) on: Thu Apr 22 14:20:08 2010
|
||||
# Project: B3View.pro
|
||||
# Template: app
|
||||
# Command: /opt/qt47/bin/qmake -spec /opt/qt47/mkspecs/linux-g++ CONFIG+=debug -o Makefile B3View.pro
|
||||
#############################################################################
|
||||
|
||||
####### Compiler, tools and options
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
DEFINES =
|
||||
CFLAGS = -pipe -g -w $(DEFINES)
|
||||
CXXFLAGS = -pipe -g -w $(DEFINES)
|
||||
INCPATH = -I/opt/qt47/mkspecs/linux-g++ -I. -I../irrlicht/trunk/include
|
||||
LINK = g++
|
||||
LFLAGS = -Wl,-rpath,/opt/qt47/lib
|
||||
LIBS = $(SUBLIBS) -L/home/er/tmp/irrlicht/trunk/source/Irrlicht -lIrrlicht -lX11 -lGL -lXxf86vm
|
||||
AR = ar cqs
|
||||
RANLIB =
|
||||
QMAKE = /opt/qt47/bin/qmake
|
||||
TAR = tar -cf
|
||||
COMPRESS = gzip -9f
|
||||
COPY = cp -f
|
||||
SED = sed
|
||||
COPY_FILE = $(COPY)
|
||||
COPY_DIR = $(COPY) -r
|
||||
STRIP = strip
|
||||
INSTALL_FILE = install -m 644 -p
|
||||
INSTALL_DIR = $(COPY_DIR)
|
||||
INSTALL_PROGRAM = install -m 755 -p
|
||||
DEL_FILE = rm -f
|
||||
SYMLINK = ln -f -s
|
||||
DEL_DIR = rmdir
|
||||
MOVE = mv -f
|
||||
CHK_DIR_EXISTS= test -d
|
||||
MKDIR = mkdir -p
|
||||
|
||||
####### Output directory
|
||||
|
||||
OBJECTS_DIR = tmp/
|
||||
|
||||
####### Files
|
||||
|
||||
SOURCES = main.cpp \
|
||||
Engine.cpp \
|
||||
EventHandler.cpp \
|
||||
UserInterface.cpp \
|
||||
Debug.cpp \
|
||||
View.cpp \
|
||||
Utils.cpp
|
||||
OBJECTS = tmp/main.o \
|
||||
tmp/Engine.o \
|
||||
tmp/EventHandler.o \
|
||||
tmp/UserInterface.o \
|
||||
tmp/Debug.o \
|
||||
tmp/View.o \
|
||||
tmp/Utils.o
|
||||
DIST = /opt/qt47/mkspecs/common/g++.conf \
|
||||
/opt/qt47/mkspecs/common/unix.conf \
|
||||
/opt/qt47/mkspecs/common/linux.conf \
|
||||
/opt/qt47/mkspecs/qconfig.pri \
|
||||
/opt/qt47/mkspecs/features/qt_functions.prf \
|
||||
/opt/qt47/mkspecs/features/qt_config.prf \
|
||||
/opt/qt47/mkspecs/features/exclusive_builds.prf \
|
||||
/opt/qt47/mkspecs/features/default_pre.prf \
|
||||
/opt/qt47/mkspecs/features/debug.prf \
|
||||
/opt/qt47/mkspecs/features/default_post.prf \
|
||||
/opt/qt47/mkspecs/features/warn_off.prf \
|
||||
/opt/qt47/mkspecs/features/resources.prf \
|
||||
/opt/qt47/mkspecs/features/uic.prf \
|
||||
/opt/qt47/mkspecs/features/yacc.prf \
|
||||
/opt/qt47/mkspecs/features/lex.prf \
|
||||
/opt/qt47/mkspecs/features/include_source_dir.prf \
|
||||
B3View.pro
|
||||
QMAKE_TARGET = B3View
|
||||
DESTDIR = build/
|
||||
TARGET = build/B3View
|
||||
|
||||
first: all
|
||||
####### Implicit rules
|
||||
|
||||
.SUFFIXES: .o .c .cpp .cc .cxx .C
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.cc.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.C.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
####### Build rules
|
||||
|
||||
all: Makefile $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
@$(CHK_DIR_EXISTS) build/ || $(MKDIR) build/
|
||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
|
||||
|
||||
Makefile: B3View.pro /opt/qt47/mkspecs/linux-g++/qmake.conf /opt/qt47/mkspecs/common/g++.conf \
|
||||
/opt/qt47/mkspecs/common/unix.conf \
|
||||
/opt/qt47/mkspecs/common/linux.conf \
|
||||
/opt/qt47/mkspecs/qconfig.pri \
|
||||
/opt/qt47/mkspecs/features/qt_functions.prf \
|
||||
/opt/qt47/mkspecs/features/qt_config.prf \
|
||||
/opt/qt47/mkspecs/features/exclusive_builds.prf \
|
||||
/opt/qt47/mkspecs/features/default_pre.prf \
|
||||
/opt/qt47/mkspecs/features/debug.prf \
|
||||
/opt/qt47/mkspecs/features/default_post.prf \
|
||||
/opt/qt47/mkspecs/features/warn_off.prf \
|
||||
/opt/qt47/mkspecs/features/resources.prf \
|
||||
/opt/qt47/mkspecs/features/uic.prf \
|
||||
/opt/qt47/mkspecs/features/yacc.prf \
|
||||
/opt/qt47/mkspecs/features/lex.prf \
|
||||
/opt/qt47/mkspecs/features/include_source_dir.prf
|
||||
$(QMAKE) -spec /opt/qt47/mkspecs/linux-g++ CONFIG+=debug -o Makefile B3View.pro
|
||||
/opt/qt47/mkspecs/common/g++.conf:
|
||||
/opt/qt47/mkspecs/common/unix.conf:
|
||||
/opt/qt47/mkspecs/common/linux.conf:
|
||||
/opt/qt47/mkspecs/qconfig.pri:
|
||||
/opt/qt47/mkspecs/features/qt_functions.prf:
|
||||
/opt/qt47/mkspecs/features/qt_config.prf:
|
||||
/opt/qt47/mkspecs/features/exclusive_builds.prf:
|
||||
/opt/qt47/mkspecs/features/default_pre.prf:
|
||||
/opt/qt47/mkspecs/features/debug.prf:
|
||||
/opt/qt47/mkspecs/features/default_post.prf:
|
||||
/opt/qt47/mkspecs/features/warn_off.prf:
|
||||
/opt/qt47/mkspecs/features/resources.prf:
|
||||
/opt/qt47/mkspecs/features/uic.prf:
|
||||
/opt/qt47/mkspecs/features/yacc.prf:
|
||||
/opt/qt47/mkspecs/features/lex.prf:
|
||||
/opt/qt47/mkspecs/features/include_source_dir.prf:
|
||||
qmake: FORCE
|
||||
@$(QMAKE) -spec /opt/qt47/mkspecs/linux-g++ CONFIG+=debug -o Makefile B3View.pro
|
||||
|
||||
dist:
|
||||
@$(CHK_DIR_EXISTS) tmp/B3View1.0.0 || $(MKDIR) tmp/B3View1.0.0
|
||||
$(COPY_FILE) --parents $(SOURCES) $(DIST) tmp/B3View1.0.0/ && (cd `dirname tmp/B3View1.0.0` && $(TAR) B3View1.0.0.tar B3View1.0.0 && $(COMPRESS) B3View1.0.0.tar) && $(MOVE) `dirname tmp/B3View1.0.0`/B3View1.0.0.tar.gz . && $(DEL_FILE) -r tmp/B3View1.0.0
|
||||
|
||||
|
||||
clean:compiler_clean
|
||||
-$(DEL_FILE) $(OBJECTS)
|
||||
-$(DEL_FILE) *~ core *.core
|
||||
|
||||
|
||||
####### Sub-libraries
|
||||
|
||||
distclean: clean
|
||||
-$(DEL_FILE) $(TARGET)
|
||||
-$(DEL_FILE) Makefile
|
||||
|
||||
|
||||
check:
|
||||
|
||||
compiler_rcc_make_all:
|
||||
compiler_rcc_clean:
|
||||
compiler_uic_make_all:
|
||||
compiler_uic_clean:
|
||||
compiler_image_collection_make_all: qmake_image_collection.cpp
|
||||
compiler_image_collection_clean:
|
||||
-$(DEL_FILE) qmake_image_collection.cpp
|
||||
compiler_yacc_decl_make_all:
|
||||
compiler_yacc_decl_clean:
|
||||
compiler_yacc_impl_make_all:
|
||||
compiler_yacc_impl_clean:
|
||||
compiler_lex_make_all:
|
||||
compiler_lex_clean:
|
||||
compiler_clean:
|
||||
|
||||
####### Compile
|
||||
|
||||
tmp/main.o: main.cpp Engine.h \
|
||||
EventHandler.h \
|
||||
Debug.h \
|
||||
UserInterface.h \
|
||||
View.h \
|
||||
Utils.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/main.o main.cpp
|
||||
|
||||
tmp/Engine.o: Engine.cpp Engine.h \
|
||||
EventHandler.h \
|
||||
Debug.h \
|
||||
UserInterface.h \
|
||||
View.h \
|
||||
Utils.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/Engine.o Engine.cpp
|
||||
|
||||
tmp/EventHandler.o: EventHandler.cpp EventHandler.h \
|
||||
Debug.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/EventHandler.o EventHandler.cpp
|
||||
|
||||
tmp/UserInterface.o: UserInterface.cpp UserInterface.h \
|
||||
Debug.h \
|
||||
Engine.h \
|
||||
EventHandler.h \
|
||||
View.h \
|
||||
Utils.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/UserInterface.o UserInterface.cpp
|
||||
|
||||
tmp/Debug.o: Debug.cpp Debug.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/Debug.o Debug.cpp
|
||||
|
||||
tmp/View.o: View.cpp View.h \
|
||||
Debug.h \
|
||||
Engine.h \
|
||||
EventHandler.h \
|
||||
UserInterface.h \
|
||||
Utils.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/View.o View.cpp
|
||||
|
||||
tmp/Utils.o: Utils.cpp Utils.h \
|
||||
Debug.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o tmp/Utils.o Utils.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install: FORCE
|
||||
|
||||
uninstall: FORCE
|
||||
|
||||
FORCE:
|
||||
|
||||
|
|
|
@ -22,6 +22,22 @@ void UserInterface::displayLoadFileDialog()
|
|||
m_Gui->addFileOpenDialog( L"Select file to load", true, 0, UIE_LOADFILEDIALOG );
|
||||
}
|
||||
|
||||
void UserInterface::handleMenuItemPressed( IGUIContextMenu *menu )
|
||||
{
|
||||
s32 id = menu->getItemCommandId( menu->getSelectedItem() );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case UIC_FILE_LOAD:
|
||||
displayLoadFileDialog();
|
||||
break;
|
||||
|
||||
case UIC_FILE_QUIT:
|
||||
m_Engine->m_RunEngine = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// PUBLIC
|
||||
UserInterface::UserInterface( Engine *engine )
|
||||
{
|
||||
|
@ -41,20 +57,8 @@ IGUIEnvironment * UserInterface::getGUIEnvironment() const
|
|||
return m_Gui;
|
||||
}
|
||||
|
||||
void UserInterface::handleMenuItemPressed( IGUIContextMenu *menu )
|
||||
void UserInterface::drawStatusLine() const
|
||||
{
|
||||
s32 id = menu->getItemCommandId( menu->getSelectedItem() );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case UIC_FILE_LOAD:
|
||||
displayLoadFileDialog();
|
||||
break;
|
||||
|
||||
case UIC_FILE_QUIT:
|
||||
m_Engine->m_RunEngine = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// IEventReceiver
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// Forward declaration of class Engine
|
||||
class Engine;
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <irrlicht.h>
|
||||
|
||||
|
@ -22,7 +23,7 @@ enum UserInterfaceElements
|
|||
UIE_MAINWINDOW = 1000,
|
||||
UIE_LOADBUTTON = 1001,
|
||||
UIE_LOADFILEDIALOG = 1002,
|
||||
UIE_FILEMENU = 1003
|
||||
UIE_FILEMENU = 1003,
|
||||
};
|
||||
|
||||
enum UserInterfaceCommands
|
||||
|
@ -46,6 +47,7 @@ public:
|
|||
UserInterface( Engine *device );
|
||||
~UserInterface();
|
||||
IGUIEnvironment * getGUIEnvironment() const;
|
||||
void drawStatusLine() const;
|
||||
|
||||
// IEventReceiver
|
||||
virtual bool OnEvent( const SEvent &event );
|
||||
|
|
27
Utils.cpp
27
Utils.cpp
|
@ -1,6 +1,31 @@
|
|||
#include "Utils.h"
|
||||
|
||||
void dumpVectorToConsole( const vector3df &vector )
|
||||
void Utility::dumpVectorToConsole( const vector3df &vector )
|
||||
{
|
||||
debug() << "X: " << vector.X << " Y: " << vector.Y << " Z: " << vector.Z << endl;
|
||||
}
|
||||
|
||||
void Utility::dumpMeshInfoToConsole( IAnimatedMeshSceneNode *node )
|
||||
{
|
||||
// Dump some information about the mesh to the console
|
||||
IAnimatedMesh *mesh = node->getMesh();
|
||||
|
||||
debug() << "[MESH]: # of frames : " << mesh->getFrameCount() << endl;
|
||||
debug() << "[MESH]: # of materials : " << node->getMaterialCount() << endl;
|
||||
for( int matIndex = 0; matIndex < node->getMaterialCount(); matIndex ++ )
|
||||
{
|
||||
debug() << "[MESH]: Material # " << matIndex << endl;
|
||||
const SMaterial &material = node->getMaterial( matIndex );
|
||||
debug() << "[MESH]: Diffuse Color : A" << material.DiffuseColor.getAlpha() << " R" << material.DiffuseColor.getRed() << " G" << material.DiffuseColor.getGreen() << " B" << material.DiffuseColor.getBlue() << endl;
|
||||
debug() << "[MESH]: Specular Color : A" << material.SpecularColor.getAlpha() << " R" << material.SpecularColor.getRed() << " G" << material.SpecularColor.getGreen() << " B" << material.SpecularColor.getBlue() << endl;
|
||||
debug() << "[MESH]: Specular Shininess : " << material.Shininess << endl;
|
||||
|
||||
// check for # textures
|
||||
int textures = 0;
|
||||
for( int ti = 0; ti < MATERIAL_MAX_TEXTURES; ti ++ )
|
||||
if( material.getTexture( ti ) != 0 ) textures ++;
|
||||
debug() << "[MESH]: # of textures : " << textures << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
11
Utils.h
11
Utils.h
|
@ -5,9 +5,16 @@
|
|||
#include <irrlicht.h>
|
||||
#include "Debug.h"
|
||||
|
||||
using irr::core::vector3df;
|
||||
using namespace irr::core;
|
||||
using namespace irr::scene;
|
||||
using namespace irr::video;
|
||||
using namespace std;
|
||||
|
||||
void dumpVectorToConsole( const vector3df &vector );
|
||||
class Utility
|
||||
{
|
||||
public:
|
||||
static void dumpVectorToConsole( const vector3df &vector );
|
||||
static void dumpMeshInfoToConsole( IAnimatedMeshSceneNode *node );
|
||||
};
|
||||
|
||||
#endif // UTILS_H
|
||||
|
|
14
View.cpp
14
View.cpp
|
@ -52,10 +52,20 @@ 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 )
|
||||
// If it's not a mouse event or window resize event, return
|
||||
if( event.EventType != EET_MOUSE_INPUT_EVENT && !( event.EventType == EET_USER_EVENT && event.UserEvent.UserData1 == UEI_WINDOWSIZECHANGED ))
|
||||
return false;
|
||||
|
||||
// Handle window resize
|
||||
if( event.EventType == EET_USER_EVENT && event.UserEvent.UserData1 == UEI_WINDOWSIZECHANGED )
|
||||
{
|
||||
dimension2d<u32> windowSize = m_Engine->m_Driver->getScreenSize();
|
||||
f32 aspectRatio = (f32) windowSize.Width / windowSize.Height;
|
||||
debug() << "Setting aspect to: " << aspectRatio << endl;
|
||||
m_Engine->m_Scene->getActiveCamera()->setAspectRatio( aspectRatio );
|
||||
}
|
||||
|
||||
// Handle mouse event
|
||||
const SEvent::SMouseInput *mouseEvent = &( event.MouseInput );
|
||||
|
||||
if( mouseEvent->Event == EMIE_MMOUSE_PRESSED_DOWN )
|
||||
|
|
6
main.cpp
6
main.cpp
|
@ -56,7 +56,11 @@ int main( int argc, char **argv )
|
|||
wchar_t * getWideCharString( char *str )
|
||||
{
|
||||
wchar_t *dest = ( wchar_t * ) malloc( sizeof( wchar_t ) * ( strlen( str ) + 1 ));
|
||||
mbstowcs( dest, str, strlen( str ));
|
||||
|
||||
int resultSize = mbstowcs( 0, str, strlen( str ));
|
||||
mbstowcs( dest, str, strlen( str ));
|
||||
|
||||
dest[resultSize] = '\0';
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue