Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
316d9dbef8 | ||
|
|
c05d85badb | ||
|
|
90ff61da00 | ||
|
|
0d78fc5ece | ||
|
|
419ebc8783 | ||
|
|
5c58595f35 | ||
|
|
509e569c64 | ||
|
|
99f3a4dfff | ||
|
|
40a11244dd | ||
|
|
5f862e092a | ||
|
|
600c80fffa | ||
|
|
853d691658 | ||
|
|
e3733a7b0b | ||
|
|
10701d787c | ||
|
|
ef942fe580 | ||
|
|
c2ca0a1a4d | ||
|
|
b5c4ef359f |
@@ -1,6 +1,8 @@
|
|||||||
syntax:glob
|
syntax:glob
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
|
CPackConfig.cmake
|
||||||
|
CPackSourceConfig.cmake
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
debug
|
debug
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Tries to find GLEW
|
||||||
|
#
|
||||||
|
# Sets variables
|
||||||
|
# GLEW_FOUND
|
||||||
|
# GLEW_INCLUDE_DIR
|
||||||
|
# GLEW_LIBRARIES
|
||||||
|
#
|
||||||
|
SET (GLEW_FOUND FALSE)
|
||||||
|
|
||||||
|
FIND_PATH (GLEW_INCLUDE_DIR glew.h /usr/include/ /usr/local/include/ /usr/include/GL /usr/local/include/GL $ENV{GLEW_PATH}/include $ENV{GLEW_INCLUDE_PATH})
|
||||||
|
|
||||||
|
FIND_LIBRARY (GLEW_LIBRARIES NAMES GLEW PATHS /usr/lib /usr/local/lib $ENV{GLEW_PATH} $ENV{GLEW_PATH}/lib ENV{GLEW_LIBRARY_PATH})
|
||||||
|
|
||||||
|
IF (GLEW_INCLUDE_DIR AND GLEW_LIBRARIES)
|
||||||
|
SET (GLEW_FOUND TRUE)
|
||||||
|
ENDIF (GLEW_INCLUDE_DIR AND GLEW_LIBRARIES)
|
||||||
|
|
||||||
|
IF (GLEW_FOUND)
|
||||||
|
IF (NOT GLEW_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found GLEW: ${GLEW_LIBRARIES}")
|
||||||
|
ENDIF (NOT GLEW_FIND_QUIETLY)
|
||||||
|
ELSE (GLEW_FOUND)
|
||||||
|
IF (GLEW_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could not find GLEW")
|
||||||
|
ENDIF (GLEW_FIND_REQUIRED)
|
||||||
|
ENDIF (GLEW_FOUND)
|
||||||
|
|
||||||
|
MARK_AS_ADVANCED (
|
||||||
|
GLEW_INCLUDE_DIR
|
||||||
|
GLEW_LIBRARIES
|
||||||
|
)
|
||||||
+25
-8
@@ -10,6 +10,10 @@ SET (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|||||||
SET (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
SET (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||||
SET (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
SET (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
|
FIND_PACKAGE (SDL REQUIRED)
|
||||||
|
FIND_PACKAGE (SDL_net REQUIRED)
|
||||||
|
FIND_PACKAGE (GLEW REQUIRED)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES (
|
INCLUDE_DIRECTORIES (
|
||||||
engine/
|
engine/
|
||||||
asteroids/
|
asteroids/
|
||||||
@@ -18,6 +22,7 @@ INCLUDE_DIRECTORIES (
|
|||||||
engine/libraries/coll2d/include
|
engine/libraries/coll2d/include
|
||||||
engine/libraries/oglft/liboglft
|
engine/libraries/oglft/liboglft
|
||||||
${FREETYPE2_INCLUDE_DIR}
|
${FREETYPE2_INCLUDE_DIR}
|
||||||
|
${GLEW_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY ( engine )
|
ADD_SUBDIRECTORY ( engine )
|
||||||
@@ -54,6 +59,11 @@ SET ( ASTEROIDSEDITOR_SOURCES
|
|||||||
asteroids/View.cc
|
asteroids/View.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES (
|
||||||
|
${SDLMIXER_INCLUDE_DIRS}
|
||||||
|
${SDLNET_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE ( fysxasteroids ${ASTEROIDS_SOURCES} )
|
ADD_EXECUTABLE ( fysxasteroids ${ASTEROIDS_SOURCES} )
|
||||||
ADD_EXECUTABLE ( fysxasteroidseditor ${ASTEROIDSEDITOR_SOURCES} )
|
ADD_EXECUTABLE ( fysxasteroidseditor ${ASTEROIDSEDITOR_SOURCES} )
|
||||||
|
|
||||||
@@ -106,22 +116,28 @@ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A fun and good looking clone of the popul
|
|||||||
SET(CPACK_PACKAGE_VENDOR "Martin Felis <martin@fysx.org>")
|
SET(CPACK_PACKAGE_VENDOR "Martin Felis <martin@fysx.org>")
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
|
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt")
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.txt")
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
|
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR "9")
|
SET(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||||
SET(CPACK_PACKAGE_VERSION_PATCH "1")
|
SET(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
|
# SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
|
||||||
SET(CPACK_PACKAGE_CONTACT "Martin Felis <martin@fysx.org>")
|
SET(CPACK_PACKAGE_CONTACT "Martin Felis <martin@fysx.org>")
|
||||||
|
|
||||||
|
# Add defines for the version
|
||||||
|
SET (VERSION_STRING
|
||||||
|
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
|
ADD_DEFINITIONS(-DFYSXASTEROIDS_VERSION=\"${VERSION_STRING}\")
|
||||||
|
|
||||||
IF(WIN32 AND NOT UNIX)
|
IF(WIN32 AND NOT UNIX)
|
||||||
# There is a bug in NSI that does not handle full unix paths properly. Make
|
# There is a bug in NSI that does not handle full unix paths properly. Make
|
||||||
# sure there is at least one set of four (4) backlasshes.
|
# sure there is at least one set of four (4) backlasshes.
|
||||||
SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
|
SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/textures\\\\icon.bmp")
|
||||||
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\fysxasteroids.exe")
|
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\fysxasteroids.exe")
|
||||||
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} fysxdotorg")
|
SET(CPACK_NSIS_DISPLAY_NAME "fysxasteroids")
|
||||||
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.fysx.org")
|
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.fysx.org")
|
||||||
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.fysx.org")
|
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.fysx.org")
|
||||||
SET(CPACK_NSIS_CONTACT "martin@fysx.org")
|
SET(CPACK_NSIS_CONTACT "martin@fysx.org")
|
||||||
SET(CPACK_NSIS_MODIFY_PATH ON)
|
SET(CPACK_NSIS_MODIFY_PATH ON)
|
||||||
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "/fysxdotorg")
|
||||||
ELSE(WIN32 AND NOT UNIX)
|
ELSE(WIN32 AND NOT UNIX)
|
||||||
# Debian stuff
|
# Debian stuff
|
||||||
SET(CPACK_GENERATOR "DEB")
|
SET(CPACK_GENERATOR "DEB")
|
||||||
@@ -130,9 +146,10 @@ ELSE(WIN32 AND NOT UNIX)
|
|||||||
SET(CPACK_SOURCE_STRIP_FILES "TRUE")
|
SET(CPACK_SOURCE_STRIP_FILES "TRUE")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games and Amusement")
|
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games and Amusement")
|
||||||
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-filesystem1.42.0 (>= 1.42.0-1), libboost-system1.42.0 (>= 1.42.0-1), libc6 (>= 2.4), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libglu1-mesa | libglu1, libice6 (>= 1:1.0.0), libpng12-0 (>= 1.2.13-4), libsdl-net1.2 (>= 1.2.7), libsdl-mixer1.2 (>= 1.2.6), libsdl1.2debian (>= 1.2.10-1), libsm6, libstdc++6 (>= 4.4.0), libx11-6, libxext6, zlib1g (>= 1:1.1.4)")
|
SET(CPACK_DEBIAN_PACKAGE_DEPENDS
|
||||||
|
"libboost-filesystem1.40.0 (>= 1.40.0-1), libboost-system1.40.0 (>= 1.40.0-1), libc6 (>= 2.4), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libglu1-mesa | libglu1, libice6 (>= 1:1.0.0), libpng12-0 (>= 1.2.13-4), libsdl-net1.2 (>= 1.2.7), libsdl-mixer1.2 (>= 1.2.6), libsdl1.2debian (>= 1.2.10-1), libsm6, libstdc++6 (>= 4.4.0), libx11-6, libxext6, zlib1g (>= 1:1.1.4)"
|
||||||
|
)
|
||||||
|
|
||||||
ENDIF(WIN32 AND NOT UNIX)
|
ENDIF(WIN32 AND NOT UNIX)
|
||||||
SET(CPACK_PACKAGE_EXECUTABLES "fysxasteroids" "fysxasteroidseditor")
|
SET(CPACK_PACKAGE_EXECUTABLES "fysxasteroids" "fysxasteroidseditor")
|
||||||
|
|
||||||
INCLUDE ( CPack )
|
INCLUDE ( CPack )
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ void Controller::ResetPlayerEntity () {
|
|||||||
Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId());
|
Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId());
|
||||||
player_entity->mPhysicState->mAngleVelocity = 0.;
|
player_entity->mPhysicState->mAngleVelocity = 0.;
|
||||||
|
|
||||||
int i;
|
player_entity->ResetControllerKeyState();
|
||||||
for (i = 0; i < EntityControllerMaxKeyStates; i++)
|
|
||||||
player_entity->UnsetControllerKeyState(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We definitely have to reset the player entity id
|
// We definitely have to reset the player entity id
|
||||||
|
|||||||
+13
-13
@@ -52,7 +52,7 @@ int Model::OnInit (int argc, char* argv[]) {
|
|||||||
mLevelHashes["level06_WolleNew3_watch_your.map"] = "e5e86667623b12a491a2395a9b361617ee961edf8d349b7419942f0dbf76b769";
|
mLevelHashes["level06_WolleNew3_watch_your.map"] = "e5e86667623b12a491a2395a9b361617ee961edf8d349b7419942f0dbf76b769";
|
||||||
mLevelHashes["level07_circled.map"] = "98aa36bf2c8f6be8cd23c7c284d6ff413db992f09e5d5866e5a3aa393a93b367";
|
mLevelHashes["level07_circled.map"] = "98aa36bf2c8f6be8cd23c7c284d6ff413db992f09e5d5866e5a3aa393a93b367";
|
||||||
mLevelHashes["level08_highway.map"] = "bf5e678750d3f4d47c7bfec5ae62d852db1f475146ef013040d1e67308708a66";
|
mLevelHashes["level08_highway.map"] = "bf5e678750d3f4d47c7bfec5ae62d852db1f475146ef013040d1e67308708a66";
|
||||||
mLevelHashes["level09_WolleNew4_wheres_the_brain.map"] = "f3f685f6eb6cc703a5eaa0177472717ea49dddc2099e2bd1865f551f94e8fdf4";
|
mLevelHashes["level09_WolleNew4_wheres_the_brain.map"] = "94af432a967ed68389a41c2907b3500de9b6a8744816c025a7269ff2ef0509c9";
|
||||||
mLevelHashes["level10_WolleWhatever_whatever.map"] = "2f97984e86bd0969909032fa44bcf883dd181fbe61782ee7dd704b0b63dfd0e1";
|
mLevelHashes["level10_WolleWhatever_whatever.map"] = "2f97984e86bd0969909032fa44bcf883dd181fbe61782ee7dd704b0b63dfd0e1";
|
||||||
mLevelHashes["level11_Strahlensatz.map"] = "3f293d4b0ea23688c15761a54b2ee097cc6a41b30750cc8fc5fccf94c20bf018";
|
mLevelHashes["level11_Strahlensatz.map"] = "3f293d4b0ea23688c15761a54b2ee097cc6a41b30750cc8fc5fccf94c20bf018";
|
||||||
mLevelHashes["level12_almost_there_test5.map"] = "5cefdc7dadbbfc30f32580f3e50cfbb6cae9ca5f432fd73e777bdbb835f3660a";
|
mLevelHashes["level12_almost_there_test5.map"] = "5cefdc7dadbbfc30f32580f3e50cfbb6cae9ca5f432fd73e777bdbb835f3660a";
|
||||||
@@ -61,7 +61,7 @@ int Model::OnInit (int argc, char* argv[]) {
|
|||||||
mLevelHashes["level15_WolleNew6_smack_my.map"] = "1d7e1223bbd8a68492108c2416c1a8ba828d293601c02e489dbf6b5db6a1aaa2";
|
mLevelHashes["level15_WolleNew6_smack_my.map"] = "1d7e1223bbd8a68492108c2416c1a8ba828d293601c02e489dbf6b5db6a1aaa2";
|
||||||
mLevelHashes["level16_Wolle7_todesspirale.map"] = "d82d8f6c21806238a7b6a87c1217a0dff42f4e59e73f28e7af3f0c8afd908e38";
|
mLevelHashes["level16_Wolle7_todesspirale.map"] = "d82d8f6c21806238a7b6a87c1217a0dff42f4e59e73f28e7af3f0c8afd908e38";
|
||||||
mLevelHashes["level17_WolleEasyNew1_twin_supernova.map"] = "4e177f82a0ba8f909ff1af1adf13caf82ab41cf09d69504c87f3e0551b9b73ed";
|
mLevelHashes["level17_WolleEasyNew1_twin_supernova.map"] = "4e177f82a0ba8f909ff1af1adf13caf82ab41cf09d69504c87f3e0551b9b73ed";
|
||||||
mLevelHashes["level18_WolleNew2_dont_drink.map"] = "3b7b0fa59ee652e763ea43ffd7e572e1bd0436116fd5d5b13ed679fce362d265";
|
mLevelHashes["level18_WolleNew2_dont_drink.map"] = "09c32e7bc6bc3c8ef7bd96b0f60094dd46276227d653abfa3c300687d31776fd";
|
||||||
mLevelHashes["level19_Geisterfahrer.map"] = "2036741d6fd4a863324210e53b903d7a898c4478e5eb9607a43a110bb6999ace";
|
mLevelHashes["level19_Geisterfahrer.map"] = "2036741d6fd4a863324210e53b903d7a898c4478e5eb9607a43a110bb6999ace";
|
||||||
mLevelHashes["level20_billiard.map"] = "23dcffbf61bd887db7613b02d0c9ad04d77d800af631edbcf5822a169dcc2a9d";
|
mLevelHashes["level20_billiard.map"] = "23dcffbf61bd887db7613b02d0c9ad04d77d800af631edbcf5822a169dcc2a9d";
|
||||||
mLevelHashes["level21_final.map"] = "6384b1565c0c844d7083e744d6cfbaf9de42f5ad5ecb0cb668c3a2458860c8ac";
|
mLevelHashes["level21_final.map"] = "6384b1565c0c844d7083e744d6cfbaf9de42f5ad5ecb0cb668c3a2458860c8ac";
|
||||||
@@ -160,6 +160,7 @@ void Model::Process () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Model::InitLevelList () {
|
unsigned int Model::InitLevelList () {
|
||||||
|
boost::filesystem::path level_dir_path;
|
||||||
std::string level_dir_name = Engine::GetResourceFullPath("/data/levels/");
|
std::string level_dir_name = Engine::GetResourceFullPath("/data/levels/");
|
||||||
Engine::LogDebug ("Searching for levels in %s", level_dir_name.c_str());
|
Engine::LogDebug ("Searching for levels in %s", level_dir_name.c_str());
|
||||||
|
|
||||||
@@ -167,12 +168,12 @@ unsigned int Model::InitLevelList () {
|
|||||||
|
|
||||||
boost::filesystem::path level_dir(level_dir_name);
|
boost::filesystem::path level_dir(level_dir_name);
|
||||||
|
|
||||||
if (!boost::filesystem::exists(level_dir)) {
|
if (!boost::filesystem::exists(level_dir.string())) {
|
||||||
Engine::LogError ("Could not init level list: \todo %s does not exist!");
|
Engine::LogError ("Could not init level list: %s does not exist!", level_dir.filename().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!boost::filesystem::is_directory(level_dir)) {
|
if (!boost::filesystem::is_directory(level_dir)) {
|
||||||
Engine::LogError ("Could not init level list: \todo %s is not a directory!");
|
Engine::LogError ("Could not init level list: %s is not a directory!", level_dir_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::directory_iterator end_iter;
|
boost::filesystem::directory_iterator end_iter;
|
||||||
@@ -181,11 +182,11 @@ unsigned int Model::InitLevelList () {
|
|||||||
++dir_iter) {
|
++dir_iter) {
|
||||||
if (boost::filesystem::is_regular_file (dir_iter->status())) {
|
if (boost::filesystem::is_regular_file (dir_iter->status())) {
|
||||||
std::string level_relative_path (level_dir_name);
|
std::string level_relative_path (level_dir_name);
|
||||||
level_relative_path += dir_iter->path().filename();
|
level_relative_path += dir_iter->path().filename().string();
|
||||||
|
|
||||||
// check whether we found an official level
|
// check whether we found an official level
|
||||||
std::string map_name (level_relative_path);
|
std::string map_name (dir_iter->path().filename().string());
|
||||||
map_name = map_name.substr(map_name.rfind ('/') + 1, map_name.size());
|
|
||||||
if (mLevelHashes.find(map_name) == mLevelHashes.end()) {
|
if (mLevelHashes.find(map_name) == mLevelHashes.end()) {
|
||||||
Engine::LogDebug ("Skipping unofficial level %s", std::string(level_relative_path).c_str());
|
Engine::LogDebug ("Skipping unofficial level %s", std::string(level_relative_path).c_str());
|
||||||
continue;
|
continue;
|
||||||
@@ -391,7 +392,7 @@ bool Model::PullGlobalHighscore(std::stringstream &highscore_stream) {
|
|||||||
int bytes_sent;
|
int bytes_sent;
|
||||||
bytes_sent = SDLNet_TCP_Send (server_socket, http_query_string.c_str(), http_query_string.size());
|
bytes_sent = SDLNet_TCP_Send (server_socket, http_query_string.c_str(), http_query_string.size());
|
||||||
|
|
||||||
if (bytes_sent != http_query_string.size()) {
|
if (static_cast<unsigned int>(bytes_sent) != http_query_string.size()) {
|
||||||
Engine::LogError ("SDL_net tcp send: %s", SDLNet_GetError());
|
Engine::LogError ("SDL_net tcp send: %s", SDLNet_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -500,7 +501,7 @@ bool Model::SubmitGlobalHigscoreEntry (std::string name, const unsigned int poin
|
|||||||
int bytes_sent;
|
int bytes_sent;
|
||||||
bytes_sent = SDLNet_TCP_Send (server_socket, http_query_string.c_str(), http_query_string.size());
|
bytes_sent = SDLNet_TCP_Send (server_socket, http_query_string.c_str(), http_query_string.size());
|
||||||
|
|
||||||
if (bytes_sent != http_query_string.size()) {
|
if (static_cast<unsigned int>(bytes_sent) != http_query_string.size()) {
|
||||||
Engine::LogError ("SDL_net tcp send: %s", SDLNet_GetError());
|
Engine::LogError ("SDL_net tcp send: %s", SDLNet_GetError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -559,14 +560,14 @@ void Model::SubmitHighscoreEntry (const std::string &name, const unsigned int po
|
|||||||
int Model::DoLoadLevel (const char* filename) {
|
int Model::DoLoadLevel (const char* filename) {
|
||||||
// verify the hash of the map
|
// verify the hash of the map
|
||||||
std::string map_name (filename);
|
std::string map_name (filename);
|
||||||
map_name = map_name.substr(map_name.rfind ('/') + 1, map_name.size());
|
map_name = boost::filesystem::path(map_name).filename().string();
|
||||||
std::string map_hash = sha256_hash_file (filename);
|
std::string map_hash = sha256_hash_file (filename);
|
||||||
if (map_hash != mLevelHashes[map_name]) {
|
if (map_hash != mLevelHashes[map_name]) {
|
||||||
Engine::LogMessage ("Map verification for file %s failed!", map_name.c_str());
|
Engine::LogMessage ("Map verification for file %s failed!", map_name.c_str());
|
||||||
mGameModified = true;
|
mGameModified = true;
|
||||||
mCurrentLevelModified = true;
|
mCurrentLevelModified = true;
|
||||||
}
|
}
|
||||||
Engine::LogDebug ("Verification for level %s OK: loading level.");
|
Engine::LogDebug ("Verification for level %s OK: loading level.", map_name.c_str());
|
||||||
|
|
||||||
std::fstream level_file (filename, std::ios::in);
|
std::fstream level_file (filename, std::ios::in);
|
||||||
|
|
||||||
@@ -799,7 +800,6 @@ void Model::OnLevelComplete() {
|
|||||||
// calculate the bonus points
|
// calculate the bonus points
|
||||||
float level_time = roundf(mLevelTimeSeconds);
|
float level_time = roundf(mLevelTimeSeconds);
|
||||||
float level_par_time = roundf(mLevelParTimeSeconds);
|
float level_par_time = roundf(mLevelParTimeSeconds);
|
||||||
int bonus_points = 0;
|
|
||||||
|
|
||||||
if (level_time <= level_par_time) {
|
if (level_time <= level_par_time) {
|
||||||
// secret time bonus formula
|
// secret time bonus formula
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class Model : public Engine::ModelBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetGameModified() { return mGameModified; }
|
bool GetGameModified() { return mGameModified; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** \brief Initializes the system */
|
/** \brief Initializes the system */
|
||||||
virtual int OnInit (int argc, char* argv[]);
|
virtual int OnInit (int argc, char* argv[]);
|
||||||
|
|||||||
+85
-12
@@ -17,6 +17,8 @@
|
|||||||
#include "AsteroidsEvents.h"
|
#include "AsteroidsEvents.h"
|
||||||
#include "RocketEntity.h"
|
#include "RocketEntity.h"
|
||||||
|
|
||||||
|
#include "OBJModel.h"
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
@@ -77,6 +79,8 @@ int View::OnInit (int argc, char* argv[]) {
|
|||||||
mShipPartsSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/ship_parts.png"));
|
mShipPartsSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/ship_parts.png"));
|
||||||
mShipPartsSprite.SetSubSpriteCount (10);
|
mShipPartsSprite.SetSubSpriteCount (10);
|
||||||
|
|
||||||
|
mAsteroidModel = LoadOBJModel (Engine::GetResourceFullPath("/data/models/asteroid/asteroid_model.obj"));
|
||||||
|
|
||||||
Engine::RegisterListener (this, EventAccelerateStart);
|
Engine::RegisterListener (this, EventAccelerateStart);
|
||||||
Engine::RegisterListener (this, EventAccelerateStop);
|
Engine::RegisterListener (this, EventAccelerateStop);
|
||||||
Engine::RegisterListener (this, EventShipExplode);
|
Engine::RegisterListener (this, EventShipExplode);
|
||||||
@@ -179,6 +183,47 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) {
|
|||||||
/*
|
/*
|
||||||
* Module specific functions
|
* Module specific functions
|
||||||
*/
|
*/
|
||||||
|
void View::Resize (int width, int height) {
|
||||||
|
if (height == 0)
|
||||||
|
height = 1;
|
||||||
|
|
||||||
|
mWindowWidth = static_cast<unsigned int> (width);
|
||||||
|
mWindowHeight = static_cast<unsigned int> (height);
|
||||||
|
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
float world_width, world_height;
|
||||||
|
world_width = GetModel()->GetWorldWidth ();
|
||||||
|
world_height = GetModel()->GetWorldHeight ();
|
||||||
|
|
||||||
|
Engine::LogMessage ("width %f height %f", world_width, world_height);
|
||||||
|
|
||||||
|
glOrtho (- world_width * 0.5, world_width * 0.5, -world_height * 0.5, world_height * 0.5, 0., 100.);
|
||||||
|
// gluPerspective(mCamera->GetFOVY (), float (width) / float (height), 0., 100);
|
||||||
|
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity ();
|
||||||
|
|
||||||
|
Engine::LogDebug ("Resize to: %d x %d", mWindowWidth,mWindowHeight);
|
||||||
|
|
||||||
|
/** \warning
|
||||||
|
* This call has to be made for SDL 1.2 for 1.3 there seems to be a
|
||||||
|
* workaround, however since I do not yet run SDL 1.3 I hold on to this.
|
||||||
|
* See http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-November/067306.html
|
||||||
|
*/
|
||||||
|
Uint32 video_flags = SDL_OPENGL;
|
||||||
|
|
||||||
|
if (mDrawFullscreen)
|
||||||
|
video_flags = video_flags | SDL_FULLSCREEN;
|
||||||
|
|
||||||
|
if( SDL_SetVideoMode( mWindowWidth, mWindowHeight, 16, video_flags) == 0 ) {
|
||||||
|
Engine::LogError ("Video mode set failed: %s", SDL_GetError ());
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void View::UpdateCamera () {
|
void View::UpdateCamera () {
|
||||||
mCamera->SetEye (
|
mCamera->SetEye (
|
||||||
0.,
|
0.,
|
||||||
@@ -212,6 +257,7 @@ void View::DrawStars() {
|
|||||||
glColor3f (1., 1., 1.);
|
glColor3f (1., 1., 1.);
|
||||||
glPointSize(2.);
|
glPointSize(2.);
|
||||||
glBegin(GL_POINTS);
|
glBegin(GL_POINTS);
|
||||||
|
|
||||||
float z_value;
|
float z_value;
|
||||||
for (i = 0; i < mBackgroundStars.size(); i++) {
|
for (i = 0; i < mBackgroundStars.size(); i++) {
|
||||||
// glPointSize (2. + 300. *mBackgroundStars.at(i).position[1]);
|
// glPointSize (2. + 300. *mBackgroundStars.at(i).position[1]);
|
||||||
@@ -219,7 +265,7 @@ void View::DrawStars() {
|
|||||||
|
|
||||||
glColor3f (z_value, z_value, z_value);
|
glColor3f (z_value, z_value, z_value);
|
||||||
glVertex3f (mBackgroundStars.at(i).position[0] * world_width,
|
glVertex3f (mBackgroundStars.at(i).position[0] * world_width,
|
||||||
-1.,
|
-10.,
|
||||||
mBackgroundStars.at(i).position[2] * world_height);
|
mBackgroundStars.at(i).position[2] * world_height);
|
||||||
|
|
||||||
mBackgroundStars.at(i).position -= vector3d(Engine::GetFrameDuration() * 0.7 * mBackgroundStars.at(i).position[1] / world_width, 0., 0.);
|
mBackgroundStars.at(i).position -= vector3d(Engine::GetFrameDuration() * 0.7 * mBackgroundStars.at(i).position[1] / world_width, 0., 0.);
|
||||||
@@ -257,7 +303,9 @@ void View::Draw() {
|
|||||||
unsigned int game_state = game_model->GetGameState();
|
unsigned int game_state = game_model->GetGameState();
|
||||||
unsigned int view_state = GetViewState();
|
unsigned int view_state = GetViewState();
|
||||||
|
|
||||||
|
glEnable (GL_DEPTH_TEST);
|
||||||
DrawStars ();
|
DrawStars ();
|
||||||
|
glDisable (GL_DEPTH_TEST);
|
||||||
|
|
||||||
if ( game_state == GameStateRunning
|
if ( game_state == GameStateRunning
|
||||||
|| view_state == ViewStateLevelIntro
|
|| view_state == ViewStateLevelIntro
|
||||||
@@ -410,6 +458,7 @@ void View::DrawUi () {
|
|||||||
glMatrixMode (GL_MODELVIEW);
|
glMatrixMode (GL_MODELVIEW);
|
||||||
glPushMatrix ();
|
glPushMatrix ();
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
|
glTranslatef (0., 1., 0.);
|
||||||
|
|
||||||
unsigned int game_state = GetModel()->GetGameState();
|
unsigned int game_state = GetModel()->GetGameState();
|
||||||
|
|
||||||
@@ -418,10 +467,10 @@ void View::DrawUi () {
|
|||||||
|
|
||||||
ViewState current_view_state = GetViewState();
|
ViewState current_view_state = GetViewState();
|
||||||
|
|
||||||
/*
|
stringstream fps_stream;
|
||||||
|
fps_stream << "fps: " << GetFrameRate();
|
||||||
SelectFont ("console.ttf size=12");
|
SelectFont ("console.ttf size=12");
|
||||||
Engine::GUI::Label (99999, GetStringViewState(current_view_state), 8, 16);
|
Engine::GUI::Label (99999, fps_stream.str().c_str(), 8, 48);
|
||||||
*/
|
|
||||||
|
|
||||||
switch (current_view_state) {
|
switch (current_view_state) {
|
||||||
case ViewStateMainMenu:
|
case ViewStateMainMenu:
|
||||||
@@ -491,9 +540,14 @@ void View::DrawUiMainMenu() {
|
|||||||
DrawPageTitle ("Asteroids");
|
DrawPageTitle ("Asteroids");
|
||||||
|
|
||||||
SelectFont("console.ttf size=23 color=#444444");
|
SelectFont("console.ttf size=23 color=#444444");
|
||||||
DrawGLString( screen_right - 272, screen_bottom - 16, "http://www.fysx.org");
|
DrawGLString( screen_right - 272, screen_bottom - 6, "http://www.fysx.org");
|
||||||
SelectFont("console.ttf size=23 color=#cccccc");
|
SelectFont("console.ttf size=23 color=#cccccc");
|
||||||
DrawGLString( screen_right - 270, screen_bottom - 18, "http://www.fysx.org");
|
DrawGLString( screen_right - 270, screen_bottom - 8, "http://www.fysx.org");
|
||||||
|
|
||||||
|
SelectFont("console.ttf size=23 color=#444444");
|
||||||
|
DrawGLString( 8, screen_bottom - 6, FYSXASTEROIDS_VERSION);
|
||||||
|
SelectFont("console.ttf size=23 color=#cccccc");
|
||||||
|
DrawGLString( 6, screen_bottom - 8, FYSXASTEROIDS_VERSION);
|
||||||
|
|
||||||
SelectFont("console.ttf size=23");
|
SelectFont("console.ttf size=23");
|
||||||
if (Engine::GUI::Button (1, "New Game", screen_right * 0.5 - 100, 200, button_width, button_height)) {
|
if (Engine::GUI::Button (1, "New Game", screen_right * 0.5 - 100, 200, button_width, button_height)) {
|
||||||
@@ -584,8 +638,6 @@ void View::DrawUiGameOver() {
|
|||||||
text_xpos,
|
text_xpos,
|
||||||
text_ypos);
|
text_ypos);
|
||||||
|
|
||||||
const static int value_width = 10;
|
|
||||||
|
|
||||||
text_ypos += 48;
|
text_ypos += 48;
|
||||||
|
|
||||||
// ----- New Score -----
|
// ----- New Score -----
|
||||||
@@ -656,6 +708,9 @@ void View::DrawUiLevelIntro() {
|
|||||||
GetModel()->SetPlayerLives(100);
|
GetModel()->SetPlayerLives(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
stringstream level_info_stream;
|
stringstream level_info_stream;
|
||||||
level_info_stream << "Level " << GetModel()->GetCurrentLevelIndex() + 1;
|
level_info_stream << "Level " << GetModel()->GetCurrentLevelIndex() + 1;
|
||||||
|
|
||||||
@@ -739,6 +794,8 @@ void View::DrawUiLevelIntro() {
|
|||||||
level_author_dest_y - Engine::GetTimer("LevelIntroLevelAuthor") * level_author_delta_y
|
level_author_dest_y - Engine::GetTimer("LevelIntroLevelAuthor") * level_author_delta_y
|
||||||
);
|
);
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
if (Engine::CheckTimer("LevelIntroLevelStart")) {
|
if (Engine::CheckTimer("LevelIntroLevelStart")) {
|
||||||
if(Engine::GUI::Button (1, "Start", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 180, button_width, button_height)) {
|
if(Engine::GUI::Button (1, "Start", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 180, button_width, button_height)) {
|
||||||
PopViewState();
|
PopViewState();
|
||||||
@@ -776,7 +833,6 @@ void View::DrawUiLevelComplete() {
|
|||||||
|
|
||||||
if (GetModel()->GetGameModified()) {
|
if (GetModel()->GetGameModified()) {
|
||||||
SelectFont("console.ttf size=23 color=#cc0000");
|
SelectFont("console.ttf size=23 color=#cc0000");
|
||||||
float width, height;
|
|
||||||
std::string message ("* UNOFFICIAL GAME * UNOFFICIAL GAME * UNOFFICIAL GAME *");
|
std::string message ("* UNOFFICIAL GAME * UNOFFICIAL GAME * UNOFFICIAL GAME *");
|
||||||
|
|
||||||
float xpos = (screen_left) + 5;
|
float xpos = (screen_left) + 5;
|
||||||
@@ -946,7 +1002,7 @@ void View::DrawUiPlayerDied() {
|
|||||||
*/
|
*/
|
||||||
void View::DrawHighscoreEntry (float x, float y, float entry_width, const std::string &name, unsigned int points) {
|
void View::DrawHighscoreEntry (float x, float y, float entry_width, const std::string &name, unsigned int points) {
|
||||||
const float width_buffer = 30.;
|
const float width_buffer = 30.;
|
||||||
float width, height;
|
float height;
|
||||||
float name_width, points_value_width;
|
float name_width, points_value_width;
|
||||||
|
|
||||||
// Measure and draw the name
|
// Measure and draw the name
|
||||||
@@ -1641,8 +1697,25 @@ void View::DrawShip (ShipEntity *ship) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void View::DrawAsteroid (AsteroidEntity *asteroid) {
|
void View::DrawAsteroid (AsteroidEntity *asteroid) {
|
||||||
mAsteroidSprite.SetScale (2. * asteroid->mPhysicState->mRadius / mAsteroidSprite.GetWidth());
|
// mAsteroidSprite.SetScale (2. * asteroid->mPhysicState->mRadius / mAsteroidSprite.GetWidth());
|
||||||
mAsteroidSprite.DrawAt(0., 0., 0.);
|
// mAsteroidSprite.DrawAt(0., 0., 0.);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glEnable (GL_LIGHTING);
|
||||||
|
glEnable (GL_LIGHT0);
|
||||||
|
|
||||||
|
glTranslatef (0., -1., 0.);
|
||||||
|
// glRotatef (90, 1., 0., 0.);
|
||||||
|
float scale = 1.8 * asteroid->mPhysicState->mRadius;
|
||||||
|
glScalef (scale, scale, scale);
|
||||||
|
DrawOBJModel (mAsteroidModel);
|
||||||
|
|
||||||
|
glDisable (GL_LIGHT0);
|
||||||
|
glDisable (GL_LIGHTING);
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
#ifdef DRAW_BOUNDARIES
|
#ifdef DRAW_BOUNDARIES
|
||||||
glColor3f (1., 1., 1.);
|
glColor3f (1., 1., 1.);
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class View : public Engine::ViewBase {
|
|||||||
|
|
||||||
/** \brief Updates the camera for further drawing */
|
/** \brief Updates the camera for further drawing */
|
||||||
virtual void UpdateCamera ();
|
virtual void UpdateCamera ();
|
||||||
|
virtual void Resize (int width, int height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawUi();
|
void DrawUi();
|
||||||
@@ -140,6 +141,8 @@ class View : public Engine::ViewBase {
|
|||||||
Engine::Sprite mShipThrustSprite;
|
Engine::Sprite mShipThrustSprite;
|
||||||
Engine::Sprite mShipPartsSprite;
|
Engine::Sprite mShipPartsSprite;
|
||||||
|
|
||||||
|
Engine::OBJModelPtr mAsteroidModel;
|
||||||
|
|
||||||
float screen_left;
|
float screen_left;
|
||||||
float screen_right;
|
float screen_right;
|
||||||
float screen_top;
|
float screen_top;
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ std::string find_game_data_dir () {
|
|||||||
paths.push_back("/usr/local/share/fysxasteroids");
|
paths.push_back("/usr/local/share/fysxasteroids");
|
||||||
paths.push_back("/usr/share/fysxasteroids");
|
paths.push_back("/usr/share/fysxasteroids");
|
||||||
|
|
||||||
std::vector<std::string>::iterator iter = paths.begin();
|
std::vector<std::string>::iterator iter;
|
||||||
for (iter; iter != paths.end(); iter++) {
|
for (iter = paths.begin(); iter != paths.end(); iter++) {
|
||||||
std::string test_path = *iter;
|
std::string test_path = *iter;
|
||||||
|
|
||||||
if (!boost::filesystem::is_directory(test_path + "/data/fonts"))
|
if (!boost::filesystem::is_directory(test_path + "/data/fonts"))
|
||||||
@@ -157,7 +157,6 @@ int main (int argc, char* argv[]) {
|
|||||||
Engine::SetMusicVolume (0.);
|
Engine::SetMusicVolume (0.);
|
||||||
|
|
||||||
// Load the icon
|
// Load the icon
|
||||||
Uint32 colorkey;
|
|
||||||
SDL_Surface *image = NULL;
|
SDL_Surface *image = NULL;
|
||||||
image = SDL_LoadBMP("./data/textures/icon.bmp");
|
image = SDL_LoadBMP("./data/textures/icon.bmp");
|
||||||
if (!image)
|
if (!image)
|
||||||
|
|||||||
+18
-6
@@ -116,10 +116,17 @@ int main (int argc, char* argv[]) {
|
|||||||
|
|
||||||
SetLogPrintLevel (Engine::LogLevelWarning);
|
SetLogPrintLevel (Engine::LogLevelWarning);
|
||||||
|
|
||||||
std::string user_path = ".";
|
// find the path for game data and user data
|
||||||
std::string game_data_path = ".";
|
std::string user_path = "";
|
||||||
|
std::string game_data_path = "";
|
||||||
|
|
||||||
|
// use the current path as default
|
||||||
|
boost::filesystem::path cpath = boost::filesystem::initial_path<boost::filesystem::path>();
|
||||||
|
user_path = boost::filesystem::path(cpath.string() + user_path).string();
|
||||||
|
game_data_path = boost::filesystem::path(cpath.string() + game_data_path).string();
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
// on linux et al we check more thoroughly at the possible directories
|
||||||
user_path = create_user_path();
|
user_path = create_user_path();
|
||||||
game_data_path = find_game_data_dir();
|
game_data_path = find_game_data_dir();
|
||||||
#endif
|
#endif
|
||||||
@@ -128,10 +135,12 @@ int main (int argc, char* argv[]) {
|
|||||||
std::string log_file_path = user_path;
|
std::string log_file_path = user_path;
|
||||||
log_file_path += "/game.log";
|
log_file_path += "/game.log";
|
||||||
|
|
||||||
|
log_file_path = boost::filesystem::path (log_file_path).string();
|
||||||
|
|
||||||
cout << "User Data Dir = " << user_path << endl;
|
cout << "User Data Dir = " << user_path << endl;
|
||||||
engine.SetUserDataPath (user_path);
|
engine.SetUserDataPath (user_path);
|
||||||
|
|
||||||
Engine::SetLogFilename (log_file_path.c_str());
|
Engine::SetLogFilename (log_file_path);
|
||||||
|
|
||||||
engine.SetGameDataPath (game_data_path);
|
engine.SetGameDataPath (game_data_path);
|
||||||
cout << "Game Data Dir = " << game_data_path << endl;
|
cout << "Game Data Dir = " << game_data_path << endl;
|
||||||
@@ -150,9 +159,9 @@ int main (int argc, char* argv[]) {
|
|||||||
else
|
else
|
||||||
SDL_WM_SetIcon(image,NULL);
|
SDL_WM_SetIcon(image,NULL);
|
||||||
|
|
||||||
SDL_WM_SetCaption("fysxasteroids -RC2-","fysxasteroids -RC2-");
|
std::string version_string = "fysxasteroids ";
|
||||||
|
version_string += FYSXASTEROIDS_VERSION;
|
||||||
engine.GetView()->SetGridSize (8,8);
|
SDL_WM_SetCaption(version_string.c_str(), version_string.c_str());
|
||||||
|
|
||||||
/// \todo get rid of the world settings in asteroids
|
/// \todo get rid of the world settings in asteroids
|
||||||
dynamic_cast<asteroids::Physics*>(engine.GetPhysics())->SetWorldSize (26, 20);
|
dynamic_cast<asteroids::Physics*>(engine.GetPhysics())->SetWorldSize (26, 20);
|
||||||
@@ -160,6 +169,9 @@ int main (int argc, char* argv[]) {
|
|||||||
engine.GetPhysics()->EnableWorldWarp(Engine::PhysicsBase::WorldWarpModeX);
|
engine.GetPhysics()->EnableWorldWarp(Engine::PhysicsBase::WorldWarpModeX);
|
||||||
engine.GetPhysics()->EnableWorldWarp(Engine::PhysicsBase::WorldWarpModeZ);
|
engine.GetPhysics()->EnableWorldWarp(Engine::PhysicsBase::WorldWarpModeZ);
|
||||||
|
|
||||||
|
engine.GetView()->SetGridSize (8,8);
|
||||||
|
engine.GetView()->Resize (800, 600);
|
||||||
|
|
||||||
// run the default commands and load the configuration
|
// run the default commands and load the configuration
|
||||||
Engine::RunCommand ("exec asteroids.rc");
|
Engine::RunCommand ("exec asteroids.rc");
|
||||||
Engine::RunCommand ("exec config.rc");
|
Engine::RunCommand ("exec config.rc");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Format
|
# Format
|
||||||
# <Type> <player?> <xpos> <ypos> <zpos> <zrot> <yrot> <xrot> <xvel> <yvel> <zvel> <rotvel>
|
# <Type> <player?> <xpos> <ypos> <zpos> <zrot> <yrot> <xrot> <xvel> <yvel> <zvel> <rotvel>
|
||||||
Title Where's the brain?
|
Title A little step for humankind
|
||||||
Author SirRandom
|
Author SirArmstrong
|
||||||
ParTime 20
|
ParTime 20
|
||||||
GameEntityTypeShip 1 0.253333 0 -1.14 0 90 0 0 0 0 0
|
GameEntityTypeShip 1 0.253333 0 -1.14 0 90 0 0 0 0 0
|
||||||
GameEntityTypeAsteroid 0 -10.45 0 -5.47833 0 0 0 4.05333 0 1.77333 31.3935
|
GameEntityTypeAsteroid 0 -10.45 0 -5.47833 0 0 0 4.05333 0 1.77333 31.3935
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Format
|
# Format
|
||||||
# <Type> <player?> <xpos> <ypos> <zpos> <zrot> <yrot> <xrot> <xvel> <yvel> <zvel> <rotvel>
|
# <Type> <player?> <xpos> <ypos> <zpos> <zrot> <yrot> <xrot> <xvel> <yvel> <zvel> <rotvel>
|
||||||
Title Don't drink and orbit alien pla
|
Title Don't drink and orbit alien planets
|
||||||
Author SirUnseen
|
Author SirUnseen
|
||||||
ParTime 31
|
ParTime 31
|
||||||
GameEntityTypeShip 1 10.3867 0 -7.63167 0 38.6598 0 7.41 0 -3.95833 0
|
GameEntityTypeShip 1 10.3867 0 -7.63167 0 38.6598 0 7.41 0 -3.95833 0
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
|||||||
|
# Material Count: 1
|
||||||
|
newmtl asteroid_asteroid_texture_full
|
||||||
|
Ns 37.254902
|
||||||
|
Ka 0.069978 0.069978 0.069978
|
||||||
|
Kd 0.640000 0.640000 0.640000
|
||||||
|
Ks 0.600000 0.600000 0.600000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
#map_Kd asteroid_texture_full.png
|
||||||
|
map_Kd asteroid_texture_solid.png
|
||||||
|
map_bump asteroid_normals_uv.png
|
||||||
Executable
+377
@@ -0,0 +1,377 @@
|
|||||||
|
# Blender v2.55 (sub 0) OBJ File: 'asteroidfull.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib asteroid_model.mtl
|
||||||
|
o Asteroid_Icosphere
|
||||||
|
v -1.783176 3.157423 -2.187264
|
||||||
|
v -0.623617 3.419646 -2.279537
|
||||||
|
v -4.136988 -1.528819 1.175240
|
||||||
|
v 1.622063 -3.012534 -1.107284
|
||||||
|
v -2.764359 2.370088 -1.340167
|
||||||
|
v 0.011242 3.019686 2.574161
|
||||||
|
v -3.271742 2.084863 -0.140242
|
||||||
|
v -1.924542 3.110817 -0.535404
|
||||||
|
v -3.428460 0.084386 1.434556
|
||||||
|
v -1.127657 -3.141940 1.362692
|
||||||
|
v -3.526288 1.205355 -1.042213
|
||||||
|
v -3.326865 -1.851120 -2.151031
|
||||||
|
v 3.315345 2.078610 0.192092
|
||||||
|
v 1.677497 2.826964 1.998395
|
||||||
|
v -3.488970 -0.830072 -2.166265
|
||||||
|
v 2.454325 -1.478905 -2.751490
|
||||||
|
v 0.892076 -2.198434 3.836253
|
||||||
|
v -0.529430 -1.099092 -4.090514
|
||||||
|
v -1.530568 2.367935 2.067323
|
||||||
|
v -0.082300 -2.695156 3.227212
|
||||||
|
v -4.186931 -0.713751 0.795901
|
||||||
|
v -3.847708 0.187925 -0.543515
|
||||||
|
v 2.213019 2.683415 -2.315270
|
||||||
|
v -3.271944 1.840718 0.932036
|
||||||
|
v 0.112475 -1.622629 4.020147
|
||||||
|
v -1.052165 1.693250 -4.113129
|
||||||
|
v -1.423264 -0.272173 -4.052314
|
||||||
|
v -2.335668 2.112422 -2.554989
|
||||||
|
v 1.706754 -3.029854 0.171139
|
||||||
|
v -2.704852 0.116766 -2.710793
|
||||||
|
v 3.689623 1.837504 -1.209753
|
||||||
|
v -1.948996 -3.023728 0.875353
|
||||||
|
v 3.308379 -0.730487 -2.346540
|
||||||
|
v -0.899223 -1.466655 3.453547
|
||||||
|
v 3.176398 -0.164593 2.544505
|
||||||
|
v 1.450483 3.221935 0.923732
|
||||||
|
v -2.242297 -2.166627 2.063739
|
||||||
|
v -1.472705 -1.333648 -3.420503
|
||||||
|
v 3.871596 0.740806 1.546153
|
||||||
|
v 2.533928 1.975883 1.930760
|
||||||
|
v 0.492799 2.513122 -3.092595
|
||||||
|
v -0.349212 3.148993 -0.029523
|
||||||
|
v 3.267344 1.184023 2.241151
|
||||||
|
v -4.353748 -1.612557 -0.495422
|
||||||
|
v -1.930530 1.654793 2.510300
|
||||||
|
v 0.573979 -0.844695 -4.044802
|
||||||
|
v 0.528275 -3.143214 -1.789249
|
||||||
|
v 3.692719 -1.577900 -1.071348
|
||||||
|
v 1.168138 1.079678 3.139852
|
||||||
|
v 3.753358 -0.623585 -0.108652
|
||||||
|
v 3.379341 -1.003592 1.838246
|
||||||
|
v -1.351585 2.874982 -3.067893
|
||||||
|
v 1.766429 -1.157478 3.728364
|
||||||
|
v 3.667178 1.594924 1.024512
|
||||||
|
v -0.884260 1.836161 2.998022
|
||||||
|
v -1.073378 -3.132030 -1.461949
|
||||||
|
v -0.467529 3.159610 1.532913
|
||||||
|
v 3.709228 0.144063 -1.087636
|
||||||
|
v 3.605958 -1.445132 -1.878629
|
||||||
|
v 2.660886 3.124851 -0.854361
|
||||||
|
v -0.436671 0.126434 -4.552140
|
||||||
|
v -2.266935 -2.809002 -1.819118
|
||||||
|
v -2.916038 -0.990559 1.868705
|
||||||
|
v 0.627561 3.215132 -1.810096
|
||||||
|
v 2.894693 -2.446815 -1.574007
|
||||||
|
v 0.482250 2.215932 3.057291
|
||||||
|
v 2.681753 1.396219 -2.708434
|
||||||
|
v 0.310227 -2.120141 -3.148356
|
||||||
|
v 3.060341 -1.967882 0.490186
|
||||||
|
v 1.224500 -2.950663 1.059580
|
||||||
|
v 3.238048 2.395264 -1.831406
|
||||||
|
v 2.981815 0.133216 -2.548208
|
||||||
|
v 3.870637 0.807691 -0.134255
|
||||||
|
v 0.576682 -3.072934 2.294799
|
||||||
|
v -0.354720 0.674670 3.589938
|
||||||
|
v 1.886084 -2.119545 3.151299
|
||||||
|
v -3.599368 -2.470988 0.392379
|
||||||
|
v 0.714642 0.489363 -4.151877
|
||||||
|
vt 0.962265 0.728057
|
||||||
|
vt 0.899626 0.745931
|
||||||
|
vt 0.929662 0.684568
|
||||||
|
vt 0.750291 0.839492
|
||||||
|
vt 0.789824 0.780340
|
||||||
|
vt 0.836636 0.898960
|
||||||
|
vt 0.197601 0.657079
|
||||||
|
vt 0.236349 0.516526
|
||||||
|
vt 0.295964 0.556306
|
||||||
|
vt 0.406744 0.084655
|
||||||
|
vt 0.437681 0.165538
|
||||||
|
vt 0.371831 0.150081
|
||||||
|
vt 0.937341 0.802735
|
||||||
|
vt 0.739755 0.637792
|
||||||
|
vt 0.713864 0.558013
|
||||||
|
vt 0.790163 0.605118
|
||||||
|
vt 0.466004 0.054740
|
||||||
|
vt 0.531386 0.156801
|
||||||
|
vt 0.407272 0.036392
|
||||||
|
vt 0.227384 0.053071
|
||||||
|
vt 0.204144 0.126771
|
||||||
|
vt 0.146542 0.125405
|
||||||
|
vt 0.861072 0.549518
|
||||||
|
vt 0.871220 0.610164
|
||||||
|
vt 0.540887 0.052625
|
||||||
|
vt 0.483144 0.379133
|
||||||
|
vt 0.531410 0.373100
|
||||||
|
vt 0.566293 0.430810
|
||||||
|
vt 0.066866 0.123562
|
||||||
|
vt 0.065190 0.224005
|
||||||
|
vt 0.002406 0.127618
|
||||||
|
vt 0.881327 0.854767
|
||||||
|
vt 0.500670 0.000000
|
||||||
|
vt 0.321590 0.676758
|
||||||
|
vt 0.371831 0.718807
|
||||||
|
vt 0.319555 0.758685
|
||||||
|
vt 0.885719 0.501947
|
||||||
|
vt 0.883607 0.391689
|
||||||
|
vt 0.934425 0.485845
|
||||||
|
vt 0.000000 0.251617
|
||||||
|
vt 0.741391 0.942675
|
||||||
|
vt 0.814392 0.974820
|
||||||
|
vt 0.777879 1.000000
|
||||||
|
vt 0.635861 0.539129
|
||||||
|
vt 0.561478 0.627398
|
||||||
|
vt 0.446596 0.581324
|
||||||
|
vt 0.695576 0.850029
|
||||||
|
vt 0.128100 0.635461
|
||||||
|
vt 0.141764 0.513552
|
||||||
|
vt 0.359817 0.484969
|
||||||
|
vt 0.371774 0.529646
|
||||||
|
vt 0.372111 0.218880
|
||||||
|
vt 0.062065 0.038661
|
||||||
|
vt 0.000031 0.066144
|
||||||
|
vt 0.752155 0.392965
|
||||||
|
vt 0.762496 0.520997
|
||||||
|
vt 0.699231 0.418395
|
||||||
|
vt 0.845722 0.651852
|
||||||
|
vt 0.741723 0.694331
|
||||||
|
vt 0.371831 0.596760
|
||||||
|
vt 0.426111 0.638510
|
||||||
|
vt 0.365584 0.589421
|
||||||
|
vt 0.395927 0.271007
|
||||||
|
vt 0.515240 0.285039
|
||||||
|
vt 0.501419 0.319046
|
||||||
|
vt 0.561706 0.232608
|
||||||
|
vt 0.118925 0.447635
|
||||||
|
vt 0.173827 0.444650
|
||||||
|
vt 0.066425 0.272682
|
||||||
|
vt 0.752460 0.638720
|
||||||
|
vt 0.864116 0.319046
|
||||||
|
vt 0.634457 0.598443
|
||||||
|
vt 0.643782 0.659783
|
||||||
|
vt 0.207013 0.293435
|
||||||
|
vt 0.808222 0.487833
|
||||||
|
vt 0.608847 0.000134
|
||||||
|
vt 0.695638 0.677489
|
||||||
|
vt 0.696948 0.736016
|
||||||
|
vt 0.157426 0.707879
|
||||||
|
vt 0.668226 0.056560
|
||||||
|
vt 0.671934 0.003912
|
||||||
|
vt 0.198776 0.481993
|
||||||
|
vt 0.273634 0.449727
|
||||||
|
vt 0.804622 0.216599
|
||||||
|
vt 0.791229 0.301115
|
||||||
|
vt 0.747758 0.249256
|
||||||
|
vt 0.721640 0.137550
|
||||||
|
vt 0.191523 0.354536
|
||||||
|
vt 0.820792 0.282262
|
||||||
|
vt 0.950867 0.369066
|
||||||
|
vt 0.324779 0.115257
|
||||||
|
vt 0.323095 0.062677
|
||||||
|
vt 0.695576 0.356821
|
||||||
|
vt 0.647322 0.164260
|
||||||
|
vt 0.005872 0.513634
|
||||||
|
vt 0.041462 0.548754
|
||||||
|
vt 0.006022 0.612097
|
||||||
|
vt 0.429869 0.368933
|
||||||
|
vt 0.426298 0.477853
|
||||||
|
vt 0.044569 0.356401
|
||||||
|
vt 0.330651 0.269674
|
||||||
|
vt 0.101029 0.677297
|
||||||
|
vt 0.075503 0.599948
|
||||||
|
vt 0.682265 0.212902
|
||||||
|
vt 0.721592 0.099681
|
||||||
|
vt 0.985494 0.451521
|
||||||
|
vt 0.944144 0.577592
|
||||||
|
vt 0.268275 0.230026
|
||||||
|
vt 0.265275 0.163033
|
||||||
|
vt 0.610146 0.272739
|
||||||
|
vt 1.000000 0.368928
|
||||||
|
vt 0.371831 0.160502
|
||||||
|
vt 0.294827 0.352889
|
||||||
|
vt 0.179156 0.406072
|
||||||
|
vt 0.695576 0.633236
|
||||||
|
vt 0.912297 0.560646
|
||||||
|
vt 0.068301 0.408852
|
||||||
|
vt 0.837648 0.638720
|
||||||
|
vt 0.183490 0.418129
|
||||||
|
vt 0.674900 0.548703
|
||||||
|
vt 0.360881 0.086504
|
||||||
|
vt 0.170343 0.000000
|
||||||
|
vt 0.499177 0.455094
|
||||||
|
vt 0.730293 0.321189
|
||||||
|
vt 0.945692 0.869305
|
||||||
|
vt 0.006033 0.668066
|
||||||
|
vt 0.005872 0.612097
|
||||||
|
vt 0.055275 0.612495
|
||||||
|
vt 0.953257 0.914727
|
||||||
|
vt 0.586418 0.354851
|
||||||
|
vt 0.666332 0.438154
|
||||||
|
vt 0.252839 0.408852
|
||||||
|
vt 0.328739 0.431163
|
||||||
|
vt 0.388098 0.659674
|
||||||
|
vt 0.000000 0.475701
|
||||||
|
vt 0.041462 0.408852
|
||||||
|
vt 0.041403 0.513634
|
||||||
|
vt 0.489351 0.319046
|
||||||
|
vt 0.721592 0.319046
|
||||||
|
vt 0.354845 0.326581
|
||||||
|
vt 0.240882 0.751040
|
||||||
|
usemtl asteroid_asteroid_normals_uv.p
|
||||||
|
s 1
|
||||||
|
f 1/1 28/2 52/3
|
||||||
|
f 15/4 30/5 22/6
|
||||||
|
f 78/7 72/8 67/9
|
||||||
|
f 1/10 8/11 5/12
|
||||||
|
f 1/1 5/13 28/2
|
||||||
|
f 48/14 69/15 50/16
|
||||||
|
f 2/17 42/18 8/11
|
||||||
|
f 8/11 1/10 2/17
|
||||||
|
f 2/17 1/10 52/19
|
||||||
|
f 69/20 29/21 70/22
|
||||||
|
f 50/16 39/23 73/24
|
||||||
|
f 2/17 64/25 42/18
|
||||||
|
f 3/26 21/27 9/28
|
||||||
|
f 74/29 10/30 20/31
|
||||||
|
f 30/5 28/2 11/32
|
||||||
|
f 41/33 64/25 2/17
|
||||||
|
f 41/34 2/35 52/36
|
||||||
|
f 43/37 49/38 40/39
|
||||||
|
f 37/40 20/31 10/30
|
||||||
|
f 44/41 21/42 3/43
|
||||||
|
f 45/44 75/45 34/46
|
||||||
|
f 12/47 30/5 15/4
|
||||||
|
f 46/48 16/49 72/8
|
||||||
|
f 72/8 31/50 71/51
|
||||||
|
f 5/12 8/11 7/52
|
||||||
|
f 45/44 34/46 9/28
|
||||||
|
f 30/5 11/32 22/6
|
||||||
|
f 76/53 74/29 17/54
|
||||||
|
f 53/55 51/56 76/57
|
||||||
|
f 26/58 28/2 30/5
|
||||||
|
f 51/56 50/16 69/15
|
||||||
|
f 46/48 72/8 78/7
|
||||||
|
f 26/58 30/5 27/59
|
||||||
|
f 10/30 74/29 70/22
|
||||||
|
f 20/60 34/46 25/61
|
||||||
|
f 67/9 23/62 41/34
|
||||||
|
f 24/63 19/64 45/65
|
||||||
|
f 53/55 49/38 43/37
|
||||||
|
f 76/53 69/20 70/22
|
||||||
|
f 24/63 7/52 8/11
|
||||||
|
f 24/63 8/11 57/66
|
||||||
|
f 24/63 57/66 19/64
|
||||||
|
f 65/67 59/68 16/49
|
||||||
|
f 32/69 37/40 10/30
|
||||||
|
f 26/58 27/59 61/70
|
||||||
|
f 53/55 75/71 49/38
|
||||||
|
f 8/11 42/18 57/66
|
||||||
|
f 75/45 55/72 66/73
|
||||||
|
f 10/30 70/22 56/74
|
||||||
|
f 35/75 43/37 39/23
|
||||||
|
f 76/53 70/22 74/29
|
||||||
|
f 23/76 64/25 41/33
|
||||||
|
f 27/59 18/77 61/70
|
||||||
|
f 12/47 38/78 30/5
|
||||||
|
f 46/48 78/7 61/79
|
||||||
|
f 60/80 64/25 23/76
|
||||||
|
f 60/80 23/76 71/81
|
||||||
|
f 33/82 59/68 58/83
|
||||||
|
f 33/82 58/83 72/8
|
||||||
|
f 72/8 71/51 67/9
|
||||||
|
f 60/84 31/85 13/86
|
||||||
|
f 35/75 39/23 51/56
|
||||||
|
f 60/84 13/86 36/87
|
||||||
|
f 62/88 32/69 56/74
|
||||||
|
f 51/56 39/23 50/16
|
||||||
|
f 60/84 71/89 31/85
|
||||||
|
f 75/71 66/90 49/38
|
||||||
|
f 65/91 29/21 69/20
|
||||||
|
f 65/91 69/20 48/92
|
||||||
|
f 53/55 76/57 17/93
|
||||||
|
f 36/94 42/18 64/25
|
||||||
|
f 36/94 64/25 60/80
|
||||||
|
f 13/95 54/96 40/97
|
||||||
|
f 77/98 3/26 37/99
|
||||||
|
f 77/100 37/40 32/69
|
||||||
|
f 68/101 62/88 56/74
|
||||||
|
f 77/100 32/69 62/88
|
||||||
|
f 18/102 68/103 46/48
|
||||||
|
f 44/41 22/6 21/42
|
||||||
|
f 14/104 36/94 13/105
|
||||||
|
f 14/106 13/107 40/39
|
||||||
|
f 78/7 67/9 41/34
|
||||||
|
f 47/108 29/21 4/109
|
||||||
|
f 14/104 6/110 36/94
|
||||||
|
f 27/59 38/78 18/77
|
||||||
|
f 47/108 56/74 70/22
|
||||||
|
f 47/108 70/22 29/21
|
||||||
|
f 66/90 6/111 14/106
|
||||||
|
f 66/90 14/106 40/39
|
||||||
|
f 66/90 40/39 49/38
|
||||||
|
f 65/91 16/112 68/101
|
||||||
|
f 36/94 6/110 57/66
|
||||||
|
f 36/94 57/66 42/18
|
||||||
|
f 45/44 55/72 75/45
|
||||||
|
f 68/101 38/113 62/88
|
||||||
|
f 65/91 68/101 47/108
|
||||||
|
f 77/100 62/88 12/114
|
||||||
|
f 66/73 55/72 6/115
|
||||||
|
f 54/116 39/23 43/37
|
||||||
|
f 16/49 59/68 33/82
|
||||||
|
f 37/99 34/46 20/60
|
||||||
|
f 77/100 12/114 44/117
|
||||||
|
f 53/55 43/37 35/75
|
||||||
|
f 48/14 50/16 58/118
|
||||||
|
f 48/119 58/83 59/68
|
||||||
|
f 6/115 55/72 19/120
|
||||||
|
f 6/110 19/64 57/66
|
||||||
|
f 54/116 43/37 40/39
|
||||||
|
f 25/61 34/46 75/45
|
||||||
|
f 62/88 38/113 12/114
|
||||||
|
f 65/91 48/92 59/121
|
||||||
|
f 76/53 51/122 69/20
|
||||||
|
f 9/28 34/46 63/123
|
||||||
|
f 19/120 55/72 45/44
|
||||||
|
f 65/91 47/108 4/109
|
||||||
|
f 63/123 34/46 37/99
|
||||||
|
f 16/49 33/82 72/8
|
||||||
|
f 47/108 68/101 56/74
|
||||||
|
f 3/26 9/28 63/123
|
||||||
|
f 53/55 35/75 51/56
|
||||||
|
f 3/26 63/123 37/99
|
||||||
|
f 74/29 20/31 17/54
|
||||||
|
f 53/55 25/124 75/71
|
||||||
|
f 11/32 28/2 5/13
|
||||||
|
f 11/32 5/13 7/125
|
||||||
|
f 73/126 54/127 13/128
|
||||||
|
f 22/6 11/32 7/125
|
||||||
|
f 22/6 7/125 24/129
|
||||||
|
f 22/130 24/131 9/28
|
||||||
|
f 50/132 73/133 58/83
|
||||||
|
f 20/60 25/61 17/134
|
||||||
|
f 44/41 15/4 22/6
|
||||||
|
f 72/8 58/83 31/50
|
||||||
|
f 65/91 4/109 29/21
|
||||||
|
f 53/55 17/93 25/124
|
||||||
|
f 31/50 58/83 73/133
|
||||||
|
f 21/135 22/136 9/137
|
||||||
|
f 10/30 56/74 32/69
|
||||||
|
f 67/9 71/51 23/62
|
||||||
|
f 77/98 44/138 3/26
|
||||||
|
f 27/59 30/5 38/78
|
||||||
|
f 31/85 73/139 13/86
|
||||||
|
f 68/101 18/140 38/113
|
||||||
|
f 24/131 45/44 9/28
|
||||||
|
f 73/24 39/23 54/116
|
||||||
|
f 26/141 61/79 78/7
|
||||||
|
f 26/141 78/7 41/34
|
||||||
|
f 44/41 12/47 15/4
|
||||||
|
f 26/141 41/34 52/36
|
||||||
|
f 46/48 68/103 16/49
|
||||||
|
f 18/102 46/48 61/79
|
||||||
|
f 26/58 52/3 28/2
|
||||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 786 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,63 @@
|
|||||||
|
Copyright (c) 2006-2007 dhpoware. All Rights Reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Per-fragment Blinn-Phong shader for a single directional light source.
|
||||||
|
|
||||||
|
[vert]
|
||||||
|
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
varying vec3 normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||||
|
|
||||||
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[frag]
|
||||||
|
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform sampler2D colorMap;
|
||||||
|
uniform float materialAlpha;
|
||||||
|
|
||||||
|
varying vec3 normal;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 n = normalize(normal);
|
||||||
|
|
||||||
|
float nDotL = max(0.0, dot(n, gl_LightSource[0].position.xyz));
|
||||||
|
float nDotH = max(0.0, dot(normal, vec3(gl_LightSource[0].halfVector)));
|
||||||
|
float power = (nDotL == 0.0) ? 0.0 : pow(nDotH, gl_FrontMaterial.shininess);
|
||||||
|
|
||||||
|
vec4 ambient = gl_FrontLightProduct[0].ambient;
|
||||||
|
vec4 diffuse = gl_FrontLightProduct[0].diffuse * nDotL;
|
||||||
|
vec4 specular = gl_FrontLightProduct[0].specular * power;
|
||||||
|
vec4 color = gl_FrontLightModelProduct.sceneColor + ambient + diffuse + specular;
|
||||||
|
|
||||||
|
gl_FragColor = color * texture2D(colorMap, gl_TexCoord[0].st);
|
||||||
|
gl_FragColor.a = materialAlpha;
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
Copyright (c) 2006-2007 dhpoware. All Rights Reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Tangent space normal mapping shader for a single directional light source.
|
||||||
|
|
||||||
|
The tangent vector is passed to the vertex shader in gl_MultiTexCoord1. The
|
||||||
|
tangent vector is assumed to be a four component vector. The tangent vector's
|
||||||
|
w component indicates the handedness of the local tangent space at this vertex.
|
||||||
|
The handedness is used to calculate the bitangent vector. The reason for the
|
||||||
|
inclusion of the handedness component is to allow for triangles with mirrored
|
||||||
|
texture mappings.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[vert]
|
||||||
|
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
varying vec3 lightDir;
|
||||||
|
varying vec3 halfVector;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||||
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||||
|
|
||||||
|
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
|
||||||
|
vec3 t = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz);
|
||||||
|
vec3 b = cross(n, t) * gl_MultiTexCoord1.w;
|
||||||
|
|
||||||
|
mat3 tbnMatrix = mat3(t.x, b.x, n.x,
|
||||||
|
t.y, b.y, n.y,
|
||||||
|
t.z, b.z, n.z);
|
||||||
|
|
||||||
|
lightDir = gl_LightSource[0].position.xyz;
|
||||||
|
lightDir = tbnMatrix * lightDir;
|
||||||
|
|
||||||
|
halfVector = gl_LightSource[0].halfVector.xyz;
|
||||||
|
halfVector = tbnMatrix * halfVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
[frag]
|
||||||
|
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform sampler2D colorMap;
|
||||||
|
uniform sampler2D normalMap;
|
||||||
|
uniform float materialAlpha;
|
||||||
|
|
||||||
|
varying vec3 lightDir;
|
||||||
|
varying vec3 halfVector;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 n = normalize(texture2D(normalMap, gl_TexCoord[0].st).rgb * 2.0 - 1.0);
|
||||||
|
vec3 l = normalize(lightDir);
|
||||||
|
vec3 h = normalize(halfVector);
|
||||||
|
|
||||||
|
float nDotL = max(0.0, dot(n, l));
|
||||||
|
float nDotH = max(0.0, dot(n, h));
|
||||||
|
float power = (nDotL == 0.0) ? 0.0 : pow(nDotH, gl_FrontMaterial.shininess);
|
||||||
|
|
||||||
|
vec4 ambient = gl_FrontLightProduct[0].ambient;
|
||||||
|
vec4 diffuse = gl_FrontLightProduct[0].diffuse * nDotL;
|
||||||
|
vec4 specular = gl_FrontLightProduct[0].specular * power;
|
||||||
|
vec4 color = gl_FrontLightModelProduct.sceneColor + ambient + diffuse + specular;
|
||||||
|
|
||||||
|
gl_FragColor = color * texture2D(colorMap, gl_TexCoord[0].st);
|
||||||
|
gl_FragColor.a = materialAlpha;
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -6,9 +6,10 @@ FIND_PACKAGE (SDL REQUIRED)
|
|||||||
FIND_PACKAGE (SDL_mixer REQUIRED)
|
FIND_PACKAGE (SDL_mixer REQUIRED)
|
||||||
FIND_PACKAGE (SDL_net REQUIRED)
|
FIND_PACKAGE (SDL_net REQUIRED)
|
||||||
FIND_PACKAGE (OpenGL REQUIRED)
|
FIND_PACKAGE (OpenGL REQUIRED)
|
||||||
|
FIND_PACKAGE (GLEW REQUIRED)
|
||||||
FIND_PACKAGE (PNG REQUIRED)
|
FIND_PACKAGE (PNG REQUIRED)
|
||||||
FIND_PACKAGE (FreeType2 REQUIRED)
|
FIND_PACKAGE (FreeType2 REQUIRED)
|
||||||
FIND_PACKAGE (Boost COMPONENTS filesystem REQUIRED)
|
FIND_PACKAGE (Boost COMPONENTS filesystem system REQUIRED)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY ( libraries )
|
ADD_SUBDIRECTORY ( libraries )
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ SET ( ENGINE_SRCS
|
|||||||
VariablesCommands.cc
|
VariablesCommands.cc
|
||||||
SimpleConsoleOverlay.cc
|
SimpleConsoleOverlay.cc
|
||||||
Sprite.cc
|
Sprite.cc
|
||||||
|
OBJModel.cc
|
||||||
IMGUIControls.cc
|
IMGUIControls.cc
|
||||||
|
|
||||||
Engine.cc
|
Engine.cc
|
||||||
@@ -51,6 +53,7 @@ INCLUDE_DIRECTORIES (
|
|||||||
libraries/oglft/liboglft
|
libraries/oglft/liboglft
|
||||||
libraries/sha2/
|
libraries/sha2/
|
||||||
${FREETYPE2_INCLUDE_DIR}
|
${FREETYPE2_INCLUDE_DIR}
|
||||||
|
${GLEW_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_LIBRARY ( Engine STATIC ${ENGINE_SRCS} )
|
ADD_LIBRARY ( Engine STATIC ${ENGINE_SRCS} )
|
||||||
@@ -60,6 +63,7 @@ TARGET_LINK_LIBRARIES ( Engine
|
|||||||
${SDLMIXER_LIBRARY}
|
${SDLMIXER_LIBRARY}
|
||||||
${SDLNET_LIBRARY}
|
${SDLNET_LIBRARY}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
|
${GLEW_LIBRARIES}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
mathlib
|
mathlib
|
||||||
|
|||||||
+1
-1
@@ -186,7 +186,7 @@ void CommandSetErrorString (const std::string &error_str){
|
|||||||
|
|
||||||
std::string CommandGetErrorString (){
|
std::string CommandGetErrorString (){
|
||||||
if (!CommandsInitialized ())
|
if (!CommandsInitialized ())
|
||||||
return false;
|
return std::string("");
|
||||||
|
|
||||||
return CommandsInstance->GetErrorString();
|
return CommandsInstance->GetErrorString();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -18,10 +18,16 @@
|
|||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
#include "EngineEnums.h"
|
#include "EngineEnums.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
// Note: glew.h must be included before any other OpenGL include file!
|
||||||
|
#include <glew.h>
|
||||||
|
|
||||||
// Some ugly #defines
|
// Some ugly #defines
|
||||||
|
|
||||||
/** \brief Defines the number of keys that can be defined for an EntityController
|
/** \brief Defines the number of keys that can be defined for an EntityController
|
||||||
@@ -115,13 +121,13 @@ class Engine : public Module {
|
|||||||
* \brief it
|
* \brief it
|
||||||
*/
|
*/
|
||||||
std::string GetResourceFullPath (const std::string &resource) {
|
std::string GetResourceFullPath (const std::string &resource) {
|
||||||
return mGameDataPath + resource;
|
return boost::filesystem::path(mGameDataPath + resource).string();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Returns the path to a file by prepending the user data path to it
|
/** \brief Returns the path to a file by prepending the user data path to it
|
||||||
*/
|
*/
|
||||||
std::string GetUserDirFullPath (const std::string &path) {
|
std::string GetUserDirFullPath (const std::string &path) {
|
||||||
return mUserDataPath + path;
|
return boost::filesystem::path(mUserDataPath + path).string();
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
+16
-2
@@ -13,17 +13,22 @@ bool EntityControllerState::GetKey (int state) {
|
|||||||
void EntityControllerState::SetKey (int state) {
|
void EntityControllerState::SetKey (int state) {
|
||||||
assert (state < EntityControllerMaxKeyStates && state >= 0);
|
assert (state < EntityControllerMaxKeyStates && state >= 0);
|
||||||
|
|
||||||
LogDebug ("Setting Entity Key State %d", state);
|
LogDebug ("Entity %d: Setting Entity Key State %d", mId, state);
|
||||||
mKeyState.set (state);
|
mKeyState.set (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityControllerState::UnsetKey (int state) {
|
void EntityControllerState::UnsetKey (int state) {
|
||||||
assert (state < EntityControllerMaxKeyStates && state >= 0);
|
assert (state < EntityControllerMaxKeyStates && state >= 0);
|
||||||
|
|
||||||
LogDebug ("Unsetting Entity Key State %d", state);
|
LogDebug ("Entity %d: Unsetting Entity Key State %d", mId, state);
|
||||||
mKeyState.reset (state);
|
mKeyState.reset (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityControllerState::Reset () {
|
||||||
|
LogDebug ("Entity %d: Resetting all key states", mId);
|
||||||
|
mKeyState.reset ();
|
||||||
|
}
|
||||||
|
|
||||||
void EntityBase::SetControllerKeyState (int state) {
|
void EntityBase::SetControllerKeyState (int state) {
|
||||||
if (!mControllerState) {
|
if (!mControllerState) {
|
||||||
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
||||||
@@ -40,4 +45,13 @@ void EntityBase::UnsetControllerKeyState (int state) {
|
|||||||
mControllerState->UnsetKey (state);
|
mControllerState->UnsetKey (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityBase::ResetControllerKeyState () {
|
||||||
|
if (!mControllerState) {
|
||||||
|
LogError ("Error when trying to send a KeyState to an Entity that has no EntityControllerState!");
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDebug ("Entity %d: Resetting key states", mId);
|
||||||
|
mControllerState->Reset ();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,11 +100,14 @@ struct EntityPhysicState {
|
|||||||
* \todo [Low] The current design is very unflexible. Is there a better way?
|
* \todo [Low] The current design is very unflexible. Is there a better way?
|
||||||
*/
|
*/
|
||||||
struct EntityControllerState {
|
struct EntityControllerState {
|
||||||
|
unsigned int mId;
|
||||||
|
|
||||||
std::bitset<EntityControllerMaxKeyStates> mKeyState;
|
std::bitset<EntityControllerMaxKeyStates> mKeyState;
|
||||||
|
|
||||||
bool GetKey (int state);
|
bool GetKey (int state);
|
||||||
void SetKey (int state);
|
void SetKey (int state);
|
||||||
void UnsetKey (int state);
|
void UnsetKey (int state);
|
||||||
|
void Reset ();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Represents the base of everything that exists in the engine
|
/** \brief Represents the base of everything that exists in the engine
|
||||||
@@ -131,6 +134,8 @@ struct EntityBase {
|
|||||||
virtual void SetControllerKeyState (int state);
|
virtual void SetControllerKeyState (int state);
|
||||||
/** \brief Removes the given state to the current movement state of the Entity */
|
/** \brief Removes the given state to the current movement state of the Entity */
|
||||||
virtual void UnsetControllerKeyState (int state);
|
virtual void UnsetControllerKeyState (int state);
|
||||||
|
/** \brief Resets all keys (i.e. no keys are pressed) */
|
||||||
|
virtual void ResetControllerKeyState ();
|
||||||
|
|
||||||
/** \brief Helper function to set the id to all substates */
|
/** \brief Helper function to set the id to all substates */
|
||||||
void SetId (unsigned int id) {
|
void SetId (unsigned int id) {
|
||||||
@@ -138,6 +143,8 @@ struct EntityBase {
|
|||||||
|
|
||||||
if (mPhysicState)
|
if (mPhysicState)
|
||||||
mPhysicState->mId = id;
|
mPhysicState->mId = id;
|
||||||
|
if (mControllerState)
|
||||||
|
mControllerState->mId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Executes game logic for the collision event
|
/** Executes game logic for the collision event
|
||||||
|
|||||||
+80
-75
@@ -33,8 +33,8 @@ bool regionhit (int x, int y, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrawBlock (int x, int y, int w, int h) {
|
void DrawBlock (int x, int y, int w, int h) {
|
||||||
const float shading_dark = 0.5;
|
const float shading_dark = 0.5f;
|
||||||
const float shading_light = 1.3;
|
// const float shading_light = 1.3f;
|
||||||
|
|
||||||
float color[4];
|
float color[4];
|
||||||
glGetFloatv (GL_CURRENT_COLOR, color);
|
glGetFloatv (GL_CURRENT_COLOR, color);
|
||||||
@@ -42,10 +42,10 @@ void DrawBlock (int x, int y, int w, int h) {
|
|||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
// middle part
|
// middle part
|
||||||
glVertex3f (x, y, 0.);
|
glVertex3i (x, y, 0);
|
||||||
glVertex3f (x, y + h, 0.);
|
glVertex3i (x, y + h, 0);
|
||||||
glVertex3f (x + w, y + h, 0.);
|
glVertex3i (x + w, y + h, 0);
|
||||||
glVertex3f (x + w, y, 0.);
|
glVertex3i (x + w, y, 0);
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
@@ -56,38 +56,38 @@ void DrawBlock (int x, int y, int w, int h) {
|
|||||||
glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark);
|
glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark);
|
||||||
|
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex3f (x,y + 2, 0.);
|
glVertex3i (x, y + 2, 0);
|
||||||
glVertex3f (x,y +h, 0.);
|
glVertex3i (x, y + h, 0);
|
||||||
glVertex3f (x + w - 2, y + h, 0.);
|
glVertex3i (x + w - 2, y + h, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawRoundedBlock (int x, int y, int w, int h) {
|
void DrawRoundedBlock (int x, int y, int w, int h) {
|
||||||
const int d = 16;
|
const int d = 16;
|
||||||
const float shading_dark = 0.5;
|
const float shading_dark = 0.5f;
|
||||||
const float shading_light = 1.3;
|
const float shading_light = 1.3f;
|
||||||
|
|
||||||
assert (h > d);
|
assert (h > d);
|
||||||
assert (w > d);
|
assert (w > d);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
// lower part
|
// lower part
|
||||||
glVertex3f (x, y, 0.);
|
glVertex3i (x, y, 0);
|
||||||
glVertex3f (x, y + d, 0.);
|
glVertex3i (x, y + d, 0);
|
||||||
glVertex3f (x + w, y + d, 0.);
|
glVertex3i (x + w, y + d, 0);
|
||||||
glVertex3f (x + w - d, y, 0.);
|
glVertex3i (x + w - d, y, 0);
|
||||||
|
|
||||||
// middle part
|
// middle part
|
||||||
glVertex3f (x, y + d, 0.);
|
glVertex3i (x, y + d, 0);
|
||||||
glVertex3f (x, y + d + h - 2 * d, 0.);
|
glVertex3i (x, y + d + h - 2 * d, 0);
|
||||||
glVertex3f (x + w, y + d + h - 2 * d, 0.);
|
glVertex3i (x + w, y + d + h - 2 * d, 0);
|
||||||
glVertex3f (x + w, y + d, 0.);
|
glVertex3i (x + w, y + d, 0);
|
||||||
|
|
||||||
// bottom part
|
// bottom part
|
||||||
glVertex3f (x, y + h - d, 0.);
|
glVertex3i (x, y + h - d, 0);
|
||||||
glVertex3f (x + d, y + h, 0.);
|
glVertex3i (x + d, y + h, 0);
|
||||||
glVertex3f (x + w, y + h, 0.);
|
glVertex3i (x + w, y + h, 0);
|
||||||
glVertex3f (x + w, y + h - d, 0.);
|
glVertex3i (x + w, y + h - d, 0);
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
@@ -99,16 +99,16 @@ void DrawRoundedBlock (int x, int y, int w, int h) {
|
|||||||
glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark);
|
glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark);
|
||||||
|
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex3f (x,y + 2, 0.);
|
glVertex3i (x,y + 2, 0);
|
||||||
glVertex3f (x,y + h -d, 0.);
|
glVertex3i (x,y + h - d, 0);
|
||||||
glVertex3f (x + d, y + h, 0.);
|
glVertex3i (x + d, y + h, 0);
|
||||||
glVertex3f (x + w - 2, y + h, 0.);
|
glVertex3i (x + w - 2, y + h, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glColor3f (color[0] * shading_light, color[1] * shading_light, color[2] * shading_light);
|
glColor3f (color[0] * shading_light, color[1] * shading_light, color[2] * shading_light);
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex3f (x + w - d, y, 0.);
|
glVertex3i (x + w - d, y, 0);
|
||||||
glVertex3f (x + w, y + d, 0.);
|
glVertex3i (x + w, y + d, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glColor4fv (color);
|
glColor4fv (color);
|
||||||
@@ -137,12 +137,12 @@ void Label (int id, const char* caption, int x, int y) {
|
|||||||
// we shift the gray a little left and up depending on the font size
|
// we shift the gray a little left and up depending on the font size
|
||||||
font_spec << "console.ttf size=" << font_size << " color=#808080";
|
font_spec << "console.ttf size=" << font_size << " color=#808080";
|
||||||
SelectFont(font_spec.str().c_str());
|
SelectFont(font_spec.str().c_str());
|
||||||
view->DrawGLString(x - font_size / 20.f , y + height * 0.5 + font_size / 20.f, caption);
|
view->DrawGLString(x - font_size / 20.f , y + height * 0.5f + font_size / 20.f, caption);
|
||||||
|
|
||||||
font_spec.str("");
|
font_spec.str("");
|
||||||
font_spec << "console.ttf size=" << font_size << " color=#ffffff";
|
font_spec << "console.ttf size=" << font_size << " color=#ffffff";
|
||||||
SelectFont(font_spec.str().c_str());
|
SelectFont(font_spec.str().c_str());
|
||||||
view->DrawGLString(x , y + height * 0.5, caption);
|
view->DrawGLString(x , y + height * 0.5f, caption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +171,12 @@ void LabelCentered (int id, const char* caption, int x, int y) {
|
|||||||
// we shift the gray a little left and up depending on the font size
|
// we shift the gray a little left and up depending on the font size
|
||||||
font_spec << "console.ttf size=" << font_size << " color=#808080";
|
font_spec << "console.ttf size=" << font_size << " color=#808080";
|
||||||
SelectFont(font_spec.str().c_str());
|
SelectFont(font_spec.str().c_str());
|
||||||
view->DrawGLString(x - 0.5 * width - font_size / 20.f , y + height * 0.5 + font_size / 20.f, caption);
|
view->DrawGLString(x - 0.5f * width - font_size / 20.f , y + height * 0.5f + font_size / 20.f, caption);
|
||||||
|
|
||||||
font_spec.str("");
|
font_spec.str("");
|
||||||
font_spec << "console.ttf size=" << font_size << " color=#ffffff";
|
font_spec << "console.ttf size=" << font_size << " color=#ffffff";
|
||||||
SelectFont(font_spec.str().c_str());
|
SelectFont(font_spec.str().c_str());
|
||||||
view->DrawGLString(x - 0.5 * width, y + height * 0.5, caption);
|
view->DrawGLString(x - 0.5f * width, y + height * 0.5f, caption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,20 +213,20 @@ bool Button (int id, const char* caption, int x, int y, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
glColor3f (0.2, 0.2, 0.2);
|
glColor3f (0.2f, 0.2f, 0.2f);
|
||||||
// DrawRoundedBlock (x + 4, y + 4, w, h);
|
// DrawRoundedBlock (x + 4, y + 4, w, h);
|
||||||
|
|
||||||
if (controller->uistate.hotitem == id
|
if (controller->uistate.hotitem == id
|
||||||
|| controller->uistate.kbditem == id) {
|
|| controller->uistate.kbditem == id) {
|
||||||
if (controller->uistate.activeitem == id) {
|
if (controller->uistate.activeitem == id) {
|
||||||
glColor3f (0.8, 0.8, 0.8);
|
glColor3f (0.8f, 0.8f, 0.8f);
|
||||||
DrawRoundedBlock (x, y, w, h);
|
DrawRoundedBlock (x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.7, 0.7, 0.7);
|
glColor3f (0.7f, 0.7f, 0.7f);
|
||||||
DrawRoundedBlock (x, y, w, h);
|
DrawRoundedBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4f, 0.4f, 0.4f);
|
||||||
DrawRoundedBlock (x, y, w, h);
|
DrawRoundedBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,18 +240,18 @@ bool Button (int id, const char* caption, int x, int y, int w, int h) {
|
|||||||
SelectFont("console.ttf size=23");
|
SelectFont("console.ttf size=23");
|
||||||
view->DrawGLStringMeasure(caption, &width, &height);
|
view->DrawGLStringMeasure(caption, &width, &height);
|
||||||
|
|
||||||
float xpos = x + w * 0.5 - width * 0.5;
|
float xpos = x + w * 0.5f - width * 0.5f;
|
||||||
float ypos = y + h * 0.5 - height * 0.5;
|
float ypos = y + h * 0.5f - height * 0.5f;
|
||||||
// LogDebug ("measure '%s' width = %f height = %f", caption, width, height);
|
// LogDebug ("measure '%s' width = %f height = %f", caption, width, height);
|
||||||
|
|
||||||
if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) {
|
if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) {
|
||||||
SelectFont("console.ttf size=23 color=#666666");
|
SelectFont("console.ttf size=23 color=#666666");
|
||||||
view->DrawGLString( xpos - 2., ypos + 2., caption);
|
view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
|
||||||
SelectFont("console.ttf size=23 color=#ffffff");
|
SelectFont("console.ttf size=23 color=#ffffff");
|
||||||
view->DrawGLString( xpos, ypos, caption);
|
view->DrawGLString( xpos, ypos, caption);
|
||||||
} else {
|
} else {
|
||||||
SelectFont("console.ttf size=23 color=#4d4d4d");
|
SelectFont("console.ttf size=23 color=#444444");
|
||||||
view->DrawGLString( xpos - 2., ypos + 2., caption);
|
view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
|
||||||
SelectFont("console.ttf size=23 color=#b3b3b3");
|
SelectFont("console.ttf size=23 color=#b3b3b3");
|
||||||
view->DrawGLString( xpos, ypos, caption);
|
view->DrawGLString( xpos, ypos, caption);
|
||||||
}
|
}
|
||||||
@@ -297,6 +297,8 @@ bool Button (int id, const char* caption, int x, int y, int w, int h) {
|
|||||||
controller->uistate.kbditem = 0;
|
controller->uistate.kbditem = 0;
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,23 +333,23 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
|
|||||||
|
|
||||||
// Render
|
// Render
|
||||||
if (checked) {
|
if (checked) {
|
||||||
glColor3f (0.91, 0.84, 0.);
|
glColor3f (0.91f, 0.84f, 0.);
|
||||||
DrawRoundedBlock (x - 2, y - 2, w + 4, h + 4);
|
DrawRoundedBlock (x - 2, y - 2, w + 4, h + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
glColor3f (0.2, 0.2, 0.2);
|
glColor3f (0.2f, 0.2f, 0.2f);
|
||||||
|
|
||||||
if (controller->uistate.hotitem == id
|
if (controller->uistate.hotitem == id
|
||||||
|| controller->uistate.kbditem == id) {
|
|| controller->uistate.kbditem == id) {
|
||||||
if (controller->uistate.activeitem == id) {
|
if (controller->uistate.activeitem == id) {
|
||||||
glColor3f (0.8, 0.8, 0.8);
|
glColor3f (0.8f, 0.8f, 0.8f);
|
||||||
DrawRoundedBlock (x, y, w, h);
|
DrawRoundedBlock (x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.7, 0.7, 0.7);
|
glColor3f (0.7f, 0.7f, 0.7f);
|
||||||
DrawRoundedBlock (x, y, w, h);
|
DrawRoundedBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4f, 0.4f, 0.4f);
|
||||||
DrawRoundedBlock (x, y, w, h);
|
DrawRoundedBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,18 +363,18 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
|
|||||||
SelectFont("console.ttf size=23");
|
SelectFont("console.ttf size=23");
|
||||||
view->DrawGLStringMeasure(caption, &width, &height);
|
view->DrawGLStringMeasure(caption, &width, &height);
|
||||||
|
|
||||||
float xpos = x + w * 0.5 - width * 0.5;
|
float xpos = x + w * 0.5f - width * 0.5f;
|
||||||
float ypos = y + h * 0.5 - height * 0.5;
|
float ypos = y + h * 0.5f - height * 0.5f;
|
||||||
// LogDebug ("measure '%s' width = %f height = %f", caption, width, height);
|
// LogDebug ("measure '%s' width = %f height = %f", caption, width, height);
|
||||||
|
|
||||||
if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) {
|
if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) {
|
||||||
SelectFont("console.ttf size=23 color=#666666");
|
SelectFont("console.ttf size=23 color=#666666");
|
||||||
view->DrawGLString( xpos - 2., ypos + 2., caption);
|
view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
|
||||||
SelectFont("console.ttf size=23 color=#ffffff");
|
SelectFont("console.ttf size=23 color=#ffffff");
|
||||||
view->DrawGLString( xpos, ypos, caption);
|
view->DrawGLString( xpos, ypos, caption);
|
||||||
} else {
|
} else {
|
||||||
SelectFont("console.ttf size=23 color=#4d4d4d");
|
SelectFont("console.ttf size=23 color=#444444");
|
||||||
view->DrawGLString( xpos - 2., ypos + 2., caption);
|
view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
|
||||||
SelectFont("console.ttf size=23 color=#b3b3b3");
|
SelectFont("console.ttf size=23 color=#b3b3b3");
|
||||||
view->DrawGLString( xpos, ypos, caption);
|
view->DrawGLString( xpos, ypos, caption);
|
||||||
}
|
}
|
||||||
@@ -418,6 +420,8 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,14 +469,14 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
|||||||
// If we have keyboard focus, we highlight the widget
|
// If we have keyboard focus, we highlight the widget
|
||||||
if ( controller->uistate.kbditem == id) {
|
if ( controller->uistate.kbditem == id) {
|
||||||
if (controller->uistate.activeitem == id) {
|
if (controller->uistate.activeitem == id) {
|
||||||
glColor3f (0.8, 0.8, 0.8);
|
glColor3f (0.8f, 0.8f, 0.8f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.7, 0.7, 0.7);
|
glColor3f (0.7f, 0.7f, 0.7f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4f, 0.4f, 0.4f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,7 +485,7 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
|||||||
view = EngineGetView ();
|
view = EngineGetView ();
|
||||||
assert (view);
|
assert (view);
|
||||||
|
|
||||||
glColor3f (1., 1., 1.);
|
glColor3f (1.f, 1.f, 1.f);
|
||||||
|
|
||||||
std::string text_output = text_value;
|
std::string text_output = text_value;
|
||||||
|
|
||||||
@@ -541,7 +545,7 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// The raw input processing
|
// The raw input processing
|
||||||
if (maxlength > 0 && text_value.size() < maxlength) {
|
if (maxlength > 0 && static_cast<int>(text_value.size()) < maxlength) {
|
||||||
if (controller->uistate.last_unicode) {
|
if (controller->uistate.last_unicode) {
|
||||||
if ((controller->uistate.last_unicode & 0xFF80) == 0) {
|
if ((controller->uistate.last_unicode & 0xFF80) == 0) {
|
||||||
// we do not want to add special characters such as backspaces
|
// we do not want to add special characters such as backspaces
|
||||||
@@ -605,14 +609,14 @@ bool LineEditMasked (int id, int x, int y, std::string &text_value, const int &m
|
|||||||
// If we have keyboard focus, we highlight the widget
|
// If we have keyboard focus, we highlight the widget
|
||||||
if ( controller->uistate.kbditem == id) {
|
if ( controller->uistate.kbditem == id) {
|
||||||
if (controller->uistate.activeitem == id) {
|
if (controller->uistate.activeitem == id) {
|
||||||
glColor3f (0.8, 0.8, 0.8);
|
glColor3f (0.8f, 0.8f, 0.8f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.7, 0.7, 0.7);
|
glColor3f (0.7f, 0.7f, 0.7f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4f, 0.4f, 0.4f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,7 +625,7 @@ bool LineEditMasked (int id, int x, int y, std::string &text_value, const int &m
|
|||||||
view = EngineGetView ();
|
view = EngineGetView ();
|
||||||
assert (view);
|
assert (view);
|
||||||
|
|
||||||
glColor3f (1., 1., 1.);
|
glColor3f (1.f, 1.f, 1.f);
|
||||||
|
|
||||||
std::string text_output = text_value;
|
std::string text_output = text_value;
|
||||||
|
|
||||||
@@ -681,7 +685,7 @@ bool LineEditMasked (int id, int x, int y, std::string &text_value, const int &m
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// The raw input processing
|
// The raw input processing
|
||||||
if (maxlength > 0 && text_value.size() < maxlength) {
|
if (maxlength > 0 && static_cast<int>(text_value.size()) < maxlength) {
|
||||||
if (controller->uistate.last_unicode) {
|
if (controller->uistate.last_unicode) {
|
||||||
if ((controller->uistate.last_unicode & 0xFF80) == 0) {
|
if ((controller->uistate.last_unicode & 0xFF80) == 0) {
|
||||||
char c = controller->uistate.last_unicode & 0x7F;
|
char c = controller->uistate.last_unicode & 0x7F;
|
||||||
@@ -725,7 +729,7 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
|
|||||||
int slider_pos = (w * value) / max_value - knob_width / 2;
|
int slider_pos = (w * value) / max_value - knob_width / 2;
|
||||||
|
|
||||||
// Check for hotness
|
// Check for hotness
|
||||||
if (regionhit (x, y + h * 0.5 - knob_height * 0.5, w, knob_height)) {
|
if (regionhit (x, y + h * 0.5f - knob_height * 0.5f, w, knob_height)) {
|
||||||
controller->uistate.hotitem = id;
|
controller->uistate.hotitem = id;
|
||||||
if (controller->uistate.activeitem == 0
|
if (controller->uistate.activeitem == 0
|
||||||
&& controller->GetButtonState(MouseButtonLeft)) {
|
&& controller->GetButtonState(MouseButtonLeft)) {
|
||||||
@@ -746,21 +750,21 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
|
|||||||
// If we have keyboard focus, we highlight the widget
|
// If we have keyboard focus, we highlight the widget
|
||||||
if ( controller->uistate.kbditem == id) {
|
if ( controller->uistate.kbditem == id) {
|
||||||
if (controller->uistate.activeitem == id) {
|
if (controller->uistate.activeitem == id) {
|
||||||
glColor3f (0.6, 0.6, 0.6);
|
glColor3f (0.6f, 0.6f, 0.6f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
glColor3f (0.8, 0.8, 0.8);
|
glColor3f (0.8f, 0.8f, 0.8f);
|
||||||
DrawBlock (x + slider_pos, y + h * 0.5 - knob_height * 0.5, knob_width, knob_height);
|
DrawBlock (x + slider_pos, y + h * 0.5f - knob_height * 0.5f, knob_width, knob_height);
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.6, 0.6, 0.6);
|
glColor3f (0.6f, 0.6f, 0.6f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
glColor3f (0.7, 0.7, 0.7);
|
glColor3f (0.7f, 0.7f, 0.7f);
|
||||||
DrawBlock (x + slider_pos, y + h * 0.5 - knob_height * 0.5, knob_width, knob_height);
|
DrawBlock (x + slider_pos, y + h * 0.5f - knob_height * 0.5f, knob_width, knob_height);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
glColor3f (0.4, 0.4, 0.4);
|
glColor3f (0.4f, 0.4f, 0.4f);
|
||||||
DrawBlock (x, y, w, h);
|
DrawBlock (x, y, w, h);
|
||||||
glColor3f (0.5, 0.5, 0.5);
|
glColor3f (0.5f, 0.5f, 0.5f);
|
||||||
DrawBlock (x + slider_pos, y + h * 0.5 - knob_height * 0.5, knob_width, knob_height);
|
DrawBlock (x + slider_pos, y + h * 0.5f - knob_height * 0.5f, knob_width, knob_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller->uistate.kbditem == id) {
|
if (controller->uistate.kbditem == id) {
|
||||||
@@ -776,19 +780,21 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
|
|||||||
controller->uistate.last_keysym = SDLK_CLEAR;
|
controller->uistate.last_keysym = SDLK_CLEAR;
|
||||||
break;
|
break;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
value -= (max_value - min_value) * 0.1;
|
value -= (max_value - min_value) * 0.1f;
|
||||||
if ( value < min_value)
|
if ( value < min_value)
|
||||||
value = min_value;
|
value = min_value;
|
||||||
controller->uistate.last_keysym = SDLK_CLEAR;
|
controller->uistate.last_keysym = SDLK_CLEAR;
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
value += (max_value - min_value) * 0.1;
|
value += (max_value - min_value) * 0.1f;
|
||||||
if ( value > max_value)
|
if ( value > max_value)
|
||||||
value = max_value;
|
value = max_value;
|
||||||
controller->uistate.last_keysym = SDLK_CLEAR;
|
controller->uistate.last_keysym = SDLK_CLEAR;
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -831,6 +837,5 @@ bool CheckKeyPressed (int keycode) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-4
@@ -90,11 +90,11 @@ void Logging::SetLogPrintLevel (LogLevel print_level) {
|
|||||||
mPrintLevel = print_level;
|
mPrintLevel = print_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logging::SetLogFilename (const char *filename) {
|
void Logging::SetLogFilename (const std::string &filename) {
|
||||||
mLogFileOut.open (filename, std::ios_base::trunc);
|
mLogFileOut.open (filename.c_str(), std::ios_base::trunc);
|
||||||
|
|
||||||
if (!mLogFileOut) {
|
if (!mLogFileOut) {
|
||||||
LogError ("Could not open logfile %s for writing!", filename);
|
LogError ("Could not open logfile %s for writing!", filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
requested_logfilename = "";
|
requested_logfilename = "";
|
||||||
@@ -122,7 +122,7 @@ void SetLogPrintLevel (LogLevel print_level) {
|
|||||||
LoggingInstance->SetLogPrintLevel (print_level);
|
LoggingInstance->SetLogPrintLevel (print_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLogFilename (const char *filename) {
|
void SetLogFilename (const std::string &filename) {
|
||||||
if (!LoggingInstance) {
|
if (!LoggingInstance) {
|
||||||
requested_logfilename = filename;
|
requested_logfilename = filename;
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ class Logging : public Module {
|
|||||||
public:
|
public:
|
||||||
void Log (LogLevel level, const char *str, ...);
|
void Log (LogLevel level, const char *str, ...);
|
||||||
void SetLogPrintLevel (LogLevel print_level);
|
void SetLogPrintLevel (LogLevel print_level);
|
||||||
void SetLogFilename (const char *filename);
|
void SetLogFilename (const std::string &filename);
|
||||||
/** \brief Returns the last LogEntry that was sent to the Logging module
|
/** \brief Returns the last LogEntry that was sent to the Logging module
|
||||||
*/
|
*/
|
||||||
const LogEntry& GetLastEntry ();
|
const LogEntry& GetLastEntry ();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct LogEntry {
|
|||||||
/** \brief Sets the level for which messages should be printed out */
|
/** \brief Sets the level for which messages should be printed out */
|
||||||
void SetLogPrintLevel (LogLevel print_level);
|
void SetLogPrintLevel (LogLevel print_level);
|
||||||
/** \brief Sets the filename to which all the logging is sent, set to NULL to disable logging */
|
/** \brief Sets the filename to which all the logging is sent, set to NULL to disable logging */
|
||||||
void SetLogFilename (const char *filename);
|
void SetLogFilename (const std::string &filename);
|
||||||
|
|
||||||
/** \brief Sends the Message to the Logging system
|
/** \brief Sends the Message to the Logging system
|
||||||
*
|
*
|
||||||
|
|||||||
+1294
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,244 @@
|
|||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2007 dhpoware. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _OBJMODEL_H
|
||||||
|
#define _OBJMODEL_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Alias|Wavefront OBJ file loader.
|
||||||
|
//
|
||||||
|
// This OBJ file loader contains the following restrictions:
|
||||||
|
// 1. Group information is ignored. Faces are grouped based on the material
|
||||||
|
// that each face uses.
|
||||||
|
// 2. Object information is ignored. This loader will merge everything into a
|
||||||
|
// single object.
|
||||||
|
// 3. The MTL file must be located in the same directory as the OBJ file. If
|
||||||
|
// it isn't then the MTL file will fail to load and a default material is
|
||||||
|
// used instead.
|
||||||
|
// 4. This loader triangulates all polygonal faces during importing.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Engine {
|
||||||
|
|
||||||
|
class OBJModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct Material
|
||||||
|
{
|
||||||
|
float ambient[4];
|
||||||
|
float diffuse[4];
|
||||||
|
float specular[4];
|
||||||
|
float shininess; // [0 = min shininess, 1 = max shininess]
|
||||||
|
float alpha; // [0 = fully transparent, 1 = fully opaque]
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
std::string colorMapFilename;
|
||||||
|
std::string bumpMapFilename;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
|
float position[3];
|
||||||
|
float texCoord[2];
|
||||||
|
float normal[3];
|
||||||
|
float tangent[4];
|
||||||
|
float bitangent[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Mesh
|
||||||
|
{
|
||||||
|
int startIndex;
|
||||||
|
int triangleCount;
|
||||||
|
const Material *pMaterial;
|
||||||
|
};
|
||||||
|
|
||||||
|
OBJModel();
|
||||||
|
~OBJModel();
|
||||||
|
|
||||||
|
void destroy();
|
||||||
|
bool import(const char *pszFilename, bool rebuildNormals = false);
|
||||||
|
void normalize(float scaleTo = 1.0f, bool center = true);
|
||||||
|
void reverseWinding();
|
||||||
|
|
||||||
|
// Getter methods.
|
||||||
|
|
||||||
|
void getCenter(float &x, float &y, float &z) const;
|
||||||
|
float getWidth() const;
|
||||||
|
float getHeight() const;
|
||||||
|
float getLength() const;
|
||||||
|
float getRadius() const;
|
||||||
|
|
||||||
|
const int *getIndexBuffer() const;
|
||||||
|
int getIndexSize() const;
|
||||||
|
|
||||||
|
const Material &getMaterial(int i) const;
|
||||||
|
const Mesh &getMesh(int i) const;
|
||||||
|
|
||||||
|
int getNumberOfIndices() const;
|
||||||
|
int getNumberOfMaterials() const;
|
||||||
|
int getNumberOfMeshes() const;
|
||||||
|
int getNumberOfTriangles() const;
|
||||||
|
int getNumberOfVertices() const;
|
||||||
|
|
||||||
|
const std::string &getPath() const;
|
||||||
|
|
||||||
|
const Vertex &getVertex(int i) const;
|
||||||
|
const Vertex *getVertexBuffer() const;
|
||||||
|
int getVertexSize() const;
|
||||||
|
|
||||||
|
bool hasNormals() const;
|
||||||
|
bool hasPositions() const;
|
||||||
|
bool hasTangents() const;
|
||||||
|
bool hasTextureCoords() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void addTrianglePos(int index, int material,
|
||||||
|
int v0, int v1, int v2);
|
||||||
|
void addTrianglePosNormal(int index, int material,
|
||||||
|
int v0, int v1, int v2,
|
||||||
|
int vn0, int vn1, int vn2);
|
||||||
|
void addTrianglePosTexCoord(int index, int material,
|
||||||
|
int v0, int v1, int v2,
|
||||||
|
int vt0, int vt1, int vt2);
|
||||||
|
void addTrianglePosTexCoordNormal(int index, int material,
|
||||||
|
int v0, int v1, int v2,
|
||||||
|
int vt0, int vt1, int vt2,
|
||||||
|
int vn0, int vn1, int vn2);
|
||||||
|
int addVertex(int hash, const Vertex *pVertex);
|
||||||
|
void bounds(float center[3], float &width, float &height,
|
||||||
|
float &length, float &radius) const;
|
||||||
|
void buildMeshes();
|
||||||
|
void generateNormals();
|
||||||
|
void generateTangents();
|
||||||
|
void importGeometryFirstPass(FILE *pFile);
|
||||||
|
void importGeometrySecondPass(FILE *pFile);
|
||||||
|
bool importMaterials(const char *pszFilename);
|
||||||
|
void scale(float scaleFactor, float offset[3]);
|
||||||
|
|
||||||
|
bool m_hasPositions;
|
||||||
|
bool m_hasTextureCoords;
|
||||||
|
bool m_hasNormals;
|
||||||
|
bool m_hasTangents;
|
||||||
|
|
||||||
|
int m_numberOfVertexCoords;
|
||||||
|
int m_numberOfTextureCoords;
|
||||||
|
int m_numberOfNormals;
|
||||||
|
int m_numberOfTriangles;
|
||||||
|
int m_numberOfMaterials;
|
||||||
|
int m_numberOfMeshes;
|
||||||
|
|
||||||
|
float m_center[3];
|
||||||
|
float m_width;
|
||||||
|
float m_height;
|
||||||
|
float m_length;
|
||||||
|
float m_radius;
|
||||||
|
|
||||||
|
std::string m_directoryPath;
|
||||||
|
|
||||||
|
std::vector<Mesh> m_meshes;
|
||||||
|
std::vector<Material> m_materials;
|
||||||
|
std::vector<Vertex> m_vertexBuffer;
|
||||||
|
std::vector<int> m_indexBuffer;
|
||||||
|
std::vector<int> m_attributeBuffer;
|
||||||
|
std::vector<float> m_vertexCoords;
|
||||||
|
std::vector<float> m_textureCoords;
|
||||||
|
std::vector<float> m_normals;
|
||||||
|
|
||||||
|
std::map<std::string, int> m_materialCache;
|
||||||
|
std::map<int, std::vector<int> > m_vertexCache;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
inline void OBJModel::getCenter(float &x, float &y, float &z) const
|
||||||
|
{ x = m_center[0]; y = m_center[1]; z = m_center[2]; }
|
||||||
|
|
||||||
|
inline float OBJModel::getWidth() const
|
||||||
|
{ return m_width; }
|
||||||
|
|
||||||
|
inline float OBJModel::getHeight() const
|
||||||
|
{ return m_height; }
|
||||||
|
|
||||||
|
inline float OBJModel::getLength() const
|
||||||
|
{ return m_length; }
|
||||||
|
|
||||||
|
inline float OBJModel::getRadius() const
|
||||||
|
{ return m_radius; }
|
||||||
|
|
||||||
|
inline const int *OBJModel::getIndexBuffer() const
|
||||||
|
{ return &m_indexBuffer[0]; }
|
||||||
|
|
||||||
|
inline int OBJModel::getIndexSize() const
|
||||||
|
{ return static_cast<int>(sizeof(int)); }
|
||||||
|
|
||||||
|
inline const OBJModel::Material &OBJModel::getMaterial(int i) const
|
||||||
|
{ return m_materials[i]; }
|
||||||
|
|
||||||
|
inline const OBJModel::Mesh &OBJModel::getMesh(int i) const
|
||||||
|
{ return m_meshes[i]; }
|
||||||
|
|
||||||
|
inline int OBJModel::getNumberOfIndices() const
|
||||||
|
{ return m_numberOfTriangles * 3; }
|
||||||
|
|
||||||
|
inline int OBJModel::getNumberOfMaterials() const
|
||||||
|
{ return m_numberOfMaterials; }
|
||||||
|
|
||||||
|
inline int OBJModel::getNumberOfMeshes() const
|
||||||
|
{ return m_numberOfMeshes; }
|
||||||
|
|
||||||
|
inline int OBJModel::getNumberOfTriangles() const
|
||||||
|
{ return m_numberOfTriangles; }
|
||||||
|
|
||||||
|
inline int OBJModel::getNumberOfVertices() const
|
||||||
|
{ return static_cast<int>(m_vertexBuffer.size()); }
|
||||||
|
|
||||||
|
inline const std::string &OBJModel::getPath() const
|
||||||
|
{ return m_directoryPath; }
|
||||||
|
|
||||||
|
inline const OBJModel::Vertex &OBJModel::getVertex(int i) const
|
||||||
|
{ return m_vertexBuffer[i]; }
|
||||||
|
|
||||||
|
inline const OBJModel::Vertex *OBJModel::getVertexBuffer() const
|
||||||
|
{ return &m_vertexBuffer[0]; }
|
||||||
|
|
||||||
|
inline int OBJModel::getVertexSize() const
|
||||||
|
{ return static_cast<int>(sizeof(Vertex)); }
|
||||||
|
|
||||||
|
inline bool OBJModel::hasNormals() const
|
||||||
|
{ return m_hasNormals; }
|
||||||
|
|
||||||
|
inline bool OBJModel::hasPositions() const
|
||||||
|
{ return m_hasPositions; }
|
||||||
|
|
||||||
|
inline bool OBJModel::hasTangents() const
|
||||||
|
{ return m_hasTangents; }
|
||||||
|
|
||||||
|
inline bool OBJModel::hasTextureCoords() const
|
||||||
|
{ return m_hasTextureCoords; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-2
@@ -11,8 +11,8 @@ class Module;
|
|||||||
class SoundSample {
|
class SoundSample {
|
||||||
public:
|
public:
|
||||||
SoundSample() :
|
SoundSample() :
|
||||||
mMixChunk (NULL),
|
mChannel (-1),
|
||||||
mChannel (-1) {
|
mMixChunk (NULL) {
|
||||||
}
|
}
|
||||||
~SoundSample();
|
~SoundSample();
|
||||||
|
|
||||||
|
|||||||
+28
-21
@@ -125,8 +125,8 @@ bool Sprite::LoadFromPNG (const std::string &filename) {
|
|||||||
png_read_image(png_ptr, row_pointers);
|
png_read_image(png_ptr, row_pointers);
|
||||||
|
|
||||||
//Now generate the OpenGL texture object
|
//Now generate the OpenGL texture object
|
||||||
glGenTextures(1, &mGlTextureName);
|
glGenTextures(1, &mGLTextureName);
|
||||||
glBindTexture(GL_TEXTURE_2D, mGlTextureName);
|
glBindTexture(GL_TEXTURE_2D, mGLTextureName);
|
||||||
|
|
||||||
bool mipmap = false;
|
bool mipmap = false;
|
||||||
|
|
||||||
@@ -151,6 +151,25 @@ bool Sprite::LoadFromPNG (const std::string &filename) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_sprite_helper (float u_start, float u_end, float width, float height) {
|
||||||
|
/*
|
||||||
|
// debug drawing with colors
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f (u_start, 0.f); glColor3f (1.f, 0.f, 0.f); glVertex3f (0.f, 0.f, 0.f);
|
||||||
|
glTexCoord2f (u_end, 0.f); glColor3f (0.f, 1.f, 0.f); glVertex3f (0.f, 0.f, height);
|
||||||
|
glTexCoord2f (u_end, 1.f); glColor3f (0.f, 0.f, 1.f); glVertex3f (width, 0.f, height);
|
||||||
|
glTexCoord2f (u_start, 1.f); glColor3f (1.f, 0.f, 1.f); glVertex3f (width, 0.f,0.f);
|
||||||
|
glEnd();
|
||||||
|
*/
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f (u_start, 0.f); glVertex3f (0.f, 0.f, 0.f);
|
||||||
|
glTexCoord2f (u_end, 0.f); glVertex3f (0.f, 0.f, height);
|
||||||
|
glTexCoord2f (u_end, 1.f); glVertex3f (width, 0.f, height);
|
||||||
|
glTexCoord2f (u_start, 1.f); glVertex3f (width, 0.f,0.f);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
void Sprite::DrawAt (float xpos, float ypos, float zpos) {
|
void Sprite::DrawAt (float xpos, float ypos, float zpos) {
|
||||||
float u_start = 0., u_end = 1.;
|
float u_start = 0., u_end = 1.;
|
||||||
if (mAnimation) {
|
if (mAnimation) {
|
||||||
@@ -167,14 +186,9 @@ void Sprite::DrawAt (float xpos, float ypos, float zpos) {
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, mGlTextureName);
|
glBindTexture (GL_TEXTURE_2D, mGLTextureName);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
draw_sprite_helper (u_start, u_end, mWidth, mHeight);
|
||||||
glTexCoord2f (u_start, 0.); glVertex3f (0., 0., 0.);
|
|
||||||
glTexCoord2f (u_end, 0.); glVertex3f (0., 0., mHeight);
|
|
||||||
glTexCoord2f (u_end, 1.); glVertex3f (mWidth, 0., mHeight);
|
|
||||||
glTexCoord2f (u_start, 1.); glVertex3f (mWidth, 0.,0.);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
@@ -200,15 +214,13 @@ void Sprite::DrawAt2D (float xpos, float ypos) {
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, mGlTextureName);
|
glBindTexture (GL_TEXTURE_2D, mGLTextureName);
|
||||||
|
glBegin (GL_QUADS);
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2f (u_start, 0.); glVertex2f (0., 0.);
|
glTexCoord2f (u_start, 0.); glVertex2f (0., 0.);
|
||||||
glTexCoord2f (u_end, 0.); glVertex2f (0., mHeight);
|
glTexCoord2f (u_end, 0.); glVertex2f (0., mHeight);
|
||||||
glTexCoord2f (u_end, 1.); glVertex2f (mWidth, mHeight);
|
glTexCoord2f (u_end, 1.); glVertex2f (mWidth, mHeight);
|
||||||
glTexCoord2f (u_start, 1.); glVertex2f (mWidth,0.);
|
glTexCoord2f (u_start, 1.); glVertex2f (mWidth,0.);
|
||||||
glEnd();
|
glEnd ();
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
@@ -229,14 +241,9 @@ void Sprite::DrawSubAt (unsigned int index, float xpos, float ypos, float zpos)
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_2D, mGlTextureName);
|
glBindTexture (GL_TEXTURE_2D, mGLTextureName);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
draw_sprite_helper (u_start, u_end, mWidth, mHeight);
|
||||||
glTexCoord2f (u_start, 0.); glVertex3f (0., 0., 0.);
|
|
||||||
glTexCoord2f (u_end, 0.); glVertex3f (0., 0., mHeight);
|
|
||||||
glTexCoord2f (u_end, 1.); glVertex3f (mWidth, 0., mHeight);
|
|
||||||
glTexCoord2f (u_start, 1.); glVertex3f (mWidth, 0.,0.);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
|||||||
+64
-9
@@ -2,29 +2,70 @@
|
|||||||
#define SPRITE_H
|
#define SPRITE_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
namespace Engine {
|
namespace Engine {
|
||||||
|
|
||||||
|
/** \brief A simple sprite class that allows animations and multiple sprites in one image
|
||||||
|
*
|
||||||
|
* Sprites are drawn aligned with the XZ-plane and the Y-axis pointing up.
|
||||||
|
*
|
||||||
|
*/
|
||||||
class Sprite {
|
class Sprite {
|
||||||
public:
|
public:
|
||||||
Sprite() {
|
Sprite() :
|
||||||
mScale = 1.;
|
mScale (1.f),
|
||||||
mWidth = 0;
|
mWidth (0),
|
||||||
mHeight = 0;
|
mHeight (0),
|
||||||
mGlTextureName = 0;
|
mGLTextureName (0),
|
||||||
|
mSubSpriteCount (1),
|
||||||
mAnimation = false;
|
mAnimation (false),
|
||||||
mSubSpriteCount = 1;
|
mAnimationFrameCount(1),
|
||||||
|
mAnimationTimer(0.f),
|
||||||
|
mAnimationFrameRate(0.f)
|
||||||
|
{ }
|
||||||
|
Sprite (const Sprite &othersprite) :
|
||||||
|
mScale (othersprite.mScale),
|
||||||
|
mWidth (othersprite.mWidth),
|
||||||
|
mHeight (othersprite.mHeight),
|
||||||
|
mGLTextureName (othersprite.mGLTextureName),
|
||||||
|
mSubSpriteCount (othersprite.mSubSpriteCount),
|
||||||
|
mAnimation (othersprite.mAnimation),
|
||||||
|
mAnimationFrameCount(othersprite.mAnimationFrameCount),
|
||||||
|
mAnimationTimer(othersprite.mAnimationTimer),
|
||||||
|
mAnimationFrameRate(othersprite.mAnimationFrameRate)
|
||||||
|
{}
|
||||||
|
Sprite& operator= (const Sprite &othersprite) {
|
||||||
|
if (this != &othersprite) {
|
||||||
|
mScale = othersprite.mScale;
|
||||||
|
mWidth = othersprite.mWidth;
|
||||||
|
mHeight = othersprite.mHeight;
|
||||||
|
mGLTextureName = othersprite.mGLTextureName;
|
||||||
|
mSubSpriteCount = othersprite.mSubSpriteCount;
|
||||||
|
mAnimation = othersprite.mAnimation;
|
||||||
|
mAnimationFrameCount= othersprite.mAnimationFrameCount;
|
||||||
|
mAnimationTimer= othersprite.mAnimationTimer;
|
||||||
|
mAnimationFrameRate= othersprite.mAnimationFrameRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Loads a Sprite from a .png file */
|
||||||
bool LoadFromPNG (const std::string &filename);
|
bool LoadFromPNG (const std::string &filename);
|
||||||
|
/** \brief Draws a sprite with the center at the given position */
|
||||||
void DrawAt (float xpos, float ypos, float zpos);
|
void DrawAt (float xpos, float ypos, float zpos);
|
||||||
void DrawAt2D (float xpos, float ypos);
|
void DrawAt2D (float xpos, float ypos);
|
||||||
unsigned int GetWidth() { return mWidth; };
|
unsigned int GetWidth() { return mWidth; };
|
||||||
unsigned int GetHeight() { return mHeight; };
|
unsigned int GetHeight() { return mHeight; };
|
||||||
|
|
||||||
|
void SetSize (unsigned int width, unsigned int height) {
|
||||||
|
mWidth = width;
|
||||||
|
mHeight = height;
|
||||||
|
}
|
||||||
void SetScale (float scale) { mScale = scale; };
|
void SetScale (float scale) { mScale = scale; };
|
||||||
|
|
||||||
|
/** \brief Marks the sprite as an animation and initializes its animation values */
|
||||||
void SetAnimation (int frame_count, float frame_rate) {
|
void SetAnimation (int frame_count, float frame_rate) {
|
||||||
mAnimation = true;
|
mAnimation = true;
|
||||||
mAnimationFrameCount = frame_count;
|
mAnimationFrameCount = frame_count;
|
||||||
@@ -42,6 +83,18 @@ class Sprite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetGLTextureName (GLuint texture_name) {
|
||||||
|
mGLTextureName = texture_name;
|
||||||
|
}
|
||||||
|
GLuint GetGLTextureName () {
|
||||||
|
return mGLTextureName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \brief Marks the Sprite as a collection of sprites
|
||||||
|
*
|
||||||
|
* All sprites have to be aligned in a row and the SubSprite
|
||||||
|
* functionality eases retrieval and drawing of individual sprites
|
||||||
|
*/
|
||||||
void SetSubSpriteCount (const unsigned int count) {
|
void SetSubSpriteCount (const unsigned int count) {
|
||||||
mSubSpriteCount = count;
|
mSubSpriteCount = count;
|
||||||
mWidth = static_cast<unsigned int>(ceil (static_cast<float> (mWidth / mSubSpriteCount)));
|
mWidth = static_cast<unsigned int>(ceil (static_cast<float> (mWidth / mSubSpriteCount)));
|
||||||
@@ -56,7 +109,7 @@ class Sprite {
|
|||||||
|
|
||||||
unsigned int mWidth;
|
unsigned int mWidth;
|
||||||
unsigned int mHeight;
|
unsigned int mHeight;
|
||||||
unsigned int mGlTextureName;
|
GLuint mGLTextureName;
|
||||||
|
|
||||||
unsigned int mSubSpriteCount;
|
unsigned int mSubSpriteCount;
|
||||||
|
|
||||||
@@ -66,6 +119,8 @@ class Sprite {
|
|||||||
float mAnimationFrameRate;
|
float mAnimationFrameRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<Sprite> SpritePtr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SPRITE_H */
|
#endif /* SPRITE_H */
|
||||||
|
|||||||
+6
-4
@@ -43,7 +43,8 @@ bool create_dir (const std::string &dir_str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string sha256_hash (std::string input) {
|
std::string sha256_hash (std::string input) {
|
||||||
char result_buf[64];
|
char result_buf[65];
|
||||||
|
result_buf[64] = '\0';
|
||||||
|
|
||||||
SHA256_CTX ctx256;
|
SHA256_CTX ctx256;
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ std::string sha256_hash (std::string input) {
|
|||||||
SHA256_Update(&ctx256, (unsigned char*) input.c_str(), input.size());
|
SHA256_Update(&ctx256, (unsigned char*) input.c_str(), input.size());
|
||||||
SHA256_End (&ctx256, result_buf);
|
SHA256_End (&ctx256, result_buf);
|
||||||
|
|
||||||
return std::string (result_buf, 64);
|
return std::string (result_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sha256_hash_file (const char *filename) {
|
std::string sha256_hash_file (const char *filename) {
|
||||||
@@ -62,7 +63,6 @@ std::string sha256_hash_file (const char *filename) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
file_stream.seekg (0,std::ios_base::end);
|
file_stream.seekg (0,std::ios_base::end);
|
||||||
std::streampos file_end = file_stream.tellg();
|
std::streampos file_end = file_stream.tellg();
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ std::string sha256_hash_file (const char *filename) {
|
|||||||
file_stream.seekg(0, std::ios_base::beg);
|
file_stream.seekg(0, std::ios_base::beg);
|
||||||
file_stream.read ((char*)file_buffer, file_size);
|
file_stream.read ((char*)file_buffer, file_size);
|
||||||
|
|
||||||
char result_buf[64];
|
char result_buf[65];
|
||||||
|
|
||||||
SHA256_CTX ctx256;
|
SHA256_CTX ctx256;
|
||||||
|
|
||||||
@@ -90,6 +90,8 @@ std::string sha256_hash_file (const char *filename) {
|
|||||||
|
|
||||||
delete[] file_buffer;
|
delete[] file_buffer;
|
||||||
|
|
||||||
|
result_buf[64] = '\0';
|
||||||
|
|
||||||
// std::cerr << "file hash is " << std::string (result_buf, 64) << std::endl;
|
// std::cerr << "file hash is " << std::string (result_buf, 64) << std::endl;
|
||||||
|
|
||||||
return std::string (result_buf, 64);
|
return std::string (result_buf, 64);
|
||||||
|
|||||||
+579
-4
@@ -11,6 +11,8 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
|
#include "OBJModel.h"
|
||||||
|
|
||||||
#include "DrawingsGL.h"
|
#include "DrawingsGL.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -61,6 +63,75 @@ int ViewBase::OnInit (int argc, char* argv[]) {
|
|||||||
InitGL ();
|
InitGL ();
|
||||||
Resize (mWindowWidth, mWindowHeight);
|
Resize (mWindowWidth, mWindowHeight);
|
||||||
|
|
||||||
|
// Initialize GLEW and check for anything we need
|
||||||
|
GLenum err = glewInit();
|
||||||
|
if (GLEW_OK != err) {
|
||||||
|
LogError ("Could not init GLEW properly: %s", glewGetErrorString(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDebug ("Using GLEW version %s", glewGetString(GLEW_VERSION));
|
||||||
|
if (glewIsExtensionSupported("GL_ARB_vertex_buffer_object")) {
|
||||||
|
} else {
|
||||||
|
LogError ("VBOs are not supported!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// read OpenGL version
|
||||||
|
std::string gl_version (reinterpret_cast<const char*>(glGetString(GL_VERSION)));
|
||||||
|
if (gl_version.size() == 0)
|
||||||
|
LogError ("Could not retrieve GL version!");
|
||||||
|
|
||||||
|
std::string major_number_str = gl_version.substr(0, gl_version.find('.'));
|
||||||
|
std::string minor_number_str = gl_version.substr(major_number_str.size() + 1, gl_version.find_first_of(". ", major_number_str.size()));
|
||||||
|
|
||||||
|
mGLVersionInfo.GLMajor = atoi (major_number_str.c_str());
|
||||||
|
mGLVersionInfo.GLMinor = atoi (minor_number_str.c_str());
|
||||||
|
|
||||||
|
// read GLSL version
|
||||||
|
std::string glsl_version (reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
|
||||||
|
if (glsl_version.size() == 0)
|
||||||
|
LogError ("Could not retrieve GLSL version!");
|
||||||
|
|
||||||
|
major_number_str = glsl_version.substr(0, glsl_version.find('.'));
|
||||||
|
minor_number_str = glsl_version.substr(major_number_str.size() + 1, glsl_version.find_first_of(". ", major_number_str.size()));
|
||||||
|
|
||||||
|
mGLVersionInfo.GLSLMajor = atoi (major_number_str.c_str());
|
||||||
|
mGLVersionInfo.GLSLMinor = atoi (minor_number_str.c_str());
|
||||||
|
|
||||||
|
LogMessage ("GL Version = %s, gl_major = %d, gl_minor = %d", gl_version.c_str(), mGLVersionInfo.GLMajor, mGLVersionInfo.GLMinor);
|
||||||
|
LogMessage ("GLSL Version = %s, gl_major = %d, gl_minor = %d", gl_version.c_str(), mGLVersionInfo.GLSLMajor, mGLVersionInfo.GLSLMinor);
|
||||||
|
|
||||||
|
if (mGLVersionInfo.GLMajor >= 2 && mGLVersionInfo.GLMinor >= 0)
|
||||||
|
mUseShaders = true;
|
||||||
|
else
|
||||||
|
mUseShaders = false;
|
||||||
|
|
||||||
|
// load the shaders if possible
|
||||||
|
if (mUseShaders) {
|
||||||
|
mBlinnPhongShader = LoadShaderProgram (GetResourceFullPath("/data/shaders/blinn_phong.glsl"));
|
||||||
|
mNormalMappingShader = LoadShaderProgram (GetResourceFullPath("/data/shaders/normal_mapping.glsl"));
|
||||||
|
} else {
|
||||||
|
mBlinnPhongShader = 0;
|
||||||
|
mNormalMappingShader = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a null texture that can be used for objects without textures
|
||||||
|
// taken from http://www.dhpoware.com/demos/glslNormalMapping.html
|
||||||
|
int pitch = ((2 * 32 + 31) & ~31) >> 3; // align to 4-byte boundaries
|
||||||
|
std::vector<GLubyte> pixels(pitch * 2, 255);
|
||||||
|
mNullTexture = 0;
|
||||||
|
|
||||||
|
glGenTextures(1, &mNullTexture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, mNullTexture);
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0, GL_BGRA,
|
||||||
|
GL_UNSIGNED_BYTE, &pixels[0]);
|
||||||
|
|
||||||
|
// Load fonts etc.
|
||||||
LoadFont ("console.ttf");
|
LoadFont ("console.ttf");
|
||||||
mCurrentFont = mFonts["console.ttf"];
|
mCurrentFont = mFonts["console.ttf"];
|
||||||
|
|
||||||
@@ -312,7 +383,7 @@ bool ViewBase::LoadFont (const std::string &font_spec_string) {
|
|||||||
|
|
||||||
OGLFT::Monochrome *font = new OGLFT::Monochrome (font_path.c_str(), font_size);
|
OGLFT::Monochrome *font = new OGLFT::Monochrome (font_path.c_str(), font_size);
|
||||||
if ( font == 0 || !font->isValid() ) {
|
if ( font == 0 || !font->isValid() ) {
|
||||||
LogError ("Could not load font %s!", font_path.c_str());
|
LogError ("Could not load font %s! (ptr=%x", font_path.c_str(), (void*)font);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +391,7 @@ bool ViewBase::LoadFont (const std::string &font_spec_string) {
|
|||||||
font->setBackgroundColor(0., 0., 0., 0.);
|
font->setBackgroundColor(0., 0., 0., 0.);
|
||||||
|
|
||||||
mFonts.insert(std::make_pair<std::string, OGLFT::Monochrome*>(font_spec_string, font));
|
mFonts.insert(std::make_pair<std::string, OGLFT::Monochrome*>(font_spec_string, font));
|
||||||
|
LogDebug ("Loading font %s successful!", font_name.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +406,7 @@ void ViewBase::SelectFont (const char *font) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogDebug ("Selecting font %s failed, trying to load it", font);
|
LogDebug ("Selecting font %s failed, trying to load it", font);
|
||||||
LogDebug ("font count = %d", mFonts.size());
|
|
||||||
if (LoadFont (font)) {
|
if (LoadFont (font)) {
|
||||||
LogDebug ("font count = %d", mFonts.size());
|
LogDebug ("font count = %d", mFonts.size());
|
||||||
font_iter = mFonts.find(font);
|
font_iter = mFonts.find(font);
|
||||||
@@ -381,6 +452,510 @@ void ViewBase::DrawGLStringMeasure (const char* str, float *width, float *height
|
|||||||
// LogDebug ("measure bbox '%s' = %f,%f %f,%f",str, bbox.x_min_, bbox.y_min_, bbox.x_max_, bbox.y_max_);
|
// LogDebug ("measure bbox '%s' = %f,%f %f,%f",str, bbox.x_min_, bbox.y_min_, bbox.x_max_, bbox.y_max_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint ViewBase::LoadTextureFromPNG (const std::string &filename) {
|
||||||
|
std::map<std::string, GLuint>::iterator texture_iterator = mGLTextures.find(filename);
|
||||||
|
|
||||||
|
if (texture_iterator != mGLTextures.end()) {
|
||||||
|
return texture_iterator->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sprite temp_sprite;
|
||||||
|
temp_sprite.LoadFromPNG (filename.c_str());
|
||||||
|
|
||||||
|
// register the texture in the View
|
||||||
|
mGLTextures[filename] = temp_sprite.GetGLTextureName();
|
||||||
|
|
||||||
|
return temp_sprite.GetGLTextureName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OBJModel loading and drawing
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
OBJModelPtr ViewBase::LoadOBJModel (const std::string &model_filename) {
|
||||||
|
LogDebug ("Loading OBJ model %s", model_filename.c_str());
|
||||||
|
|
||||||
|
OBJModelPtr result_model (new OBJModel);
|
||||||
|
|
||||||
|
if(!result_model->import (model_filename.c_str(), true)) {
|
||||||
|
LogError("Could not load model %s", model_filename.c_str());
|
||||||
|
return result_model;
|
||||||
|
}
|
||||||
|
|
||||||
|
result_model->normalize();
|
||||||
|
result_model->reverseWinding();
|
||||||
|
|
||||||
|
// Load any associated textures.
|
||||||
|
// Note the path where the textures are assumed to be located.
|
||||||
|
|
||||||
|
const OBJModel::Material *pMaterial = 0;
|
||||||
|
GLuint textureId = 0;
|
||||||
|
std::string::size_type offset = 0;
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
for (int i = 0; i < result_model->getNumberOfMaterials(); ++i)
|
||||||
|
{
|
||||||
|
pMaterial = &result_model->getMaterial(i);
|
||||||
|
|
||||||
|
// Look for and load any diffuse color map textures.
|
||||||
|
if (!pMaterial->colorMapFilename.empty()) {
|
||||||
|
// Try load the texture using the path in the .MTL file.
|
||||||
|
textureId = LoadTextureFromPNG(pMaterial->colorMapFilename.c_str());
|
||||||
|
|
||||||
|
if (!textureId)
|
||||||
|
{
|
||||||
|
offset = pMaterial->colorMapFilename.find_last_of('\\');
|
||||||
|
|
||||||
|
if (offset != std::string::npos)
|
||||||
|
filename = pMaterial->colorMapFilename.substr(++offset);
|
||||||
|
else
|
||||||
|
filename = pMaterial->colorMapFilename;
|
||||||
|
|
||||||
|
// Try loading the texture from the same directory as the OBJ file.
|
||||||
|
textureId = LoadTextureFromPNG((filename).c_str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogMessage ("No diffuse color map found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for and load any normal map textures.
|
||||||
|
if (!pMaterial->bumpMapFilename.empty()) {
|
||||||
|
|
||||||
|
// Try load the texture using the path in the .MTL file.
|
||||||
|
textureId = LoadTextureFromPNG((pMaterial->bumpMapFilename).c_str());
|
||||||
|
|
||||||
|
if (!textureId)
|
||||||
|
{
|
||||||
|
offset = pMaterial->bumpMapFilename.find_last_of('\\');
|
||||||
|
|
||||||
|
if (offset != std::string::npos)
|
||||||
|
filename = pMaterial->bumpMapFilename.substr(++offset);
|
||||||
|
else
|
||||||
|
filename = pMaterial->bumpMapFilename;
|
||||||
|
|
||||||
|
// Try loading the texture from the same directory as the OBJ file.
|
||||||
|
textureId = LoadTextureFromPNG((result_model->getPath() + filename).c_str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogMessage ("Material has no bumpmap!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the window caption.
|
||||||
|
|
||||||
|
LogMessage ("Loaded model %s successful, dimensions (whl): %f, %f, %f meshes %d vertices %d triangles: %d",
|
||||||
|
model_filename.c_str(),
|
||||||
|
result_model->getWidth(),
|
||||||
|
result_model->getHeight(),
|
||||||
|
result_model->getLength(),
|
||||||
|
result_model->getNumberOfMeshes(),
|
||||||
|
result_model->getNumberOfVertices(),
|
||||||
|
result_model->getNumberOfTriangles()
|
||||||
|
);
|
||||||
|
|
||||||
|
return result_model;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewBase::DrawOBJModel (OBJModelPtr obj_model) {
|
||||||
|
if (mUseShaders) {
|
||||||
|
DrawOBJModelShaded(obj_model);
|
||||||
|
} else {
|
||||||
|
DrawOBJModelSolid (obj_model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewBase::DrawOBJModelSolid (OBJModelPtr obj_model) {
|
||||||
|
const OBJModel::Mesh *pMesh = 0;
|
||||||
|
const OBJModel::Material *pMaterial = 0;
|
||||||
|
const OBJModel::Vertex *pVertices = 0;
|
||||||
|
std::map<std::string, GLuint>::const_iterator iter;
|
||||||
|
|
||||||
|
for (int i = 0; i < obj_model->getNumberOfMeshes(); ++i)
|
||||||
|
{
|
||||||
|
pMesh = &obj_model->getMesh(i);
|
||||||
|
pMaterial = pMesh->pMaterial;
|
||||||
|
pVertices = obj_model->getVertexBuffer();
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pMaterial->ambient);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pMaterial->diffuse);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pMaterial->specular);
|
||||||
|
|
||||||
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, pMaterial->shininess * 128.0f);
|
||||||
|
|
||||||
|
if (pMaterial->colorMapFilename.size() > 0)
|
||||||
|
{
|
||||||
|
iter = mGLTextures.find(pMaterial->colorMapFilename);
|
||||||
|
|
||||||
|
if (iter == mGLTextures.end())
|
||||||
|
{
|
||||||
|
LogError ("Could not find required colormap '%s'", pMaterial->colorMapFilename.c_str());
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, iter->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasPositions())
|
||||||
|
{
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasTextureCoords())
|
||||||
|
{
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->texCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasNormals())
|
||||||
|
{
|
||||||
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
|
glNormalPointer(GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDrawElements(GL_TRIANGLES, pMesh->triangleCount * 3, GL_UNSIGNED_INT,
|
||||||
|
obj_model->getIndexBuffer() + pMesh->startIndex);
|
||||||
|
|
||||||
|
if (obj_model->hasNormals())
|
||||||
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
|
||||||
|
if (obj_model->hasTextureCoords())
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
|
if (obj_model->hasPositions())
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
// disable texture drawing if active
|
||||||
|
if (pMaterial->colorMapFilename.size() > 0)
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewBase::DrawOBJModelShaded (OBJModelPtr obj_model) {
|
||||||
|
const OBJModel::Mesh *pMesh = 0;
|
||||||
|
const OBJModel::Material *pMaterial = 0;
|
||||||
|
const OBJModel::Vertex *pVertices = 0;
|
||||||
|
std::map<std::string, GLuint>::const_iterator iter;
|
||||||
|
GLuint texture = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < obj_model->getNumberOfMeshes(); ++i)
|
||||||
|
{
|
||||||
|
pMesh = &obj_model->getMesh(i);
|
||||||
|
pMaterial = pMesh->pMaterial;
|
||||||
|
pVertices = obj_model->getVertexBuffer();
|
||||||
|
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, pMaterial->ambient);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, pMaterial->diffuse);
|
||||||
|
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pMaterial->specular);
|
||||||
|
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, pMaterial->shininess * 128.0f);
|
||||||
|
|
||||||
|
// if there is no bumpmap we will simply use a blinn phong shader and draw
|
||||||
|
// the color map onto our model
|
||||||
|
if (pMaterial->bumpMapFilename.empty())
|
||||||
|
{
|
||||||
|
// LogMessage ("using Blinn Phong shader");
|
||||||
|
// Per fragment Blinn-Phong code path.
|
||||||
|
glUseProgram(mBlinnPhongShader);
|
||||||
|
|
||||||
|
// Bind the color map texture.
|
||||||
|
|
||||||
|
texture = mNullTexture;
|
||||||
|
|
||||||
|
if (pMaterial->colorMapFilename.size() > 0) {
|
||||||
|
iter = mGLTextures.find(pMaterial->colorMapFilename);
|
||||||
|
|
||||||
|
if (iter != mGLTextures.end())
|
||||||
|
texture = iter->second;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// LogMessage ("Disabling textures");
|
||||||
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
|
// Update shader parameters.
|
||||||
|
assert (glIsProgram (mBlinnPhongShader) == GL_TRUE);
|
||||||
|
assert (glGetUniformLocation(mBlinnPhongShader, "materialAlpha") != -1);
|
||||||
|
assert (glGetUniformLocation(mBlinnPhongShader, "colorMap") != -1);
|
||||||
|
glUniform1i(glGetUniformLocation(
|
||||||
|
mBlinnPhongShader, "colorMap"), 0);
|
||||||
|
glUniform1f(glGetUniformLocation(
|
||||||
|
mBlinnPhongShader, "materialAlpha"), pMaterial->alpha);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if there is a bumpmap we use both the bump map and the color map and
|
||||||
|
// apply it on our model
|
||||||
|
|
||||||
|
// LogMessage ("using Normal Mapping Shader");
|
||||||
|
// Normal mapping code path.
|
||||||
|
|
||||||
|
glUseProgram(mNormalMappingShader);
|
||||||
|
|
||||||
|
// Bind the normal map texture.
|
||||||
|
|
||||||
|
iter = mGLTextures.find(pMaterial->bumpMapFilename);
|
||||||
|
|
||||||
|
if (iter != mGLTextures.end()) {
|
||||||
|
texture = iter->second;
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
} else {
|
||||||
|
LogError ("bumpmap %s not found", pMaterial->bumpMapFilename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind the color map texture.
|
||||||
|
|
||||||
|
texture = mNullTexture;
|
||||||
|
|
||||||
|
if (pMaterial->colorMapFilename.size() > 0)
|
||||||
|
{
|
||||||
|
iter = mGLTextures.find(pMaterial->colorMapFilename);
|
||||||
|
|
||||||
|
if (iter != mGLTextures.end()) {
|
||||||
|
texture = iter->second;
|
||||||
|
} else {
|
||||||
|
LogError ("color map %s not found", pMaterial->colorMapFilename.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
|
// Update shader parameters.
|
||||||
|
assert (glGetUniformLocation(mNormalMappingShader, "colorMap") != -1);
|
||||||
|
assert (glGetUniformLocation(mNormalMappingShader, "normalMap") != -1);
|
||||||
|
assert (glGetUniformLocation(mNormalMappingShader, "materialAlpha") != -1);
|
||||||
|
|
||||||
|
glUniform1i(glGetUniformLocation(
|
||||||
|
mNormalMappingShader, "colorMap"), 0);
|
||||||
|
glUniform1i(glGetUniformLocation(
|
||||||
|
mNormalMappingShader, "normalMap"), 1);
|
||||||
|
glUniform1f(glGetUniformLocation(
|
||||||
|
mNormalMappingShader, "materialAlpha"), pMaterial->alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render mesh.
|
||||||
|
|
||||||
|
if (obj_model->hasPositions())
|
||||||
|
{
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasTextureCoords())
|
||||||
|
{
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->texCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasNormals())
|
||||||
|
{
|
||||||
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
|
glNormalPointer(GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasTangents())
|
||||||
|
{
|
||||||
|
glClientActiveTexture(GL_TEXTURE1);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glTexCoordPointer(4, GL_FLOAT, obj_model->getVertexSize(),
|
||||||
|
obj_model->getVertexBuffer()->tangent);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDrawElements(GL_TRIANGLES, pMesh->triangleCount * 3, GL_UNSIGNED_INT,
|
||||||
|
obj_model->getIndexBuffer() + pMesh->startIndex);
|
||||||
|
|
||||||
|
if (obj_model->hasTangents())
|
||||||
|
{
|
||||||
|
glClientActiveTexture(GL_TEXTURE1);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasNormals())
|
||||||
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
|
||||||
|
if (obj_model->hasTextureCoords())
|
||||||
|
{
|
||||||
|
glClientActiveTexture(GL_TEXTURE0);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj_model->hasPositions())
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// as we might be using multiple textures (at least for the normal mapping
|
||||||
|
// case) we have to disable both textures
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
glUseProgram(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shader loading, compiling, linking
|
||||||
|
*/
|
||||||
|
/** Compiles a shader program
|
||||||
|
*
|
||||||
|
* This function contains code mainly taken from dhpowares excellent
|
||||||
|
* objviewer example (see http://www.dhpoware.com/demos/gl3NormalMapping.html ).
|
||||||
|
*/
|
||||||
|
GLuint ViewBase::CompileShader (GLenum type, const GLchar *source, GLint length) {
|
||||||
|
GLuint shader = glCreateShader(type);
|
||||||
|
|
||||||
|
if (shader) {
|
||||||
|
GLint compiled = 0;
|
||||||
|
|
||||||
|
glShaderSource (shader, 1, &source, &length);
|
||||||
|
glCompileShader(shader);
|
||||||
|
glGetShaderiv (shader, GL_COMPILE_STATUS, &compiled);
|
||||||
|
|
||||||
|
if (!compiled) {
|
||||||
|
GLsizei info_log_size = 0;
|
||||||
|
std::string info_log;
|
||||||
|
|
||||||
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &info_log_size);
|
||||||
|
info_log.resize (info_log_size);
|
||||||
|
glGetShaderInfoLog (shader, info_log_size, &info_log_size, &info_log[0]);
|
||||||
|
|
||||||
|
LogError ("Error compiling shader: %s", info_log.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return shader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Links the given shader programs
|
||||||
|
*
|
||||||
|
* This function contains code mainly taken from dhpowares excellent
|
||||||
|
* objviewer example (see http://www.dhpoware.com/demos/gl3NormalMapping.html ).
|
||||||
|
*/
|
||||||
|
GLuint ViewBase::LinkShaders (GLuint vertex_shader, GLuint fragment_shader) {
|
||||||
|
GLuint program = glCreateProgram();
|
||||||
|
|
||||||
|
if (program) {
|
||||||
|
GLint linked = 0;
|
||||||
|
|
||||||
|
if (vertex_shader)
|
||||||
|
glAttachShader (program, vertex_shader);
|
||||||
|
|
||||||
|
if (fragment_shader)
|
||||||
|
glAttachShader (program, fragment_shader);
|
||||||
|
|
||||||
|
glLinkProgram (program);
|
||||||
|
glGetProgramiv (program, GL_LINK_STATUS, &linked);
|
||||||
|
|
||||||
|
if (!linked) {
|
||||||
|
GLsizei info_log_size = 0;
|
||||||
|
std::string info_log;
|
||||||
|
|
||||||
|
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &info_log_size);
|
||||||
|
info_log.resize (info_log_size);
|
||||||
|
glGetProgramInfoLog (program, info_log_size, &info_log_size, &info_log[0]);
|
||||||
|
|
||||||
|
LogError ("Error linking shaders vert: %d, frag: %d", vertex_shader, fragment_shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vertex_shader)
|
||||||
|
glDeleteShader (vertex_shader);
|
||||||
|
|
||||||
|
if (fragment_shader)
|
||||||
|
glDeleteShader (fragment_shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Loads a vertex or fragment shader program
|
||||||
|
*
|
||||||
|
* This function contains code mainly taken from dhpowares excellent
|
||||||
|
* objviewer example (see http://www.dhpoware.com/demos/gl3NormalMapping.html ).
|
||||||
|
*/
|
||||||
|
GLuint ViewBase::LoadShaderProgram (const std::string &filename) {
|
||||||
|
LogDebug ("Loading shader program %s", filename.c_str());
|
||||||
|
|
||||||
|
std::ifstream program_file (filename.c_str());
|
||||||
|
if (!program_file) {
|
||||||
|
LogError ("Could not open file '%s' while loading shader program", filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the whole file into a string
|
||||||
|
std::string shader_program ((std::istreambuf_iterator<char>(program_file)), std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
program_file.close();
|
||||||
|
|
||||||
|
GLuint program = 0;
|
||||||
|
|
||||||
|
if (shader_program.size() > 0) {
|
||||||
|
const GLchar *source;
|
||||||
|
GLint length = 0;
|
||||||
|
GLuint vertex_shader = 0;
|
||||||
|
GLuint fragment_shader = 0;
|
||||||
|
|
||||||
|
std::string::size_type vertex_shader_offset = shader_program.find("[vert]");
|
||||||
|
std::string::size_type fragment_shader_offset = shader_program.find("[frag]");
|
||||||
|
|
||||||
|
if (vertex_shader_offset != std::string::npos) {
|
||||||
|
// skip over the [vert] tag
|
||||||
|
vertex_shader_offset += 6;
|
||||||
|
source = reinterpret_cast<const GLchar *> (&shader_program[vertex_shader_offset]);
|
||||||
|
length = static_cast<GLint>(fragment_shader_offset - vertex_shader_offset);
|
||||||
|
vertex_shader = CompileShader (GL_VERTEX_SHADER, source, length);
|
||||||
|
|
||||||
|
LogMessage ("Compiled vertex shader with id %d", vertex_shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fragment_shader_offset != std::string::npos) {
|
||||||
|
// skip over the [vert] tag
|
||||||
|
fragment_shader_offset += 6;
|
||||||
|
source = reinterpret_cast<const GLchar *> (&shader_program[fragment_shader_offset]);
|
||||||
|
length = static_cast<GLint>(shader_program.length() - fragment_shader_offset - 1);
|
||||||
|
fragment_shader = CompileShader (GL_FRAGMENT_SHADER, source, length);
|
||||||
|
|
||||||
|
LogMessage ("Compiled fragment shader with id %d", fragment_shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
program = LinkShaders (vertex_shader, fragment_shader);
|
||||||
|
|
||||||
|
LogMessage ("Successfully linked shaders vert: %d frag: %d from file %s into program %d", vertex_shader, fragment_shader, filename.c_str(), program);
|
||||||
|
}
|
||||||
|
|
||||||
|
mShaderPrograms[filename] = program;
|
||||||
|
|
||||||
|
return program;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Camera and other auxillary functions
|
||||||
|
*/
|
||||||
|
|
||||||
void ViewBase::GetCamereEye (float *eye_out) {
|
void ViewBase::GetCamereEye (float *eye_out) {
|
||||||
assert (mCamera);
|
assert (mCamera);
|
||||||
mCamera->GetEye (eye_out);
|
mCamera->GetEye (eye_out);
|
||||||
@@ -428,7 +1003,7 @@ void ViewBase::Resize (int width, int height) {
|
|||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(mCamera->GetFOVY (), float (width) / float (height), 0.1, 100);
|
gluPerspective(mCamera->GetFOVY (), float (width) / float (height), 0., 100);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
|
|||||||
+37
-11
@@ -4,6 +4,7 @@
|
|||||||
#include "Engine.h"
|
#include "Engine.h"
|
||||||
#include "EngineEnums.h"
|
#include "EngineEnums.h"
|
||||||
#include "OverlayBase.h"
|
#include "OverlayBase.h"
|
||||||
|
#include "Sprite.h"
|
||||||
|
|
||||||
// forward declarations for the OGLFT fonts
|
// forward declarations for the OGLFT fonts
|
||||||
namespace OGLFT {
|
namespace OGLFT {
|
||||||
@@ -15,6 +16,9 @@ namespace Engine {
|
|||||||
class Module;
|
class Module;
|
||||||
class ModelBase;
|
class ModelBase;
|
||||||
class CameraBase;
|
class CameraBase;
|
||||||
|
class OBJModel;
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<OBJModel> OBJModelPtr;
|
||||||
|
|
||||||
/** \brief Performs the actual drawing based on Camera and Model
|
/** \brief Performs the actual drawing based on Camera and Model
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +29,7 @@ class ViewBase : public Module{
|
|||||||
virtual ~ViewBase() {};
|
virtual ~ViewBase() {};
|
||||||
|
|
||||||
/** \brief Resizes the View */
|
/** \brief Resizes the View */
|
||||||
void Resize (int width, int height);
|
virtual void Resize (int width, int height);
|
||||||
/** \brief Switches to fullscreen */
|
/** \brief Switches to fullscreen */
|
||||||
void SetFullscreen (bool fullscreen);
|
void SetFullscreen (bool fullscreen);
|
||||||
bool GetIsFullscreen () { return mDrawFullscreen; };
|
bool GetIsFullscreen () { return mDrawFullscreen; };
|
||||||
@@ -76,16 +80,6 @@ class ViewBase : public Module{
|
|||||||
bool GetDrawGrid () { return mDrawGrid; };
|
bool GetDrawGrid () { return mDrawGrid; };
|
||||||
void SetGridSize (int x, int z) { mGridSizeX = x; mGridSizeZ = z; }
|
void SetGridSize (int x, int z) { mGridSizeX = x; mGridSizeZ = z; }
|
||||||
|
|
||||||
// void AddOverlay (OverlayBasePtr overlay) { mOverlays.push_back (overlay); };
|
|
||||||
|
|
||||||
/* Input forwarding for the overlays */
|
|
||||||
/*
|
|
||||||
bool SendKeyDown (const SDL_keysym &keysym);
|
|
||||||
bool SendKeyUp (const SDL_keysym &keysym);
|
|
||||||
bool SendMouseButtonUp (Uint8 button, Uint16 xpos, Uint16 ypos);
|
|
||||||
bool SendMouseButtonDown (Uint8 button, Uint16 xpos, Uint16 ypos);
|
|
||||||
*/
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
protected:
|
protected:
|
||||||
/** \brief Initializes the system */
|
/** \brief Initializes the system */
|
||||||
@@ -138,6 +132,38 @@ class ViewBase : public Module{
|
|||||||
/** \brief Contains all the fonts that are to be used */
|
/** \brief Contains all the fonts that are to be used */
|
||||||
std::map<std::string, OGLFT::Monochrome*> mFonts;
|
std::map<std::string, OGLFT::Monochrome*> mFonts;
|
||||||
|
|
||||||
|
GLuint LoadTextureFromPNG (const std::string &filename);
|
||||||
|
|
||||||
|
/** \brief All loaded textures */
|
||||||
|
std::map<std::string, GLuint> mGLTextures;
|
||||||
|
|
||||||
|
OBJModelPtr LoadOBJModel (const std::string &model_filename);
|
||||||
|
void DrawOBJModel (OBJModelPtr mesh);
|
||||||
|
void DrawOBJModelSolid (OBJModelPtr mesh);
|
||||||
|
void DrawOBJModelShaded (OBJModelPtr mesh);
|
||||||
|
std::map<std::string, OBJModelPtr> mOBJModeles;
|
||||||
|
|
||||||
|
/** \brief Whether we can use shader programs */
|
||||||
|
bool mUseShaders;
|
||||||
|
|
||||||
|
GLuint CompileShader (GLenum type, const GLchar *source, GLint length);
|
||||||
|
GLuint LinkShaders (GLuint vertex_shader, GLuint fragment_shader);
|
||||||
|
GLuint LoadShaderProgram (const std::string &filename);
|
||||||
|
|
||||||
|
std::map<std::string, GLuint> mShaderPrograms;
|
||||||
|
|
||||||
|
GLuint mBlinnPhongShader;
|
||||||
|
GLuint mNormalMappingShader;
|
||||||
|
|
||||||
|
struct OpenGLVersionInfo {
|
||||||
|
int GLMajor;
|
||||||
|
int GLMinor;
|
||||||
|
int GLSLMajor;
|
||||||
|
int GLSLMinor;
|
||||||
|
} mGLVersionInfo;
|
||||||
|
|
||||||
|
GLuint mNullTexture;
|
||||||
|
|
||||||
friend class Engine;
|
friend class Engine;
|
||||||
friend class ControllerBase;
|
friend class ControllerBase;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,12 @@
|
|||||||
#define VIEW_DEFAULT_WIDTH 800
|
#define VIEW_DEFAULT_WIDTH 800
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
#define NOMINMAX
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
inline double roundf(double x) { return floor(x + 0.5); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ namespace OGLFT {
|
|||||||
FT_Error error = FT_New_Face( Library::instance(), filename, 0, &ft_face );
|
FT_Error error = FT_New_Face( Library::instance(), filename, 0, &ft_face );
|
||||||
|
|
||||||
if ( error != 0 ) {
|
if ( error != 0 ) {
|
||||||
|
std::cerr << "FreeType error code: " << error << std::endl;
|
||||||
valid_ = false;
|
valid_ = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -178,8 +179,10 @@ namespace OGLFT {
|
|||||||
|
|
||||||
FT_Error error = FT_New_Face( Library::instance(), filename, 0, &ft_face );
|
FT_Error error = FT_New_Face( Library::instance(), filename, 0, &ft_face );
|
||||||
|
|
||||||
if ( error != 0 )
|
if ( error != 0 ) {
|
||||||
|
std::cerr << "FreeType error code: " << error << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
faces_.push_back( FaceData( ft_face ) );
|
faces_.push_back( FaceData( ft_face ) );
|
||||||
|
|
||||||
@@ -406,7 +409,10 @@ namespace OGLFT {
|
|||||||
FT_Error error = FT_Load_Glyph( faces_[f].face_, glyph_index,
|
FT_Error error = FT_Load_Glyph( faces_[f].face_, glyph_index,
|
||||||
FT_LOAD_DEFAULT );
|
FT_LOAD_DEFAULT );
|
||||||
|
|
||||||
if ( error != 0 ) return;
|
if ( error != 0 ) {
|
||||||
|
std::cerr << "FreeType error code: " << error << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rotation_reference_glyph_ = glyph_index;
|
rotation_reference_glyph_ = glyph_index;
|
||||||
|
|
||||||
|
|||||||
@@ -619,7 +619,7 @@ namespace OGLFT {
|
|||||||
* \param blue the blue component of the background color.
|
* \param blue the blue component of the background color.
|
||||||
* \param alpha the alpha component of the background color.
|
* \param alpha the alpha component of the background color.
|
||||||
*/
|
*/
|
||||||
void setBackgroundColor ( GLfloat red = 1.0,
|
OGLFT_API void setBackgroundColor ( GLfloat red = 1.0,
|
||||||
GLfloat green = 1.0,
|
GLfloat green = 1.0,
|
||||||
GLfloat blue = 1.0,
|
GLfloat blue = 1.0,
|
||||||
GLfloat alpha = 0.0 );
|
GLfloat alpha = 0.0 );
|
||||||
@@ -631,7 +631,7 @@ namespace OGLFT {
|
|||||||
* \param background_color an array of 4 values corresponding to the
|
* \param background_color an array of 4 values corresponding to the
|
||||||
* red, green, blue and alpha components of the background color.
|
* red, green, blue and alpha components of the background color.
|
||||||
*/
|
*/
|
||||||
void setBackgroundColor ( const GLfloat background_color[4] );
|
OGLFT_API void setBackgroundColor ( const GLfloat background_color[4] );
|
||||||
#ifndef OGLFT_NO_QT
|
#ifndef OGLFT_NO_QT
|
||||||
/*!
|
/*!
|
||||||
* This is the nominal background color of the glyphs. A lot of other things
|
* This is the nominal background color of the glyphs. A lot of other things
|
||||||
|
|||||||
@@ -86,7 +86,12 @@
|
|||||||
* made).
|
* made).
|
||||||
*/
|
*/
|
||||||
#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
|
#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
|
||||||
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
|
#ifdef WIN32
|
||||||
|
#define LITTLE_ENDIAN 12345
|
||||||
|
#define BYTE_ORDER LITTLE_ENDIAN
|
||||||
|
#else
|
||||||
|
#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ extern "C" {
|
|||||||
* uintXX_t (from inttypes.h), you may need to define things by hand
|
* uintXX_t (from inttypes.h), you may need to define things by hand
|
||||||
* for your system:
|
* for your system:
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if WIN32
|
||||||
typedef unsigned char u_int8_t; /* 1-byte (8-bits) */
|
typedef unsigned char u_int8_t; /* 1-byte (8-bits) */
|
||||||
typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */
|
typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */
|
||||||
typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */
|
typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */
|
||||||
|
|||||||
Reference in New Issue
Block a user