Release 0.1.12-alpha: Merge branch 'dev'
commit
6ec644d20b
|
@ -38,3 +38,7 @@ CMakeLists.txt.user.*
|
|||
|
||||
# Ignore Visual Studio Code files
|
||||
/.vscode
|
||||
|
||||
# Ignore Visual Studio files
|
||||
/CMakeSettings.json
|
||||
/.vs
|
||||
|
|
|
@ -16,9 +16,9 @@ set(COLOBOT_VERSION_MINOR 1)
|
|||
set(COLOBOT_VERSION_REVISION 11.1)
|
||||
|
||||
# Used on official releases
|
||||
set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
|
||||
#set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
|
||||
# Used on unreleased, development builds
|
||||
#set(COLOBOT_VERSION_UNRELEASED "+alpha")
|
||||
set(COLOBOT_VERSION_UNRELEASED "+alpha")
|
||||
|
||||
# Append git characteristics to version
|
||||
if(DEFINED COLOBOT_VERSION_UNRELEASED)
|
||||
|
@ -124,6 +124,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|||
# Include cmake directory with some additional scripts
|
||||
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
# MSVC needs different flags if linking statically
|
||||
option(MSVC_STATIC "Link statically when using MSVC" OFF)
|
||||
|
||||
# Compiler detection
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
||||
|
@ -160,14 +163,19 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|||
message(STATUS "Detected MSVC compiler")
|
||||
|
||||
set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings
|
||||
set(RELEASE_CXX_FLAGS "/MD")
|
||||
if(MSVC_STATIC)
|
||||
set(RELEASE_CXX_FLAGS "/MT /Ox")
|
||||
set(DEBUG_CXX_FLAGS "/MTd /ZI")
|
||||
else(MSVC_STATIC)
|
||||
set(RELEASE_CXX_FLAGS "/MD /Ox")
|
||||
set(DEBUG_CXX_FLAGS "/MDd /ZI")
|
||||
endif()
|
||||
set(TEST_CXX_FLAGS "")
|
||||
add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG)
|
||||
|
||||
# Needed for Debug information (it's set to "No" by default for some reason)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
|
||||
else()
|
||||
message(FATAL_ERROR "Your C++ compiler doesn't seem to be supported.")
|
||||
endif()
|
||||
|
@ -196,11 +204,14 @@ option(DEV_BUILD "Enable development build (enables some debugging tools, local
|
|||
|
||||
# Official build - changes text on the crash screen
|
||||
# PLEASE DO NOT USE ON UNOFFICIAL BUILDS. Thanks.
|
||||
option(OFFICIAL_BUILD "Official build (changes crash screen text)" OFF)
|
||||
option(OFFICIAL_COLOBOT_BUILD "Official build (changes crash screen text)" OFF)
|
||||
|
||||
# Portable build - load all data from current directory
|
||||
option(PORTABLE "Portable build" OFF)
|
||||
|
||||
# Portable saves - suitable for e.g. putting the whole game on external storage and moving your saves with it
|
||||
option(PORTABLE_SAVES "Portable saves" OFF)
|
||||
|
||||
# Building tests can be enabled/disabled
|
||||
option(TESTS "Build tests" OFF)
|
||||
|
||||
|
@ -312,6 +323,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|||
|
||||
set(CBOT_STATIC 1) # only this works for some reason
|
||||
set(WINGETOPT 1) # use wingetopt library
|
||||
|
||||
# Hide console in release builds
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(CMAKE_WIN32_EXECUTABLE 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
##
|
||||
|
@ -350,21 +366,19 @@ endif()
|
|||
##
|
||||
|
||||
# Installation paths defined before compiling sources
|
||||
if(PLATFORM_WINDOWS)
|
||||
if(MXE)
|
||||
if(PORTABLE OR (PLATFORM_WINDOWS AND MXE))
|
||||
# We need to use STRING because PATH doesn't accept relative paths
|
||||
set(COLOBOT_INSTALL_BIN_DIR ./ CACHE STRING "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ./ CACHE STRING "Colobot libraries directory")
|
||||
set(COLOBOT_INSTALL_DATA_DIR ./data CACHE STRING "Colobot shared data directory")
|
||||
set(COLOBOT_INSTALL_I18N_DIR ./lang CACHE STRING "Colobot translations directory")
|
||||
set(COLOBOT_INSTALL_DOC_DIR ./doc CACHE STRING "Colobot documentation directory")
|
||||
else()
|
||||
elseif(PLATFORM_WINDOWS)
|
||||
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot libraries directory")
|
||||
set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/data CACHE PATH "Colobot shared data directory")
|
||||
set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/lang CACHE PATH "Colobot translations directory")
|
||||
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
|
||||
endif()
|
||||
elseif(PLATFORM_MACOSX)
|
||||
set(COLOBOT_INSTALL_BIN_DIR ../MacOS CACHE STRING "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ../MacOS CACHE STRING "Colobot libraries directory")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env groovy
|
||||
|
||||
pipeline {
|
||||
agent { label 'colobot-build' }
|
||||
agent none
|
||||
options {
|
||||
buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '20'))
|
||||
}
|
||||
|
@ -19,13 +19,17 @@ pipeline {
|
|||
stage('Build') {
|
||||
parallel {
|
||||
stage('Build Windows') {
|
||||
agent {
|
||||
docker { image 'krzysh/colobot-build:latest' }
|
||||
}
|
||||
steps {
|
||||
sh 'mkdir -p build/windows'
|
||||
dir('build/windows') {
|
||||
sh '''
|
||||
cmake \
|
||||
# FIXME: without -lsetupapi linking sdl2 fails
|
||||
/opt/mxe/usr/bin/i686-w64-mingw32.static-cmake \
|
||||
-DCMAKE_CXX_STANDARD_LIBRARIES="-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -lsetupapi" \
|
||||
-DCMAKE_INSTALL_PREFIX=/install \
|
||||
-DCMAKE_TOOLCHAIN_FILE=/opt/mxe/usr/i686-w64-mingw32.static/share/cmake/mxe-conf.cmake \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=0 ../..
|
||||
make
|
||||
rm -rf install
|
||||
|
@ -42,14 +46,16 @@ pipeline {
|
|||
}
|
||||
|
||||
stage('Build Linux') {
|
||||
agent {
|
||||
docker { image 'krzysh/colobot-build:latest' }
|
||||
}
|
||||
steps {
|
||||
sh 'mkdir -p build/linux'
|
||||
dir('build/linux') {
|
||||
sh '''
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=/install -DCOLOBOT_INSTALL_BIN_DIR=/install -DCOLOBOT_INSTALL_LIB_DIR=/install -DCOLOBOT_INSTALL_DATA_DIR=/install/data -DCOLOBOT_INSTALL_I18N_DIR=/install/lang -DCMAKE_SKIP_INSTALL_RPATH=ON \
|
||||
-DBOOST_STATIC=ON -DGLEW_STATIC=ON -DGLEW_LIBRARY=/usr/lib64/libGLEW.a \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=0 ../..
|
||||
-DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 ../..
|
||||
make
|
||||
rm -rf install
|
||||
DESTDIR=. make install
|
||||
|
@ -60,7 +66,31 @@ pipeline {
|
|||
post {
|
||||
success {
|
||||
sh 'rm -f linux-debug.zip'
|
||||
zip zipFile: 'linux-debug.zip', archive: true, dir: 'build/linux/install'
|
||||
dir('build/linux') {
|
||||
sh '''
|
||||
# Clean up
|
||||
rm -rf squashfs-root
|
||||
rm -rf colobot.AppDir
|
||||
rm -rf appimage
|
||||
rm -f Colobot-x86_64.AppImage
|
||||
|
||||
# Download app image tool
|
||||
wget -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
||||
chmod +x linuxdeploy-x86_64.AppImage
|
||||
./linuxdeploy-x86_64.AppImage --appimage-extract
|
||||
|
||||
# Create AppImage
|
||||
NO_STRIP=1 ./squashfs-root/AppRun -e colobot --output appimage --appdir colobot.AppDir -d desktop/colobot.desktop -i ../../desktop/colobot.svg
|
||||
chmod +x Colobot-x86_64.AppImage
|
||||
|
||||
# Prepare folder for zip
|
||||
mkdir -p appimage
|
||||
cp -rp install/data appimage/data
|
||||
cp -rp install/lang appimage/lang
|
||||
cp -p Colobot-x86_64.AppImage appimage/colobot
|
||||
'''
|
||||
}
|
||||
zip zipFile: 'linux-debug.zip', archive: true, dir: 'build/linux/appimage'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +98,9 @@ pipeline {
|
|||
}
|
||||
|
||||
stage('Generate docs') {
|
||||
agent {
|
||||
docker { image 'krzysh/colobot-build:latest' }
|
||||
}
|
||||
steps {
|
||||
dir('build/linux') {
|
||||
sh 'make doc'
|
||||
|
@ -81,6 +114,9 @@ pipeline {
|
|||
}
|
||||
|
||||
stage('Run tests') {
|
||||
agent {
|
||||
docker { image 'krzysh/colobot-build:latest' }
|
||||
}
|
||||
steps {
|
||||
dir('build/linux') {
|
||||
sh './colobot_ut --gtest_output=xml:gtestresults.xml || true'
|
||||
|
@ -91,6 +127,9 @@ pipeline {
|
|||
}
|
||||
|
||||
stage('Run colobot-lint') {
|
||||
agent {
|
||||
label 'colobot-build'
|
||||
}
|
||||
environment {
|
||||
CC = '/usr/lib/llvm-3.6/bin/clang'
|
||||
CXX = '/usr/lib/llvm-3.6/bin/clang++'
|
||||
|
@ -245,11 +284,10 @@ exit $ret
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: cppcheck publisher STILL doesn't have pipeline support
|
||||
// There is an open pull request though, merged but no release yet... https://github.com/jenkinsci/cppcheck-plugin/pull/36
|
||||
|
||||
publishCppcheck pattern: 'build/lint/colobot_lint_report.xml'
|
||||
publishHTML([reportName: 'Colobot-lint HTML report', reportDir: 'build/lint/html_report', reportFiles: 'index.html', reportTitles: '', allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)
|
||||
|
||||
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile)
|
||||
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile libsndfile-1)
|
||||
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)
|
||||
|
||||
IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
|
||||
|
|
|
@ -7,7 +7,7 @@ IF (WIN32)
|
|||
FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h
|
||||
DOC "The directory where physfs.h resides")
|
||||
FIND_LIBRARY( PHYSFS_LIBRARY
|
||||
NAMES physfs
|
||||
NAMES physfs physfs-static
|
||||
PATHS /mingw/lib
|
||||
DOC "The PhysFS library")
|
||||
ELSE (WIN32)
|
||||
|
|
2
data
2
data
|
@ -1 +1 @@
|
|||
Subproject commit 3cbab7144e6bf940015b2c33fdd17c7c2bfa804b
|
||||
Subproject commit dd12dbe39a7ad896ac6c73fd4e40c333259e1c84
|
|
@ -70,6 +70,12 @@ if(PLATFORM_GNU)
|
|||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
|
||||
)
|
||||
|
||||
# Install appdata
|
||||
install(
|
||||
FILES info.colobot.Colobot.appdata.xml
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo/
|
||||
)
|
||||
|
||||
# Install Icon
|
||||
install(
|
||||
FILES ${COLOBOT_ICON_FILE}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component>
|
||||
<id>info.colobot.Colobot</id>
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>GPL-3.0</project_license>
|
||||
<developer_name>TerranovaTeam</developer_name>
|
||||
<update_contact>contact@colobot.info</update_contact>
|
||||
<name>Colobot</name>
|
||||
<summary>Colonize with bots</summary>
|
||||
|
||||
<description>
|
||||
<p>Colobot (Colonize with Bots) is an educational game aiming to teach programming through entertainment. You are playing as an astronaut on a journey with robot helpers to find a planet for colonization. It features 3D real-time graphics and a C++ and Java-like, object-oriented language, CBOT, which can be used to program the robots available in the game.</p>
|
||||
</description>
|
||||
|
||||
<launchable type="desktop-id">colobot.desktop</launchable>
|
||||
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<caption>Alpha 0.1.5</caption>
|
||||
<image type="source" height="600" width="800">https://colobot.info/wordpress/wp-content/uploads/alpha-0.1.5.png</image>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
|
||||
<url type="homepage">https://colobot.info/</url>
|
||||
<url type="bugtracker">https://github.com/colobot/colobot/issues</url>
|
||||
<url type="help">http://colobot.info/forum/</url>
|
||||
<url type="donation">https://colobot.info/donate/</url>
|
||||
|
||||
<content_rating type="oars-1.1">
|
||||
<content_attribute id="violence-cartoon">moderate</content_attribute>
|
||||
<content_attribute id="violence-fantasy">moderate</content_attribute>
|
||||
<content_attribute id="violence-bloodshed">mild</content_attribute>
|
||||
</content_rating>
|
||||
|
||||
<releases>
|
||||
<release date="2018-04-10" version="0.1.11.1"/>
|
||||
</releases>
|
||||
</component>
|
|
@ -451,6 +451,9 @@ msgstr ""
|
|||
msgid "Shadow resolution\\Higher means better range and quality, but slower"
|
||||
msgstr ""
|
||||
|
||||
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
|
||||
msgstr ""
|
||||
|
||||
msgid "Standard controls\\Standard key functions"
|
||||
msgstr ""
|
||||
|
||||
|
|
11
po/cs.po
11
po/cs.po
|
@ -8,7 +8,7 @@ msgstr ""
|
|||
"Project-Id-Version: 0.1.11\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: DATE\n"
|
||||
"PO-Revision-Date: 2018-02-24 20:39+01\n"
|
||||
"PO-Revision-Date: 2018-08-20 22:48+02\n"
|
||||
"Last-Translator: next_ghost <next_ghost@quick.cz>\n"
|
||||
"Language-Team: Czech <next_ghost@quick.cz>\n"
|
||||
"Language: Czech\n"
|
||||
|
@ -1193,7 +1193,7 @@ msgid "Programming help\\Gives more detailed help with programming"
|
|||
msgstr "Nápověda\\Zobrazí nápovědu pro psaní programů"
|
||||
|
||||
msgid "Programs dispatched by Houston"
|
||||
msgstr "Program poslaný z Houstonu"
|
||||
msgstr "Programy poslané z Houstonu"
|
||||
|
||||
msgid "Public required"
|
||||
msgstr "Tato definice musí být veřejná (public)"
|
||||
|
@ -1548,7 +1548,7 @@ msgstr "Buchar"
|
|||
|
||||
#, c-format
|
||||
msgid "Time: %s"
|
||||
msgstr ""
|
||||
msgstr "Čas: %s"
|
||||
|
||||
msgid "Titanium"
|
||||
msgstr "Titan"
|
||||
|
@ -1664,6 +1664,9 @@ msgstr "Proměnná nebyla nastavena"
|
|||
msgid "Vault"
|
||||
msgstr "Trezor"
|
||||
|
||||
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
|
||||
msgstr ""
|
||||
|
||||
msgid "Violet flag"
|
||||
msgstr "Fialová vlajka"
|
||||
|
||||
|
@ -1741,7 +1744,7 @@ msgid "You cannot use \"%s\" in this exercise (used: %d)"
|
|||
msgstr "V tomto cvičení nesmíte použít \"%s\" (použito: %dx)"
|
||||
|
||||
msgid "You found a usable object"
|
||||
msgstr "Našli jste fungující objekt"
|
||||
msgstr "Našli jste použitelný objekt"
|
||||
|
||||
#, c-format
|
||||
msgid "You have to use \"%1$s\" at least once in this exercise (used: %2$d)"
|
||||
|
|
3
po/de.po
3
po/de.po
|
@ -1681,6 +1681,9 @@ msgstr "Der Wert dieser Variable wurde nicht definiert"
|
|||
msgid "Vault"
|
||||
msgstr "Bunker"
|
||||
|
||||
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
|
||||
msgstr ""
|
||||
|
||||
msgid "Violet flag"
|
||||
msgstr "Violette Fahne"
|
||||
|
||||
|
|
34
po/fr.po
34
po/fr.po
|
@ -1,19 +1,21 @@
|
|||
# Didier Raboud <odyx@debian.org>, 2012, 2015, 2016.
|
||||
# Martin Quinson <mquinson@debian.org>, 2016
|
||||
# B-CE, 2018
|
||||
# Pascal Audoux <pascal.audoux@gmail.com>, 2018
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Colobot 0.1.11\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: DATE\n"
|
||||
"PO-Revision-Date: 2018-02-28 20:00+0100\n"
|
||||
"PO-Revision-Date: 2019-01-09 23:07+0100\n"
|
||||
"Last-Translator: B-CE\n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
"X-Generator: Lokalize 2.0\n"
|
||||
"X-Generator: Poedit 2.0.6\n"
|
||||
"X-Language: fr_FR\n"
|
||||
"X-Source-Language: en_US\n"
|
||||
|
||||
|
@ -384,9 +386,8 @@ msgstr "Fermer"
|
|||
msgid "Closing bracket missing"
|
||||
msgstr "Il manque une parenthèse fermante"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Code battle"
|
||||
msgstr "Batailles de code"
|
||||
msgstr "Bataille de code"
|
||||
|
||||
msgid "Code battles"
|
||||
msgstr "Batailles de code"
|
||||
|
@ -501,7 +502,7 @@ msgid "Dynamic shadows ++\\Dynamic shadows + self shadowing"
|
|||
msgstr "Ombres dynamiques ++\\Active les ombres dynamiques et l'auto-ombrage"
|
||||
|
||||
msgid "Dynamic shadows\\Beautiful shadows!"
|
||||
msgstr "Ombres dynamiques\\Magnifiques ombres !"
|
||||
msgstr "Ombres dynamiques\\Magnifiques ombres !"
|
||||
|
||||
msgid "Edit the selected program"
|
||||
msgstr "Éditer le programme sélectionné"
|
||||
|
@ -647,7 +648,7 @@ msgid "Generating"
|
|||
msgstr "Génération"
|
||||
|
||||
msgid "Gold Edition development by:"
|
||||
msgstr "Édition Gold développée par :"
|
||||
msgstr "Édition Gold développée par :"
|
||||
|
||||
msgid "Goto: destination occupied"
|
||||
msgstr "Goto: destination occupée"
|
||||
|
@ -685,9 +686,8 @@ msgstr "Bulles d'aide\\Bulles explicatives"
|
|||
msgid "Hex value out of range"
|
||||
msgstr "Valeur hexadécimale impossible"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Higher speed\\Doubles speed"
|
||||
msgstr "Vitesse 2.0x\\Deux fois plus rapide"
|
||||
msgstr "Vitesse augmentée\\Deux fois plus rapide"
|
||||
|
||||
msgid "Highest\\Highest graphic quality (lowest frame rate)"
|
||||
msgstr "Maxi\\Haute qualité (+ lent)"
|
||||
|
@ -831,7 +831,7 @@ msgid "Loading basic level settings"
|
|||
msgstr "Chargement des configurations de base du niveau"
|
||||
|
||||
msgid "Loading finished!"
|
||||
msgstr "Chargement terminé !"
|
||||
msgstr "Chargement terminé !"
|
||||
|
||||
msgid "Loading music"
|
||||
msgstr "Chargement de la musique"
|
||||
|
@ -980,7 +980,7 @@ msgid "No uranium to transform"
|
|||
msgstr "Pas de minerai d'uranium à transformer"
|
||||
|
||||
msgid "No userlevels installed!"
|
||||
msgstr "Pas de niveaux spéciaux installés !"
|
||||
msgstr "Pas de niveaux spéciaux installés !"
|
||||
|
||||
msgid "Non-void function needs \"return;\""
|
||||
msgstr "Les fonctions avec retour autre que void doivent comporter l'instruction \"return;\""
|
||||
|
@ -1228,12 +1228,11 @@ msgstr "Chargement rapide\\Chargement direct d'une sauvegarde"
|
|||
msgid "Quick save\\Immediately save game"
|
||||
msgstr "Sauvegarde rapide\\Sauvegarde direct"
|
||||
|
||||
#, fuzzy
|
||||
msgid "Quicksave slot not found"
|
||||
msgstr "Objet n'existe pas"
|
||||
msgstr "Emplacement de sauvegarde rapide non trouvé"
|
||||
|
||||
msgid "Quit\\Quit Colobot: Gold Edition"
|
||||
msgstr "Quitter\\Quitter Colobot : Édition Gold"
|
||||
msgstr "Quitter\\Quitter Colobot : Édition Gold"
|
||||
|
||||
msgid "Quit\\Quit the current mission or exercise"
|
||||
msgstr "Quitter la mission en cours\\Terminer un exercice ou une mssion"
|
||||
|
@ -1568,7 +1567,7 @@ msgstr "Robot secoueur"
|
|||
|
||||
#, c-format
|
||||
msgid "Time: %s"
|
||||
msgstr ""
|
||||
msgstr "Temps : %s"
|
||||
|
||||
msgid "Titanium"
|
||||
msgstr "Titane"
|
||||
|
@ -1655,7 +1654,7 @@ msgid "Unknown command"
|
|||
msgstr "Commande inconnue"
|
||||
|
||||
msgid "Unknown escape sequence"
|
||||
msgstr ""
|
||||
msgstr "Séquence d'échappement inconnue"
|
||||
|
||||
msgid "Unknown function"
|
||||
msgstr "Routine inconnue"
|
||||
|
@ -1684,6 +1683,9 @@ msgstr "Variable non initialisée"
|
|||
msgid "Vault"
|
||||
msgstr "Coffre-fort"
|
||||
|
||||
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
|
||||
msgstr ""
|
||||
|
||||
msgid "Violet flag"
|
||||
msgstr "Drapeau violet"
|
||||
|
||||
|
@ -1827,7 +1829,7 @@ msgid "\\Red flags"
|
|||
msgstr "\\Drapeaux rouges"
|
||||
|
||||
msgid "\\Return to Colobot: Gold Edition"
|
||||
msgstr "\\Revenir à Colobot : Édition Gold"
|
||||
msgstr "\\Revenir à Colobot : Édition Gold"
|
||||
|
||||
msgid "\\SatCom on standby"
|
||||
msgstr "\\Mettre le SatCom en veille"
|
||||
|
|
3
po/pl.po
3
po/pl.po
|
@ -1663,6 +1663,9 @@ msgstr "Zmienna nie została zainicjalizowana"
|
|||
msgid "Vault"
|
||||
msgstr "Skrytka"
|
||||
|
||||
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
|
||||
msgstr "Synchronizacja pionowa\\Ogranicza ilość klatek na sekundę do wartości odświeżania ekranu"
|
||||
|
||||
msgid "Violet flag"
|
||||
msgstr "Fioletowa flaga"
|
||||
|
||||
|
|
3
po/ru.po
3
po/ru.po
|
@ -1694,6 +1694,9 @@ msgstr "Переменная не инициализирована"
|
|||
msgid "Vault"
|
||||
msgstr "Хранилище"
|
||||
|
||||
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
|
||||
msgstr ""
|
||||
|
||||
msgid "Violet flag"
|
||||
msgstr "Фиолетовый флаг"
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "CBot/CBotInstr/CBotFunction.h"
|
||||
#include "CBot/CBotInstr/CBotInstrCall.h"
|
||||
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
|
|
@ -151,7 +151,12 @@ set(LOCAL_INCLUDES
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
)
|
||||
|
||||
set(SYSTEM_INCLUDES
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
include_directories(${LOCAL_INCLUDES})
|
||||
include_directories(SYSTEM ${SYSTEM_INCLUDES})
|
||||
|
||||
|
||||
if(CBOT_STATIC)
|
||||
|
|
|
@ -44,8 +44,51 @@ if(MXE) # MXE requires special treatment
|
|||
elseif(PLATFORM_WINDOWS)
|
||||
# because it isn't included in standard linking libraries
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
find_library(LIBINTL_LIBRARY NAMES intl.lib)
|
||||
set(PLATFORM_LIBS ${LIBINTL_LIBRARY})
|
||||
find_library(LIBINTL_LIBRARY NAMES intl.lib libintl)
|
||||
|
||||
if(${MSVC_STATIC})
|
||||
if (${OPENAL_SOUND})
|
||||
find_library(FLAC_LIBRARY NAMES flac.lib)
|
||||
find_library(VORBIS_LIBRARY NAMES vorbis.lib)
|
||||
find_library(VORBISENC_LIBRARY NAMES vorbisenc.lib)
|
||||
find_library(OGG_LIBRARY NAMES ogg.lib)
|
||||
set(OPENAL_MSVC_LIBS
|
||||
${FLAC_LIBRARY}
|
||||
${VORBIS_LIBRARY}
|
||||
${VORBISENC_LIBRARY}
|
||||
${OGG_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(BZ2_LIBRARY NAMES bz2.lib)
|
||||
find_library(JPEG_LIBRARY NAMES jpeg.lib)
|
||||
find_library(TIFF_LIBRARY NAMES tiff.lib)
|
||||
find_library(WEBP_LIBRARY NAMES webp.lib)
|
||||
find_library(LZMA_LIBRARY NAMES lzma.lib)
|
||||
find_library(FREETYPE_LIBRARY NAMES freetype.lib)
|
||||
set(MSVC_LIBS
|
||||
${LIBINTL_LIBRARY}
|
||||
${OPENAL_MSVC_LIBS}
|
||||
${JPEG_LIBRARY}
|
||||
${TIFF_LIBRARY}
|
||||
${BZ2_LIBRARY}
|
||||
${WEBP_LIBRARY}
|
||||
${LZMA_LIBRARY}
|
||||
${FREETYPE_LIBRARY}
|
||||
winmm.lib
|
||||
dxguid.lib
|
||||
imm32.lib
|
||||
ole32.lib
|
||||
oleaut32.lib
|
||||
version.lib
|
||||
wsock32.lib
|
||||
ws2_32.lib
|
||||
)
|
||||
else(${MSVC_STATIC})
|
||||
set(MSVC_LIBS ${LIBINTL_LIBRARY})
|
||||
endif()
|
||||
|
||||
set(PLATFORM_LIBS ${MSVC_LIBS})
|
||||
else()
|
||||
set(PLATFORM_LIBS "-lintl")
|
||||
endif()
|
||||
|
@ -106,6 +149,8 @@ set(BASE_SOURCES
|
|||
common/error.h
|
||||
common/event.cpp
|
||||
common/event.h
|
||||
common/font_loader.h
|
||||
common/font_loader.cpp
|
||||
common/global.h
|
||||
common/image.cpp
|
||||
common/image.h
|
||||
|
|
|
@ -815,11 +815,29 @@ bool CApplication::CreateVideoSurface()
|
|||
m_private->glcontext = SDL_GL_CreateContext(m_private->window);
|
||||
|
||||
int vsync = 0;
|
||||
if (GetConfigFile().GetIntProperty("Experimental", "VSync", vsync))
|
||||
if (GetConfigFile().GetIntProperty("Setup", "VSync", vsync))
|
||||
{
|
||||
SDL_GL_SetSwapInterval(vsync);
|
||||
while (SDL_GL_SetSwapInterval(vsync) == -1)
|
||||
{
|
||||
switch(vsync)
|
||||
{
|
||||
case -1: //failed with adaptive sync?
|
||||
GetLogger()->Warn("Adaptive sync not supported.\n");
|
||||
vsync = 1;
|
||||
break;
|
||||
case 1: //failed with VSync enabled?
|
||||
GetLogger()->Warn("Couldn't enable VSync.\n");
|
||||
vsync = 0;
|
||||
break;
|
||||
case 0: //failed with VSync disabled?
|
||||
GetLogger()->Warn("Couldn't disable VSync.\n");
|
||||
vsync = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
GetConfigFile().SetIntProperty("Setup", "VSync", vsync);
|
||||
|
||||
GetLogger()->Info("Using Vsync: %s\n", (vsync ? "true" : "false"));
|
||||
GetLogger()->Info("Using Vsync: %s\n", (vsync == -1 ? "adaptive" : (vsync ? "true" : "false")));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -833,6 +851,27 @@ bool CApplication::ChangeVideoConfig(const Gfx::DeviceConfig &newConfig)
|
|||
SDL_SetWindowSize(m_private->window, m_deviceConfig.size.x, m_deviceConfig.size.y);
|
||||
SDL_SetWindowFullscreen(m_private->window, m_deviceConfig.fullScreen ? SDL_WINDOW_FULLSCREEN : 0);
|
||||
|
||||
int vsync = m_engine->GetVSync();
|
||||
while (SDL_GL_SetSwapInterval(vsync) == -1)
|
||||
{
|
||||
switch(vsync)
|
||||
{
|
||||
case -1: //failed with adaptive sync?
|
||||
GetLogger()->Warn("Adaptive sync not supported.\n");
|
||||
vsync = 1;
|
||||
break;
|
||||
case 1: //failed with VSync enabled?
|
||||
GetLogger()->Warn("Couldn't enable VSync.\n");
|
||||
vsync = 0;
|
||||
break;
|
||||
case 0: //failed with VSync disabled?
|
||||
GetLogger()->Warn("Couldn't disable VSync.\n");
|
||||
vsync = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_engine->SetVSync(vsync);
|
||||
|
||||
m_device->ConfigChanged(m_deviceConfig);
|
||||
|
||||
m_eventQueue->AddEvent(Event(EVENT_RESOLUTION_CHANGED));
|
||||
|
@ -1718,6 +1757,11 @@ char CApplication::GetLanguageChar() const
|
|||
case LANGUAGE_RUSSIAN:
|
||||
langChar = 'R';
|
||||
break;
|
||||
|
||||
case LANGUAGE_PORTUGUESE_BRAZILIAN:
|
||||
langChar = 'B';
|
||||
break;
|
||||
|
||||
}
|
||||
return langChar;
|
||||
}
|
||||
|
@ -1774,6 +1818,10 @@ void CApplication::SetLanguage(Language language)
|
|||
{
|
||||
m_language = LANGUAGE_RUSSIAN;
|
||||
}
|
||||
else if (strncmp(envLang,"pt",2) == 0)
|
||||
{
|
||||
m_language = LANGUAGE_PORTUGUESE_BRAZILIAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLogger()->Warn("Enviromnent locale ('%s') is not supported, setting default language\n", envLang);
|
||||
|
@ -1812,6 +1860,10 @@ void CApplication::SetLanguage(Language language)
|
|||
case LANGUAGE_RUSSIAN:
|
||||
locale = "ru_RU.utf8";
|
||||
break;
|
||||
|
||||
case LANGUAGE_PORTUGUESE_BRAZILIAN:
|
||||
locale = "pt_BR.utf8";
|
||||
break;
|
||||
}
|
||||
|
||||
std::string langStr = "LANGUAGE=";
|
||||
|
@ -1832,7 +1884,12 @@ void CApplication::SetLanguage(Language language)
|
|||
// Update C++ locale
|
||||
try
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||
// Avoids failed assertion in VS debugger
|
||||
throw -1;
|
||||
#else
|
||||
std::locale::global(std::locale(systemLocale.c_str()));
|
||||
#endif
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
|
|
@ -38,46 +38,41 @@
|
|||
#include <boost/filesystem.hpp>
|
||||
|
||||
CPathManager::CPathManager(CSystemUtils* systemUtils)
|
||||
: m_systemUtils(systemUtils)
|
||||
: m_dataPath(systemUtils->GetDataPath())
|
||||
, m_langPath(systemUtils->GetLangPath())
|
||||
, m_savePath(systemUtils->GetSaveDir())
|
||||
, m_modAutoloadDir{ m_dataPath + "/mods", m_savePath + "/mods" }
|
||||
, m_mods{}
|
||||
{
|
||||
#ifdef PORTABLE
|
||||
m_dataPath = "./data";
|
||||
m_langPath = "./lang";
|
||||
m_savePath = "./saves";
|
||||
#else
|
||||
m_dataPath = m_systemUtils->GetDataPath();
|
||||
m_langPath = m_systemUtils->GetLangPath();
|
||||
#ifdef DEV_BUILD
|
||||
m_savePath = "./saves";
|
||||
#else
|
||||
m_savePath = m_systemUtils->GetSaveDir();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
CPathManager::~CPathManager()
|
||||
{
|
||||
}
|
||||
|
||||
void CPathManager::SetDataPath(std::string dataPath)
|
||||
void CPathManager::SetDataPath(const std::string &dataPath)
|
||||
{
|
||||
m_dataPath = dataPath;
|
||||
}
|
||||
|
||||
void CPathManager::SetLangPath(std::string langPath)
|
||||
void CPathManager::SetLangPath(const std::string &langPath)
|
||||
{
|
||||
m_langPath = langPath;
|
||||
}
|
||||
|
||||
void CPathManager::SetSavePath(std::string savePath)
|
||||
void CPathManager::SetSavePath(const std::string &savePath)
|
||||
{
|
||||
m_savePath = savePath;
|
||||
}
|
||||
|
||||
void CPathManager::AddMod(std::string modPath)
|
||||
void CPathManager::AddModAutoloadDir(const std::string &modAutoloadDirPath)
|
||||
{
|
||||
GetLogger()->Info("Loading mod: '%s'\n", modPath.c_str());
|
||||
CResourceManager::AddLocation(modPath, true);
|
||||
m_modAutoloadDir.push_back(modAutoloadDirPath);
|
||||
}
|
||||
|
||||
void CPathManager::AddMod(const std::string &modPath)
|
||||
{
|
||||
m_mods.push_back(modPath);
|
||||
}
|
||||
|
||||
const std::string& CPathManager::GetDataPath()
|
||||
|
@ -133,19 +128,51 @@ std::string CPathManager::VerifyPaths()
|
|||
|
||||
void CPathManager::InitPaths()
|
||||
{
|
||||
LoadModsFromDir(m_dataPath+"/mods");
|
||||
LoadModsFromDir(m_savePath+"/mods");
|
||||
|
||||
GetLogger()->Info("Data path: %s\n", m_dataPath.c_str());
|
||||
GetLogger()->Info("Save path: %s\n", m_savePath.c_str());
|
||||
CResourceManager::AddLocation(m_dataPath, false);
|
||||
if (!m_modAutoloadDir.empty())
|
||||
{
|
||||
GetLogger()->Info("Mod autoload dirs:\n");
|
||||
for(const std::string& modAutoloadDir : m_modAutoloadDir)
|
||||
GetLogger()->Info(" * %s\n", modAutoloadDir.c_str());
|
||||
}
|
||||
if (!m_mods.empty())
|
||||
{
|
||||
GetLogger()->Info("Mods:\n");
|
||||
for(const std::string& modPath : m_mods)
|
||||
GetLogger()->Info(" * %s\n", modPath.c_str());
|
||||
}
|
||||
|
||||
CResourceManager::AddLocation(m_dataPath);
|
||||
|
||||
for (const std::string& modAutoloadDir : m_modAutoloadDir)
|
||||
{
|
||||
GetLogger()->Trace("Searching for mods in '%s'...\n", modAutoloadDir.c_str());
|
||||
for (const std::string& modPath : FindModsInDir(modAutoloadDir))
|
||||
{
|
||||
GetLogger()->Info("Autoloading mod: '%s'\n", modPath.c_str());
|
||||
CResourceManager::AddLocation(modPath);
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::string& modPath : m_mods)
|
||||
{
|
||||
GetLogger()->Info("Loading mod: '%s'\n", modPath.c_str());
|
||||
CResourceManager::AddLocation(modPath);
|
||||
}
|
||||
|
||||
CResourceManager::SetSaveLocation(m_savePath);
|
||||
CResourceManager::AddLocation(m_savePath, true);
|
||||
CResourceManager::AddLocation(m_savePath);
|
||||
|
||||
GetLogger()->Debug("Finished initalizing data paths\n");
|
||||
GetLogger()->Debug("PHYSFS search path is:\n");
|
||||
for (const std::string& path : CResourceManager::GetLocations())
|
||||
GetLogger()->Debug(" * %s\n", path.c_str());
|
||||
}
|
||||
|
||||
void CPathManager::LoadModsFromDir(const std::string &dir)
|
||||
std::vector<std::string> CPathManager::FindModsInDir(const std::string &dir)
|
||||
{
|
||||
GetLogger()->Trace("Looking for mods in '%s' ...\n", dir.c_str());
|
||||
std::vector<std::string> ret;
|
||||
try
|
||||
{
|
||||
#if PLATFORM_WINDOWS
|
||||
|
@ -156,9 +183,9 @@ void CPathManager::LoadModsFromDir(const std::string &dir)
|
|||
for(; iterator != boost::filesystem::directory_iterator(); ++iterator)
|
||||
{
|
||||
#if PLATFORM_WINDOWS
|
||||
AddMod(CSystemUtilsWindows::UTF8_Encode(iterator->path().wstring()));
|
||||
ret.push_back(CSystemUtilsWindows::UTF8_Encode(iterator->path().wstring()));
|
||||
#else
|
||||
AddMod(iterator->path().string());
|
||||
ret.push_back(iterator->path().string());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -166,4 +193,5 @@ void CPathManager::LoadModsFromDir(const std::string &dir)
|
|||
{
|
||||
GetLogger()->Warn("Unable to load mods from directory '%s': %s\n", dir.c_str(), e.what());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -17,16 +17,10 @@
|
|||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file app/pathman.h
|
||||
* \brief Class for managing data/lang/save paths
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CSystemUtils;
|
||||
|
||||
|
@ -34,16 +28,17 @@ class CSystemUtils;
|
|||
* \class CPathManager
|
||||
* \brief Class for managing data/lang/save paths
|
||||
*/
|
||||
class CPathManager : public CSingleton<CPathManager>
|
||||
class CPathManager
|
||||
{
|
||||
public:
|
||||
CPathManager(CSystemUtils* systemUtils);
|
||||
~CPathManager();
|
||||
|
||||
void SetDataPath(std::string dataPath);
|
||||
void SetLangPath(std::string langPath);
|
||||
void SetSavePath(std::string savePath);
|
||||
void AddMod(std::string modPath);
|
||||
void SetDataPath(const std::string &dataPath);
|
||||
void SetLangPath(const std::string &langPath);
|
||||
void SetSavePath(const std::string &savePath);
|
||||
void AddModAutoloadDir(const std::string &modAutoloadDirPath);
|
||||
void AddMod(const std::string &modPath);
|
||||
|
||||
const std::string& GetDataPath();
|
||||
const std::string& GetLangPath();
|
||||
|
@ -56,14 +51,17 @@ public:
|
|||
|
||||
private:
|
||||
//! Loads all mods from given directory
|
||||
void LoadModsFromDir(const std::string &dir);
|
||||
std::vector<std::string> FindModsInDir(const std::string &dir);
|
||||
|
||||
private:
|
||||
CSystemUtils* m_systemUtils;
|
||||
//! Data path
|
||||
std::string m_dataPath;
|
||||
//! Lang path
|
||||
std::string m_langPath;
|
||||
//! Save path
|
||||
std::string m_savePath;
|
||||
//! Mod autoload paths
|
||||
std::vector<std::string> m_modAutoloadDir;
|
||||
//! Mod paths
|
||||
std::vector<std::string> m_mods;
|
||||
};
|
||||
|
|
|
@ -133,7 +133,7 @@ void CSignalHandlers::ReportError(const std::string& errorMessage)
|
|||
msg << "including information on what you were doing before this happened and all the information below." << std::endl;
|
||||
msg << "==============================" << std::endl;
|
||||
#if BUILD_NUMBER == 0
|
||||
#ifdef OFFICIAL_BUILD
|
||||
#ifdef OFFICIAL_COLOBOT_BUILD
|
||||
msg << "You are running official " << COLOBOT_VERSION_DISPLAY << " build." << std::endl;
|
||||
#else
|
||||
// COLOBOT_VERSION_DISPLAY doesn't update if you don't run CMake after "git pull"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#cmakedefine OPENAL_SOUND
|
||||
|
||||
#cmakedefine PORTABLE @PORTABLE@
|
||||
#cmakedefine PORTABLE_SAVES @PORTABLE_SAVES@
|
||||
|
||||
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
|
||||
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
|
||||
|
|
|
@ -232,6 +232,7 @@ void InitializeEventTypeTexts()
|
|||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SHADOW_MAPPING_QUALITY] = "EVENT_INTERFACE_SHADOW_MAPPING_QUALITY";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_SHADOW_MAPPING_BUFFER] = "EVENT_INTERFACE_SHADOW_MAPPING_BUFFER";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_LANGUAGE] = "EVENT_INTERFACE_LANGUAGE";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_VSYNC] = "EVENT_INTERFACE_VSYNC";
|
||||
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO1] = "EVENT_INTERFACE_KINFO1";
|
||||
EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO2] = "EVENT_INTERFACE_KINFO2";
|
||||
|
|
|
@ -268,6 +268,7 @@ enum EventType
|
|||
EVENT_INTERFACE_SHADOW_MAPPING_QUALITY = 788,
|
||||
EVENT_INTERFACE_SHADOW_MAPPING_BUFFER = 789,
|
||||
EVENT_INTERFACE_LANGUAGE = 790,
|
||||
EVENT_INTERFACE_VSYNC = 791,
|
||||
|
||||
EVENT_INTERFACE_KINFO1 = 500,
|
||||
EVENT_INTERFACE_KINFO2 = 501,
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "common/font_loader.h"
|
||||
|
||||
#include "common/logger.h"
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#include "common/resources/inputstream.h"
|
||||
#include "common/resources/outputstream.h"
|
||||
|
||||
#include "common/system/system.h"
|
||||
|
||||
#include "graphics/engine/text.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <cstring>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
namespace bp = boost::property_tree;
|
||||
|
||||
const std::map<Gfx::FontType, std::string> DEFAULT_FONT =
|
||||
{
|
||||
{ Gfx::FONT_COMMON, "dvu_sans.ttf" },
|
||||
{ Gfx::FONT_COMMON_BOLD, "dvu_sans_bold.ttf" },
|
||||
{ Gfx::FONT_COMMON_ITALIC, "dvu_sans_italic.ttf" },
|
||||
{ Gfx::FONT_STUDIO, "dvu_sans_mono.ttf" },
|
||||
{ Gfx::FONT_STUDIO_BOLD, "dvu_sans_mono_bold.ttf" },
|
||||
{ Gfx::FONT_STUDIO_ITALIC, "dvu_sans_mono.ttf" }, //placeholder for future use, DejaVu Sans Mono doesn't have italic variant
|
||||
{ Gfx::FONT_SATCOM, "dvu_sans.ttf" },
|
||||
{ Gfx::FONT_SATCOM_BOLD, "dvu_sans_bold.ttf" },
|
||||
{ Gfx::FONT_SATCOM_ITALIC, "dvu_sans_italic.ttf" },
|
||||
};
|
||||
|
||||
const std::map<Gfx::FontType, std::string> FONT_TYPE =
|
||||
{
|
||||
{ Gfx::FONT_COMMON, "FontCommon" },
|
||||
{ Gfx::FONT_COMMON_BOLD, "FontCommonBold" },
|
||||
{ Gfx::FONT_COMMON_ITALIC, "FontCommonItalic" },
|
||||
{ Gfx::FONT_STUDIO, "FontStudio" },
|
||||
{ Gfx::FONT_STUDIO_BOLD, "FontStudioBold" },
|
||||
{ Gfx::FONT_STUDIO_ITALIC, "FontStudioItalic" },
|
||||
{ Gfx::FONT_SATCOM, "FontSatCom" },
|
||||
{ Gfx::FONT_SATCOM_BOLD, "FontSatComBold" },
|
||||
{ Gfx::FONT_SATCOM_ITALIC, "FontSatComItalic" },
|
||||
};
|
||||
|
||||
CFontLoader::CFontLoader()
|
||||
{
|
||||
}
|
||||
|
||||
CFontLoader::~CFontLoader()
|
||||
{
|
||||
}
|
||||
|
||||
bool CFontLoader::Init()
|
||||
{
|
||||
try
|
||||
{
|
||||
std::unique_ptr<std::istream> stream;
|
||||
auto inputStream = MakeUnique<CInputStream>("/fonts/fonts.ini");
|
||||
bool good = inputStream->is_open();
|
||||
stream = std::move(inputStream);
|
||||
|
||||
if (good)
|
||||
{
|
||||
bp::ini_parser::read_ini(*stream, m_propertyTree);
|
||||
GetLogger()->Debug("Fonts config file loaded correctly. \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
GetLogger()->Error("Error on parsing config file: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CFontLoader::GetFont(Gfx::FontType type)
|
||||
{
|
||||
return std::string("/fonts/") + m_propertyTree.get<std::string>(GetFontType(type), GetDefaultFont(type));
|
||||
}
|
||||
|
||||
std::string CFontLoader::GetDefaultFont(Gfx::FontType type) const
|
||||
{
|
||||
return DEFAULT_FONT.at(type);
|
||||
}
|
||||
|
||||
std::string CFontLoader::GetFontType(Gfx::FontType type) const
|
||||
{
|
||||
return FONT_TYPE.at(type);
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file common/font_loader.h
|
||||
* \brief Class for loading fonts from /data/fonts/fonts.ini
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "graphics/engine/text.h"
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* \class CFontLoader
|
||||
*
|
||||
* \brief Class for loading config file
|
||||
*
|
||||
*/
|
||||
|
||||
class CFontLoader
|
||||
{
|
||||
public:
|
||||
CFontLoader();
|
||||
virtual ~CFontLoader();
|
||||
|
||||
/** Loads fonts.ini
|
||||
* \return return true on success
|
||||
*/
|
||||
bool Init();
|
||||
|
||||
/** Reads given font from file
|
||||
* \return return path to font file
|
||||
*/
|
||||
std::string GetFont(Gfx::FontType type);
|
||||
|
||||
/** Const type method to read filenames of fonts from defaultFont map
|
||||
* used as a fallback if it wasn't possible to read font from fonts.ini
|
||||
* \return return filename of default path
|
||||
*/
|
||||
std::string GetDefaultFont(Gfx::FontType type) const;
|
||||
|
||||
/** Const type method converting Gfx::FontType to string
|
||||
* \return return id of font used in fonts.ini file
|
||||
*/
|
||||
|
||||
std::string GetFontType(Gfx::FontType type) const;
|
||||
|
||||
private:
|
||||
boost::property_tree::ptree m_propertyTree;
|
||||
};
|
|
@ -27,7 +27,8 @@ const std::map<Language, std::string> LANGUAGE_MAP = {
|
|||
{ LANGUAGE_GERMAN, "de" },
|
||||
{ LANGUAGE_FRENCH, "fr" },
|
||||
{ LANGUAGE_POLISH, "pl" },
|
||||
{ LANGUAGE_RUSSIAN, "ru" }
|
||||
{ LANGUAGE_RUSSIAN, "ru" },
|
||||
{ LANGUAGE_PORTUGUESE_BRAZILIAN, "pt" }
|
||||
};
|
||||
|
||||
bool ParseLanguage(const std::string& str, Language& language)
|
||||
|
|
|
@ -33,7 +33,8 @@ enum Language
|
|||
LANGUAGE_GERMAN = 2,
|
||||
LANGUAGE_POLISH = 3,
|
||||
LANGUAGE_RUSSIAN = 4,
|
||||
LANGUAGE_CZECH = 5
|
||||
LANGUAGE_CZECH = 5,
|
||||
LANGUAGE_PORTUGUESE_BRAZILIAN = 6
|
||||
};
|
||||
|
||||
bool ParseLanguage(const std::string& str, Language& language);
|
||||
|
|
|
@ -85,6 +85,16 @@ bool CResourceManager::RemoveLocation(const std::string &location)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> CResourceManager::GetLocations()
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
char **list = PHYSFS_getSearchPath();
|
||||
for (char **it = list; *it != nullptr; ++it)
|
||||
ret.push_back(*it);
|
||||
PHYSFS_freeList(list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool CResourceManager::SetSaveLocation(const std::string &location)
|
||||
{
|
||||
|
|
|
@ -35,8 +35,12 @@ public:
|
|||
|
||||
static std::string CleanPath(const std::string &path);
|
||||
|
||||
//! Add a location to the search path
|
||||
static bool AddLocation(const std::string &location, bool prepend = true);
|
||||
//! Remove a location from the search path
|
||||
static bool RemoveLocation(const std::string &location);
|
||||
//! List all locations in the search path
|
||||
static std::vector<std::string> GetLocations();
|
||||
|
||||
static bool SetSaveLocation(const std::string &location);
|
||||
static std::string GetSaveLocation();
|
||||
|
|
|
@ -48,6 +48,9 @@ const char* stringsCbot[CBot::CBotErrMAX] = { nullptr };
|
|||
*/
|
||||
#define TR(x) x
|
||||
|
||||
/* Please run `make update-pot` after changing this file
|
||||
* in order to update translation files. Thank you.
|
||||
*/
|
||||
|
||||
void InitializeRestext()
|
||||
{
|
||||
|
@ -216,6 +219,7 @@ void InitializeRestext()
|
|||
stringsEvent[EVENT_INTERFACE_SHADOW_MAPPING] = TR("Dynamic shadows\\Beautiful shadows!");
|
||||
stringsEvent[EVENT_INTERFACE_SHADOW_MAPPING_QUALITY]= TR("Dynamic shadows ++\\Dynamic shadows + self shadowing");
|
||||
stringsEvent[EVENT_INTERFACE_SHADOW_MAPPING_BUFFER] = TR("Shadow resolution\\Higher means better range and quality, but slower");
|
||||
stringsEvent[EVENT_INTERFACE_VSYNC] = TR("Vertical Synchronization\\Limits the number of frames per second to display frequency");
|
||||
|
||||
stringsEvent[EVENT_INTERFACE_KDEF] = TR("Standard controls\\Standard key functions");
|
||||
assert(INPUT_SLOT_MAX < EVENT_INTERFACE_KEY_END-EVENT_INTERFACE_KEY);
|
||||
|
|
|
@ -112,6 +112,7 @@ void CSettings::SaveSettings()
|
|||
|
||||
// Experimental settings
|
||||
GetConfigFile().SetBoolProperty("Experimental", "TerrainShadows", engine->GetTerrainShadows());
|
||||
GetConfigFile().SetIntProperty("Setup", "VSync", engine->GetVSync());
|
||||
|
||||
CInput::GetInstancePointer()->SaveKeyBindings();
|
||||
|
||||
|
@ -274,6 +275,10 @@ void CSettings::LoadSettings()
|
|||
|
||||
if (GetConfigFile().GetBoolProperty("Experimental", "TerrainShadows", bValue))
|
||||
engine->SetTerrainShadows(bValue);
|
||||
if (GetConfigFile().GetIntProperty("Setup", "VSync", iValue))
|
||||
{
|
||||
engine->SetVSync(iValue);
|
||||
}
|
||||
|
||||
CInput::GetInstancePointer()->LoadKeyBindings();
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "common/system/system.h"
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#include "common/make_unique.h"
|
||||
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
|
@ -190,5 +188,5 @@ std::string CSystemUtils::GetLangPath()
|
|||
|
||||
std::string CSystemUtils::GetSaveDir()
|
||||
{
|
||||
return std::string("saves");
|
||||
return "./saves";
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
|
@ -96,16 +96,20 @@ long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemT
|
|||
|
||||
std::string CSystemUtilsLinux::GetSaveDir()
|
||||
{
|
||||
#if PORTABLE_SAVES || DEV_BUILD
|
||||
return CSystemUtils::GetSaveDir();
|
||||
#else
|
||||
std::string savegameDir;
|
||||
|
||||
// Determine savegame dir according to XDG Base Directory Specification
|
||||
char *envXDG_DATA_HOME = getenv("XDG_CONFIG_DATA");
|
||||
char *envXDG_DATA_HOME = getenv("XDG_DATA_HOME");
|
||||
if (envXDG_DATA_HOME == nullptr)
|
||||
{
|
||||
char *envHOME = getenv("HOME");
|
||||
if (envHOME == nullptr)
|
||||
{
|
||||
savegameDir = "/tmp/colobot-save";
|
||||
GetLogger()->Warn("Unable to find directory for saves - using current directory");
|
||||
savegameDir = "./saves";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -119,6 +123,7 @@ std::string CSystemUtilsLinux::GetSaveDir()
|
|||
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
|
||||
|
||||
return savegameDir;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSystemUtilsLinux::Usleep(int usec)
|
||||
|
|
|
@ -102,10 +102,15 @@ std::string CSystemUtilsMacOSX::GetLangPath()
|
|||
|
||||
std::string CSystemUtilsMacOSX::GetSaveDir()
|
||||
{
|
||||
#if PORTABLE_SAVES || DEV_BUILD
|
||||
// TODO: I have no idea if this actually works on Mac OS
|
||||
return "./saves";
|
||||
#else
|
||||
std::string savegameDir = m_ASPath;
|
||||
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
|
||||
|
||||
return savegameDir;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSystemUtilsMacOSX::Usleep(int usec)
|
||||
|
|
|
@ -110,11 +110,15 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
|
|||
|
||||
std::string CSystemUtilsWindows::GetSaveDir()
|
||||
{
|
||||
#if PORTABLE_SAVES || DEV_BUILD
|
||||
return CSystemUtils::GetSaveDir();
|
||||
#else
|
||||
std::string savegameDir;
|
||||
|
||||
wchar_t* envUSERPROFILE = _wgetenv(L"USERPROFILE");
|
||||
if (envUSERPROFILE == nullptr)
|
||||
{
|
||||
GetLogger()->Warn("Unable to find directory for saves - using current directory");
|
||||
savegameDir = "./saves";
|
||||
}
|
||||
else
|
||||
|
@ -124,6 +128,7 @@ std::string CSystemUtilsWindows::GetSaveDir()
|
|||
GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
|
||||
|
||||
return savegameDir;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSystemUtilsWindows::Usleep(int usec)
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
#define COLOBOT_VERSION_DISPLAY "@COLOBOT_VERSION_DISPLAY@"
|
||||
|
||||
#define BUILD_NUMBER @BUILD_NUMBER@
|
||||
#cmakedefine OFFICIAL_BUILD
|
||||
#cmakedefine OFFICIAL_COLOBOT_BUILD
|
||||
|
|
|
@ -416,14 +416,6 @@ public:
|
|||
//! Sets only the texture wrap modes (for faster than thru stage params)
|
||||
virtual void SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode wrapT) = 0;
|
||||
|
||||
//! Renders primitive composed of generic vertices
|
||||
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount) = 0;
|
||||
|
||||
//! Renders multiple primitives composed of generic vertices
|
||||
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount) = 0;
|
||||
|
||||
//! Renders primitive composed of vertices with single texture
|
||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) = 0;
|
||||
|
|
|
@ -41,10 +41,15 @@ struct FramebufferParams
|
|||
int depth = 16;
|
||||
//! Requested number of samples for multisampling
|
||||
int samples = 1;
|
||||
//! true requests color texture
|
||||
bool colorTexture = false;
|
||||
//! true requests depth texture
|
||||
bool depthTexture = false;
|
||||
|
||||
enum class AttachmentType
|
||||
{
|
||||
Texture,
|
||||
Renderbuffer,
|
||||
None,
|
||||
};
|
||||
AttachmentType colorAttachment = AttachmentType::Renderbuffer;
|
||||
AttachmentType depthAttachment = AttachmentType::Renderbuffer;
|
||||
|
||||
//! Loads default values
|
||||
void LoadDefault()
|
||||
|
|
|
@ -168,16 +168,6 @@ void CNullDevice::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
|
|||
{
|
||||
}
|
||||
|
||||
void CNullDevice::DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount)
|
||||
{
|
||||
}
|
||||
|
||||
void CNullDevice::DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount)
|
||||
{
|
||||
}
|
||||
|
||||
void CNullDevice::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||
int first[], int count[], int drawCount, Color color)
|
||||
{
|
||||
|
|
|
@ -81,11 +81,6 @@ public:
|
|||
|
||||
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
|
||||
|
||||
void DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount) override;
|
||||
void DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
|
||||
|
||||
void DrawPrimitive(PrimitiveType type, const Vertex* vertices, int vertexCount, Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||
void DrawPrimitive(PrimitiveType type, const VertexTex2* vertices, int vertexCount, Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||
void DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount) override;
|
||||
|
|
|
@ -39,57 +39,11 @@
|
|||
namespace Gfx
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* \struct VertexAttribute
|
||||
* \brief Vertex attribute
|
||||
*
|
||||
* This structure contains parameters for a vertex attribute.
|
||||
*/
|
||||
struct VertexAttribute
|
||||
enum VertexType
|
||||
{
|
||||
//! true enables vertex attribute
|
||||
bool enabled = false;
|
||||
//! true means normalized value (integer types only)
|
||||
bool normalized = false;
|
||||
//! Number of elements in the vertex attribute.
|
||||
//! Valid values are 1, 2, 3, and 4. Depends on specific attribute.
|
||||
unsigned char size = 0;
|
||||
//! Type of values in vertex attribute
|
||||
Type type = Type::UBYTE;
|
||||
//! Offset to the vertex attribute
|
||||
int offset = 0;
|
||||
//! Stride of vertex attribute
|
||||
int stride = 0;
|
||||
//! Default values used when attribute is disabled
|
||||
float values[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
};
|
||||
|
||||
/**
|
||||
* \struct VertexFormat
|
||||
* \brief Vertex format
|
||||
*
|
||||
* This structure defines vertex formats for generic vertex arrays.
|
||||
*
|
||||
* It contains:
|
||||
* - vertex coordinate specification
|
||||
* - color specification
|
||||
* - normal specification
|
||||
* - texture coordinate 1 specification
|
||||
* - texture coordinate 2 specification
|
||||
*/
|
||||
struct VertexFormat
|
||||
{
|
||||
//! Vertex coordinate
|
||||
VertexAttribute vertex{};
|
||||
//! Color
|
||||
VertexAttribute color{};
|
||||
//! Normal
|
||||
VertexAttribute normal{};
|
||||
//! Texture coordinate 1
|
||||
VertexAttribute tex1{};
|
||||
//! Texture coordinate 2
|
||||
VertexAttribute tex2{};
|
||||
VERTEX_TYPE_NORMAL,
|
||||
VERTEX_TYPE_TEX2,
|
||||
VERTEX_TYPE_COL,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -105,6 +59,8 @@ struct VertexFormat
|
|||
*/
|
||||
struct Vertex
|
||||
{
|
||||
static constexpr VertexType VERTEX_TYPE = VERTEX_TYPE_NORMAL;
|
||||
|
||||
Math::Vector coord;
|
||||
Math::Vector normal;
|
||||
Math::Point texCoord;
|
||||
|
@ -137,6 +93,8 @@ struct Vertex
|
|||
*/
|
||||
struct VertexCol
|
||||
{
|
||||
static constexpr VertexType VERTEX_TYPE = VERTEX_TYPE_COL;
|
||||
|
||||
Math::Vector coord;
|
||||
Color color;
|
||||
|
||||
|
@ -166,6 +124,8 @@ struct VertexCol
|
|||
*/
|
||||
struct VertexTex2
|
||||
{
|
||||
static constexpr VertexType VERTEX_TYPE = VERTEX_TYPE_TEX2;
|
||||
|
||||
Math::Vector coord;
|
||||
Math::Vector normal;
|
||||
Math::Point texCoord;
|
||||
|
|
|
@ -197,6 +197,7 @@ CEngine::CEngine(CApplication *app, CSystemUtils* systemUtils)
|
|||
m_terrainShadows = false;
|
||||
m_shadowRange = 0.0f;
|
||||
m_multisample = 2;
|
||||
m_vsync = 0;
|
||||
|
||||
m_backForce = true;
|
||||
m_lightMode = true;
|
||||
|
@ -323,6 +324,7 @@ bool CEngine::Create()
|
|||
SetShadowMappingOffscreen(m_offscreenShadowRendering);
|
||||
SetShadowMappingOffscreenResolution(m_offscreenShadowRenderingResolution);
|
||||
SetMultiSample(m_multisample);
|
||||
SetVSync(m_vsync);
|
||||
|
||||
m_modelManager = MakeUnique<COldModelManager>(this);
|
||||
m_pyroManager = MakeUnique<CPyroManager>();
|
||||
|
@ -431,7 +433,7 @@ bool CEngine::ProcessEvent(const Event &event)
|
|||
{
|
||||
auto data = event.GetData<KeyEventData>();
|
||||
|
||||
if (data->key == KEY(F12))
|
||||
if (data->key == KEY(F11) || data->key == KEY(F12))
|
||||
{
|
||||
m_showStats = !m_showStats;
|
||||
return false;
|
||||
|
@ -3023,6 +3025,19 @@ bool CEngine::GetTerrainShadows()
|
|||
return m_terrainShadows;
|
||||
}
|
||||
|
||||
void CEngine::SetVSync(int value)
|
||||
{
|
||||
if (value < -1) value = -1;
|
||||
if (value > 1) value = 1;
|
||||
if(m_vsync == value) return;
|
||||
m_vsync = value;
|
||||
}
|
||||
|
||||
int CEngine::GetVSync()
|
||||
{
|
||||
return m_vsync;
|
||||
}
|
||||
|
||||
void CEngine::SetBackForce(bool present)
|
||||
{
|
||||
m_backForce = present;
|
||||
|
@ -3786,7 +3801,8 @@ void CEngine::RenderShadowMap()
|
|||
FramebufferParams params;
|
||||
params.width = params.height = width;
|
||||
params.depth = depth = 32;
|
||||
params.depthTexture = true;
|
||||
params.colorAttachment = FramebufferParams::AttachmentType::None;
|
||||
params.depthAttachment = FramebufferParams::AttachmentType::Texture;
|
||||
|
||||
CFramebuffer *framebuffer = m_device->CreateFramebuffer("shadow", params);
|
||||
if (framebuffer == nullptr)
|
||||
|
@ -4032,7 +4048,10 @@ void CEngine::UseMSAA(bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
if (framebuffer != nullptr)
|
||||
{
|
||||
framebuffer->Bind();
|
||||
}
|
||||
|
||||
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, true);
|
||||
m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, true);
|
||||
|
@ -5117,7 +5136,7 @@ void CEngine::DrawStats()
|
|||
if (!m_showStats)
|
||||
return;
|
||||
|
||||
float height = m_text->GetAscent(FONT_COLOBOT, 13.0f);
|
||||
float height = m_text->GetAscent(FONT_COMMON, 13.0f);
|
||||
float width = 0.4f;
|
||||
const int TOTAL_LINES = 22;
|
||||
|
||||
|
@ -5144,13 +5163,13 @@ void CEngine::DrawStats()
|
|||
auto drawStatsLine = [&](const std::string& name, const std::string& value, const std::string& value2)
|
||||
{
|
||||
if (!name.empty())
|
||||
m_text->DrawText(name+":", FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
m_text->DrawText(name+":", FONT_COMMON, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pos.x += 0.25f;
|
||||
if (!value.empty())
|
||||
m_text->DrawText(value, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
m_text->DrawText(value, FONT_COMMON, 12.0f, pos, 1.0f, TEXT_ALIGN_LEFT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pos.x += 0.15f;
|
||||
if (!value2.empty())
|
||||
m_text->DrawText(value2, FONT_COLOBOT, 12.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
m_text->DrawText(value2, FONT_COMMON, 12.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pos.x -= 0.4f;
|
||||
pos.y -= height;
|
||||
};
|
||||
|
@ -5218,8 +5237,8 @@ void CEngine::DrawTimer()
|
|||
{
|
||||
SetState(ENG_RSTATE_TEXT);
|
||||
|
||||
Math::Point pos(0.98f, 0.98f-m_text->GetAscent(FONT_COLOBOT, 15.0f));
|
||||
m_text->DrawText(m_timerText, FONT_COLOBOT, 15.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
Math::Point pos(0.98f, 0.98f-m_text->GetAscent(FONT_COMMON, 15.0f));
|
||||
m_text->DrawText(m_timerText, FONT_COMMON, 15.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles)
|
||||
|
|
|
@ -1072,6 +1072,13 @@ public:
|
|||
bool GetTerrainShadows();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
//! Management of vertical synchronization
|
||||
// NOTE: This is an user configuration setting
|
||||
void SetVSync(int value);
|
||||
int GetVSync();
|
||||
//@}
|
||||
|
||||
//@{
|
||||
//! Management of shadow color
|
||||
// NOTE: This is a setting configurable only in INI file
|
||||
|
@ -1336,6 +1343,9 @@ protected:
|
|||
//! Texture bias for sampling shadow maps
|
||||
Math::Matrix m_shadowBias;
|
||||
|
||||
//! Vertical synchronization controll
|
||||
int m_vsync;
|
||||
|
||||
//! World matrix for 2D interface
|
||||
Math::Matrix m_matWorldInterface;
|
||||
//! Projection matrix for 2D interface
|
||||
|
|
|
@ -3301,7 +3301,7 @@ void CParticle::DrawParticleCylinder(int i)
|
|||
|
||||
void CParticle::DrawParticleText(int i)
|
||||
{
|
||||
CharTexture tex = m_engine->GetText()->GetCharTexture(static_cast<UTF8Char>(m_particle[i].text), FONT_COURIER, FONT_SIZE_BIG*2.0f);
|
||||
CharTexture tex = m_engine->GetText()->GetCharTexture(static_cast<UTF8Char>(m_particle[i].text), FONT_STUDIO, FONT_SIZE_BIG*2.0f);
|
||||
if (tex.id == 0) return;
|
||||
|
||||
m_device->SetTexture(0, tex.id);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "app/app.h"
|
||||
|
||||
#include "common/font_loader.h"
|
||||
#include "common/image.h"
|
||||
#include "common/logger.h"
|
||||
#include "common/stringutils.h"
|
||||
|
@ -32,6 +33,7 @@
|
|||
|
||||
#include "math/func.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
|
@ -174,7 +176,7 @@ CText::CText(CEngine* engine)
|
|||
m_defaultSize = 12.0f;
|
||||
m_tabSize = 4;
|
||||
|
||||
m_lastFontType = FONT_COLOBOT;
|
||||
m_lastFontType = FONT_COMMON;
|
||||
m_lastFontSize = 0;
|
||||
m_lastCachedFont = nullptr;
|
||||
|
||||
|
@ -189,18 +191,23 @@ CText::~CText()
|
|||
|
||||
bool CText::Create()
|
||||
{
|
||||
CFontLoader fontLoader;
|
||||
if (!fontLoader.Init())
|
||||
{
|
||||
GetLogger()->Warn("Error on parsing fonts config file: failed to open file\n");
|
||||
}
|
||||
if (TTF_Init() != 0)
|
||||
{
|
||||
m_error = std::string("TTF_Init error: ") + std::string(TTF_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_fonts[FONT_COLOBOT] = MakeUnique<MultisizeFont>("fonts/dvu_sans.ttf");
|
||||
m_fonts[FONT_COLOBOT_BOLD] = MakeUnique<MultisizeFont>("fonts/dvu_sans_bold.ttf");
|
||||
m_fonts[FONT_COLOBOT_ITALIC] = MakeUnique<MultisizeFont>("fonts/dvu_sans_italic.ttf");
|
||||
|
||||
m_fonts[FONT_COURIER] = MakeUnique<MultisizeFont>("fonts/dvu_sans_mono.ttf");
|
||||
m_fonts[FONT_COURIER_BOLD] = MakeUnique<MultisizeFont>("fonts/dvu_sans_mono_bold.ttf");
|
||||
for (auto type : {FONT_COMMON, FONT_STUDIO, FONT_SATCOM})
|
||||
{
|
||||
m_fonts[static_cast<Gfx::FontType>(type)] = MakeUnique<MultisizeFont>(fontLoader.GetFont(type));
|
||||
m_fonts[static_cast<Gfx::FontType>(type|FONT_BOLD)] = MakeUnique<MultisizeFont>(fontLoader.GetFont(static_cast<Gfx::FontType>(type|FONT_BOLD)));
|
||||
m_fonts[static_cast<Gfx::FontType>(type|FONT_ITALIC)] = MakeUnique<MultisizeFont>(fontLoader.GetFont(static_cast<Gfx::FontType>(type|FONT_ITALIC)));
|
||||
}
|
||||
|
||||
for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it)
|
||||
{
|
||||
|
@ -218,7 +225,7 @@ void CText::Destroy()
|
|||
m_fonts.clear();
|
||||
|
||||
m_lastCachedFont = nullptr;
|
||||
m_lastFontType = FONT_COLOBOT;
|
||||
m_lastFontType = FONT_COMMON;
|
||||
m_lastFontSize = 0;
|
||||
|
||||
TTF_Quit();
|
||||
|
@ -253,7 +260,7 @@ void CText::FlushCache()
|
|||
}
|
||||
|
||||
m_lastCachedFont = nullptr;
|
||||
m_lastFontType = FONT_COLOBOT;
|
||||
m_lastFontType = FONT_COMMON;
|
||||
m_lastFontSize = 0;
|
||||
}
|
||||
|
||||
|
@ -336,8 +343,8 @@ void CText::SizeText(const std::string &text, std::vector<FontMetaChar>::iterato
|
|||
end.x -= sw;
|
||||
}
|
||||
|
||||
start.y -= GetDescent(FONT_COLOBOT, size);
|
||||
end.y += GetAscent(FONT_COLOBOT, size);
|
||||
start.y -= GetDescent(FONT_COMMON, size);
|
||||
end.y += GetAscent(FONT_COMMON, size);
|
||||
}
|
||||
|
||||
void CText::SizeText(const std::string &text, FontType font,
|
||||
|
@ -417,7 +424,7 @@ float CText::GetStringWidth(const std::string &text,
|
|||
unsigned int fmtIndex = 0;
|
||||
while (index < text.length())
|
||||
{
|
||||
FontType font = FONT_COLOBOT;
|
||||
FontType font = FONT_COMMON;
|
||||
if (format + fmtIndex != end)
|
||||
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
|
||||
|
||||
|
@ -464,7 +471,7 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
|
|||
if (font == FONT_BUTTON)
|
||||
{
|
||||
Math::IntPoint windowSize = m_engine->GetWindowSize();
|
||||
float height = GetHeight(FONT_COLOBOT, size);
|
||||
float height = GetHeight(FONT_COMMON, size);
|
||||
float width = height*(static_cast<float>(windowSize.y)/windowSize.x);
|
||||
return width;
|
||||
}
|
||||
|
@ -506,7 +513,7 @@ int CText::GetCharWidthInt(UTF8Char ch, FontType font, float size, float offset)
|
|||
if (font == FONT_BUTTON)
|
||||
{
|
||||
Math::IntPoint windowSize = m_engine->GetWindowSize();
|
||||
int height = GetHeightInt(FONT_COLOBOT, size);
|
||||
int height = GetHeightInt(FONT_COMMON, size);
|
||||
int width = height*(static_cast<float>(windowSize.y)/windowSize.x);
|
||||
return width;
|
||||
}
|
||||
|
@ -552,7 +559,7 @@ int CText::Justify(const std::string &text, std::vector<FontMetaChar>::iterator
|
|||
unsigned int fmtIndex = 0;
|
||||
while (index < text.length())
|
||||
{
|
||||
FontType font = FONT_COLOBOT;
|
||||
FontType font = FONT_COMMON;
|
||||
if (format + fmtIndex != end)
|
||||
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
|
||||
|
||||
|
@ -636,7 +643,7 @@ int CText::Detect(const std::string &text, std::vector<FontMetaChar>::iterator f
|
|||
unsigned int fmtIndex = 0;
|
||||
while (index < text.length())
|
||||
{
|
||||
FontType font = FONT_COLOBOT;
|
||||
FontType font = FONT_COMMON;
|
||||
|
||||
if (format + fmtIndex != end)
|
||||
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
|
||||
|
@ -773,7 +780,7 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
|
|||
StringToUTFCharList(text, chars, format, end);
|
||||
for (auto it = chars.begin(); it != chars.end(); ++it)
|
||||
{
|
||||
FontType font = FONT_COLOBOT;
|
||||
FontType font = FONT_COMMON;
|
||||
if (format + fmtIndex != end)
|
||||
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
|
||||
|
||||
|
@ -846,7 +853,7 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
|
|||
|
||||
if (eol != 0)
|
||||
{
|
||||
FontType font = FONT_COLOBOT;
|
||||
FontType font = FONT_COMMON;
|
||||
UTF8Char ch = TranslateSpecialChar(eol);
|
||||
color = Color(1.0f, 0.0f, 0.0f);
|
||||
DrawCharAndAdjustPos(ch, font, size, pos, color);
|
||||
|
@ -887,7 +894,7 @@ void CText::StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &
|
|||
{
|
||||
UTF8Char ch;
|
||||
|
||||
FontType font = FONT_COLOBOT;
|
||||
FontType font = FONT_COMMON;
|
||||
if (format + index != end)
|
||||
font = static_cast<FontType>(*(format + index) & FONT_MASK_FONT);
|
||||
|
||||
|
@ -993,7 +1000,7 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::I
|
|||
if (font == FONT_BUTTON)
|
||||
{
|
||||
Math::IntPoint windowSize = m_engine->GetWindowSize();
|
||||
int height = GetHeightInt(FONT_COLOBOT, size);
|
||||
int height = GetHeightInt(FONT_COMMON, size);
|
||||
int width = height * (static_cast<float>(windowSize.y)/windowSize.x);
|
||||
|
||||
Math::IntPoint p1(pos.x, pos.y - height);
|
||||
|
@ -1246,13 +1253,13 @@ FontTexture CText::CreateFontTexture(Math::IntPoint tileSize)
|
|||
|
||||
Math::IntPoint CText::GetNextTilePos(const FontTexture& fontTexture)
|
||||
{
|
||||
int horizontalTiles = FONT_TEXTURE_SIZE.x / fontTexture.tileSize.x;
|
||||
int verticalTiles = FONT_TEXTURE_SIZE.y / fontTexture.tileSize.y;
|
||||
int horizontalTiles = FONT_TEXTURE_SIZE.x / std::max(1, fontTexture.tileSize.x); //this should prevent crashes in some combinations of resolution and font size, see issue #1128
|
||||
int verticalTiles = FONT_TEXTURE_SIZE.y / std::max(1, fontTexture.tileSize.y);
|
||||
|
||||
int totalTiles = horizontalTiles * verticalTiles;
|
||||
int tileNumber = totalTiles - fontTexture.freeSlots;
|
||||
|
||||
int verticalTileIndex = tileNumber / horizontalTiles;
|
||||
int verticalTileIndex = tileNumber / std::max(1, horizontalTiles);
|
||||
int horizontalTileIndex = tileNumber % horizontalTiles;
|
||||
|
||||
return Math::IntPoint(horizontalTileIndex * fontTexture.tileSize.x,
|
||||
|
|
|
@ -77,18 +77,25 @@ enum FontType
|
|||
FONT_ITALIC = 0x08,
|
||||
|
||||
//! Default colobot font used for interface
|
||||
FONT_COLOBOT = 0x00,
|
||||
FONT_COMMON = 0x00,
|
||||
//! Alias for bold colobot font
|
||||
FONT_COLOBOT_BOLD = FONT_COLOBOT | FONT_BOLD,
|
||||
FONT_COMMON_BOLD = FONT_COMMON | FONT_BOLD,
|
||||
//! Alias for italic colobot font
|
||||
FONT_COLOBOT_ITALIC = FONT_COLOBOT | FONT_ITALIC,
|
||||
FONT_COMMON_ITALIC = FONT_COMMON | FONT_ITALIC,
|
||||
|
||||
//! Courier (monospace) font used mainly in code editor (only regular & bold)
|
||||
FONT_COURIER = 0x01,
|
||||
//! Alias for bold courier font
|
||||
FONT_COURIER_BOLD = FONT_COURIER | FONT_BOLD,
|
||||
//! Studio font used mainly in code editor
|
||||
FONT_STUDIO = 0x01,
|
||||
//! Alias for bold studio font
|
||||
FONT_STUDIO_BOLD = FONT_STUDIO | FONT_BOLD,
|
||||
//! Alias for italic studio font (at this point not used anywhere)
|
||||
FONT_STUDIO_ITALIC = FONT_STUDIO | FONT_ITALIC,
|
||||
|
||||
// 0x02 left for possible another font
|
||||
//! SatCom font used for interface (currently bold and italic wariants aren't used anywhere)
|
||||
FONT_SATCOM = 0x02,
|
||||
//! Alias for bold satcom font
|
||||
FONT_SATCOM_BOLD = FONT_SATCOM | FONT_BOLD,
|
||||
//! Alias for italic satcom font
|
||||
FONT_SATCOM_ITALIC = FONT_SATCOM | FONT_ITALIC,
|
||||
|
||||
//! Pseudo-font loaded from textures for buttons, icons, etc.
|
||||
FONT_BUTTON = 0x03,
|
||||
|
|
|
@ -188,7 +188,7 @@ struct OldModelTriangleV1
|
|||
Vertex p2;
|
||||
Vertex p3;
|
||||
Material material;
|
||||
char texName[20] = {};
|
||||
char texName[21] = {'\0'};
|
||||
float min = 0;
|
||||
float max = 0;
|
||||
};
|
||||
|
@ -207,7 +207,7 @@ struct OldModelTriangleV2
|
|||
Vertex p2;
|
||||
Vertex p3;
|
||||
Material material;
|
||||
char texName[20] = {};
|
||||
char texName[21] = {'\0'};
|
||||
float min = 0.0f;
|
||||
float max = 0.0f;
|
||||
long state = 0;
|
||||
|
@ -231,7 +231,7 @@ struct OldModelTriangleV3
|
|||
VertexTex2 p2;
|
||||
VertexTex2 p3;
|
||||
Material material;
|
||||
char texName[20] = {};
|
||||
char texName[21] = {'\0'};
|
||||
float min = 0.0f;
|
||||
float max = 0.0f;
|
||||
long state = 0;
|
||||
|
|
|
@ -328,7 +328,10 @@ void ModelOutput::WriteOldModel(const CModel& model, std::ostream &stream)
|
|||
t.material.ambient = triangle.ambient;
|
||||
t.material.diffuse = triangle.diffuse;
|
||||
t.material.specular = triangle.specular;
|
||||
strncpy(t.texName, triangle.tex1Name.c_str(), 20);
|
||||
|
||||
strncpy(t.texName, triangle.tex1Name.c_str(), sizeof(t.texName)-1);
|
||||
t.texName[sizeof(t.texName)-1] = '\0';
|
||||
|
||||
t.min = 0.0f;
|
||||
t.max = 1000000.0f;
|
||||
t.state = ConvertToOldState(triangle);
|
||||
|
|
|
@ -257,7 +257,6 @@ bool CGL14Device::Create()
|
|||
if (glVersion >= 15)
|
||||
{
|
||||
GetLogger()->Info("Core VBO supported\n", glMajor, glMinor);
|
||||
m_vertexBufferType = VBT_VBO_CORE;
|
||||
|
||||
// Set function pointers
|
||||
m_glGenBuffers = glGenBuffers;
|
||||
|
@ -269,7 +268,6 @@ bool CGL14Device::Create()
|
|||
else if (vboARB) // VBO ARB extension available
|
||||
{
|
||||
GetLogger()->Info("ARB VBO supported\n");
|
||||
m_vertexBufferType = VBT_VBO_ARB;
|
||||
|
||||
// Set function pointers
|
||||
m_glGenBuffers = glGenBuffersARB;
|
||||
|
@ -280,8 +278,11 @@ bool CGL14Device::Create()
|
|||
}
|
||||
else // no VBO support
|
||||
{
|
||||
GetLogger()->Info("VBO not supported\n");
|
||||
m_vertexBufferType = VBT_DISPLAY_LIST;
|
||||
m_errorMessage = "Your graphics card or drivers don't support OpenGL 1.5 or vertex buffer objects.\n"
|
||||
"Ensure you have the latest graphics drivers for your graphics card.\n\n";
|
||||
GetLogger()->Error(m_errorMessage.c_str());
|
||||
m_errorMessage += GetHardwareInfo();
|
||||
return false;
|
||||
}
|
||||
|
||||
// This is mostly done in all modern hardware by default
|
||||
|
@ -1299,255 +1300,93 @@ void CGL14Device::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode
|
|||
else assert(false);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void SetVertexAttributes(const Vertex* bufferBase, const std::vector<int>& textureRemapping)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<const char*>(bufferBase) + offsetof(Vertex, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<const char*>(bufferBase) + offsetof(Vertex, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + textureRemapping[1]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0 + textureRemapping[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<const char*>(bufferBase) + offsetof(Vertex, texCoord));
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void SetVertexAttributes(const VertexTex2* bufferBase, const std::vector<int>& textureRemapping)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + textureRemapping[1]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, texCoord2));
|
||||
glClientActiveTexture(GL_TEXTURE0 + textureRemapping[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, texCoord));
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void SetVertexAttributes(const VertexCol* bufferBase, const std::vector<int>& textureRemapping)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexCol, coord));
|
||||
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + textureRemapping[1]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0 + textureRemapping[0]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexCol, color));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void CGL14Device::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int vertexCount,
|
||||
Color color)
|
||||
{
|
||||
Vertex* vs = const_cast<Vertex*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
SetVertexAttributes(vertices, m_remap);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
||||
Color color)
|
||||
{
|
||||
VertexTex2* vs = const_cast<VertexTex2*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
SetVertexAttributes(vertices, m_remap);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
|
||||
{
|
||||
VertexCol* vs = const_cast<VertexCol*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].color));
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
SetVertexAttributes(vertices, m_remap);
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount)
|
||||
{
|
||||
const char *ptr = reinterpret_cast<const char*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(format.vertex.size,
|
||||
TransformType(format.vertex.type),
|
||||
format.vertex.stride,
|
||||
ptr + format.vertex.offset);
|
||||
|
||||
if (format.color.enabled)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(format.color.size,
|
||||
TransformType(format.color.type),
|
||||
format.color.stride,
|
||||
ptr + format.color.offset);
|
||||
}
|
||||
else
|
||||
glColor4fv(format.color.values);
|
||||
|
||||
if (format.normal.enabled)
|
||||
{
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(TransformType(format.normal.type),
|
||||
format.normal.stride,
|
||||
ptr + format.normal.offset);
|
||||
}
|
||||
else
|
||||
glNormal3fv(format.normal.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex1.size,
|
||||
TransformType(format.tex1.type),
|
||||
format.tex1.stride,
|
||||
ptr + format.tex1.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex1.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex2.size,
|
||||
TransformType(format.tex2.type),
|
||||
format.tex2.stride,
|
||||
ptr + format.tex2.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex2.values);
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
|
||||
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount)
|
||||
{
|
||||
const char *ptr = reinterpret_cast<const char*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(format.vertex.size,
|
||||
TransformType(format.vertex.type),
|
||||
format.vertex.stride,
|
||||
ptr + format.vertex.offset);
|
||||
|
||||
if (format.color.enabled)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(format.color.size,
|
||||
TransformType(format.color.type),
|
||||
format.color.stride,
|
||||
ptr + format.color.offset);
|
||||
}
|
||||
else
|
||||
glColor4fv(format.color.values);
|
||||
|
||||
if (format.normal.enabled)
|
||||
{
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(TransformType(format.normal.type),
|
||||
format.normal.stride,
|
||||
ptr + format.normal.offset);
|
||||
}
|
||||
else
|
||||
glNormal3fv(format.normal.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex1.size,
|
||||
TransformType(format.tex1.type),
|
||||
format.tex1.stride,
|
||||
ptr + format.tex1.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex1.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex2.size,
|
||||
TransformType(format.tex2.type),
|
||||
format.tex2.stride,
|
||||
ptr + format.tex2.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex2.values);
|
||||
|
||||
GLenum t = TranslateGfxPrimitive(type);
|
||||
|
||||
if (m_multiDrawArrays)
|
||||
{
|
||||
glMultiDrawArrays(t, first, count, drawCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < drawCount; i++)
|
||||
glDrawArrays(t, first[i], count[i]);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
|
||||
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||
int first[], int count[], int drawCount, Color color)
|
||||
{
|
||||
Vertex* vs = const_cast<Vertex*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
SetVertexAttributes(vertices, m_remap);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
GLenum t = TranslateGfxPrimitive(type);
|
||||
|
@ -1561,31 +1400,13 @@ void CGL14Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
|||
for (int i = 0; i < drawCount; i++)
|
||||
glDrawArrays(t, first[i], count[i]);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
||||
int first[], int count[], int drawCount, Color color)
|
||||
{
|
||||
VertexTex2* vs = const_cast<VertexTex2*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
SetVertexAttributes(vertices, m_remap);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
GLenum t = TranslateGfxPrimitive(type);
|
||||
|
@ -1599,25 +1420,13 @@ void CGL14Device::DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
|||
for (int i = 0; i < drawCount; i++)
|
||||
glDrawArrays(t, first[i], count[i]);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
void CGL14Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||
int first[], int count[], int drawCount)
|
||||
{
|
||||
VertexCol* vs = const_cast<VertexCol*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].color));
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
SetVertexAttributes(vertices, m_remap);
|
||||
|
||||
GLenum t = TranslateGfxPrimitive(type);
|
||||
|
||||
|
@ -1630,21 +1439,16 @@ void CGL14Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
|||
for (int i = 0; i < drawCount; i++)
|
||||
glDrawArrays(t, first[i], count[i]);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
unsigned int CGL14Device::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
template <typename Vertex>
|
||||
unsigned int CGL14Device::CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = 0;
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
id = ++m_lastVboId;
|
||||
unsigned int id = ++m_lastVboId;
|
||||
|
||||
VboObjectInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||
info.vertexType = Vertex::VERTEX_TYPE;
|
||||
info.vertexCount = vertexCount;
|
||||
info.bufferId = 0;
|
||||
|
||||
|
@ -1654,174 +1458,29 @@ unsigned int CGL14Device::CreateStaticBuffer(PrimitiveType primitiveType, const
|
|||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = glGenLists(1);
|
||||
|
||||
glNewList(id, GL_COMPILE);
|
||||
|
||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned int CGL14Device::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||
template <typename Vertex>
|
||||
void CGL14Device::UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = 0;
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
id = ++m_lastVboId;
|
||||
|
||||
VboObjectInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_TEX2;
|
||||
info.vertexCount = vertexCount;
|
||||
info.bufferId = 0;
|
||||
|
||||
m_glGenBuffers(1, &info.bufferId);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexTex2), vertices, GL_STATIC_DRAW);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = glGenLists(1);
|
||||
|
||||
glNewList(id, GL_COMPILE);
|
||||
|
||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned int CGL14Device::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = 0;
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
id = ++m_lastVboId;
|
||||
|
||||
VboObjectInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_COL;
|
||||
info.vertexCount = vertexCount;
|
||||
info.bufferId = 0;
|
||||
|
||||
m_glGenBuffers(1, &info.bufferId);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexCol), vertices, GL_STATIC_DRAW);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = glGenLists(1);
|
||||
|
||||
glNewList(id, GL_COMPILE);
|
||||
|
||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void CGL14Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VboObjectInfo& info = (*it).second;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||
info.vertexType = Vertex::VERTEX_TYPE;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), vertices, GL_STATIC_DRAW);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glNewList(bufferId, GL_COMPILE);
|
||||
|
||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
void CGL14Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||
{
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VboObjectInfo& info = (*it).second;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_TEX2;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexTex2), vertices, GL_STATIC_DRAW);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glNewList(bufferId, GL_COMPILE);
|
||||
|
||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
void CGL14Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||
{
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VboObjectInfo& info = (*it).second;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_COL;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, info.bufferId);
|
||||
m_glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(VertexCol), vertices, GL_STATIC_DRAW);
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glNewList(bufferId, GL_COMPILE);
|
||||
|
||||
DrawPrimitive(primitiveType, vertices, vertexCount);
|
||||
|
||||
glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
void CGL14Device::DrawStaticBuffer(unsigned int bufferId)
|
||||
{
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
@ -1830,77 +1489,24 @@ void CGL14Device::DrawStaticBuffer(unsigned int bufferId)
|
|||
|
||||
if ((*it).second.vertexType == VERTEX_TYPE_NORMAL)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, texCoord));
|
||||
SetVertexAttributes(static_cast<Vertex*>(nullptr), m_remap);
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_TEX2)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[1]);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord2));
|
||||
SetVertexAttributes(static_cast<VertexTex2*>(nullptr), m_remap);
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), static_cast<char*>(nullptr) + offsetof(VertexCol, coord));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), static_cast<char*>(nullptr) + offsetof(VertexCol, color));
|
||||
SetVertexAttributes(static_cast<VertexCol*>(nullptr), m_remap);
|
||||
}
|
||||
|
||||
GLenum mode = TranslateGfxPrimitive((*it).second.primitiveType);
|
||||
|
||||
glDrawArrays(mode, 0, (*it).second.vertexCount);
|
||||
|
||||
if ((*it).second.vertexType == VERTEX_TYPE_NORMAL)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_TEX2)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0 + m_remap[0]);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
m_glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCallList(bufferId);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL14Device::DestroyStaticBuffer(unsigned int bufferId)
|
||||
{
|
||||
if (m_vertexBufferType != VBT_DISPLAY_LIST)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
@ -1908,11 +1514,6 @@ void CGL14Device::DestroyStaticBuffer(unsigned int bufferId)
|
|||
m_glDeleteBuffers(1, &(*it).second.bufferId);
|
||||
|
||||
m_vboObjects.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDeleteLists(bufferId, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Based on libwine's implementation */
|
||||
|
|
|
@ -43,17 +43,6 @@
|
|||
namespace Gfx
|
||||
{
|
||||
|
||||
/**
|
||||
\enum VertexBufferType
|
||||
\brief Specifies type of vertex buffer to use
|
||||
*/
|
||||
enum VertexBufferType
|
||||
{
|
||||
VBT_DISPLAY_LIST, //! use display lists
|
||||
VBT_VBO_CORE, //! use core OpenGL 1.5 VBOs
|
||||
VBT_VBO_ARB //! use ARB extension VBOs
|
||||
};
|
||||
|
||||
enum ShadowMappingSupport
|
||||
{
|
||||
SMS_NONE, //! No support for depth textures
|
||||
|
@ -119,11 +108,6 @@ public:
|
|||
|
||||
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount) override;
|
||||
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
||||
|
@ -139,12 +123,31 @@ public:
|
|||
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||
int first[], int count[], int drawCount) override;
|
||||
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
|
||||
void DrawStaticBuffer(unsigned int bufferId) override;
|
||||
void DestroyStaticBuffer(unsigned int bufferId) override;
|
||||
|
||||
|
@ -214,6 +217,11 @@ private:
|
|||
//! Disables shadows
|
||||
void DisableShadows();
|
||||
|
||||
template <typename Vertex>
|
||||
unsigned int CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||
template <typename Vertex>
|
||||
void UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||
|
||||
private:
|
||||
//! Current config
|
||||
DeviceConfig m_config;
|
||||
|
@ -260,14 +268,6 @@ private:
|
|||
//! Map of framebuffers
|
||||
std::map<std::string, std::unique_ptr<CFramebuffer>> m_framebuffers;
|
||||
|
||||
//! Type of vertex structure
|
||||
enum VertexType
|
||||
{
|
||||
VERTEX_TYPE_NORMAL,
|
||||
VERTEX_TYPE_TEX2,
|
||||
VERTEX_TYPE_COL,
|
||||
};
|
||||
|
||||
//! Info about static VBO buffers
|
||||
struct VboObjectInfo
|
||||
{
|
||||
|
@ -284,8 +284,6 @@ private:
|
|||
bool m_multiDrawArrays = false;
|
||||
//! Framebuffer support
|
||||
FramebufferSupport m_framebufferSupport = FBS_NONE;
|
||||
//! Which vertex buffer type to use
|
||||
VertexBufferType m_vertexBufferType = VBT_DISPLAY_LIST;
|
||||
//! Map of saved VBO objects
|
||||
std::map<unsigned int, VboObjectInfo> m_vboObjects;
|
||||
//! Last ID of VBO object
|
||||
|
|
|
@ -1115,33 +1115,70 @@ void CGL21Device::SetTextureStageWrap(int index, TexWrapMode wrapS, TexWrapMode
|
|||
else assert(false);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void SetVertexAttributes(const Vertex* bufferBase)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<const char*>(bufferBase) + offsetof(Vertex, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<const char*>(bufferBase) + offsetof(Vertex, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<const char*>(bufferBase) + offsetof(Vertex, texCoord));
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void SetVertexAttributes(const VertexTex2* bufferBase)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, texCoord2));
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexTex2, texCoord));
|
||||
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void SetVertexAttributes(const VertexCol* bufferBase)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexCol, coord));
|
||||
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<const char*>(bufferBase) + offsetof(VertexCol, color));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void CGL21Device::DrawPrimitive(PrimitiveType type, const Vertex *vertices, int vertexCount,
|
||||
Color color)
|
||||
{
|
||||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
Vertex* vs = const_cast<Vertex*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
SetVertexAttributes(vertices);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
||||
|
@ -1150,33 +1187,10 @@ void CGL21Device::DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices,
|
|||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
VertexTex2* vs = const_cast<VertexTex2*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
|
||||
|
||||
SetVertexAttributes(vertices);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, int vertexCount)
|
||||
|
@ -1184,179 +1198,8 @@ void CGL21Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
|
|||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
VertexCol* vs = const_cast<VertexCol*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].color));
|
||||
|
||||
SetVertexAttributes(vertices);
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount)
|
||||
{
|
||||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
const char *ptr = reinterpret_cast<const char*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(format.vertex.size,
|
||||
TransformType(format.vertex.type),
|
||||
format.vertex.stride,
|
||||
ptr + format.vertex.offset);
|
||||
|
||||
if (format.color.enabled)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(format.color.size,
|
||||
TransformType(format.color.type),
|
||||
format.color.stride,
|
||||
ptr + format.color.offset);
|
||||
}
|
||||
else
|
||||
glColor4fv(format.color.values);
|
||||
|
||||
if (format.normal.enabled)
|
||||
{
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(TransformType(format.normal.type),
|
||||
format.normal.stride,
|
||||
ptr + format.normal.offset);
|
||||
}
|
||||
else
|
||||
glNormal3fv(format.normal.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex1.size,
|
||||
TransformType(format.tex1.type),
|
||||
format.tex1.stride,
|
||||
ptr + format.tex1.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex1.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex2.size,
|
||||
TransformType(format.tex2.type),
|
||||
format.tex2.stride,
|
||||
ptr + format.tex2.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex2.values);
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
|
||||
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount)
|
||||
{
|
||||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
const char *ptr = reinterpret_cast<const char*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(format.vertex.size,
|
||||
TransformType(format.vertex.type),
|
||||
format.vertex.stride,
|
||||
ptr + format.vertex.offset);
|
||||
|
||||
if (format.color.enabled)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(format.color.size,
|
||||
TransformType(format.color.type),
|
||||
format.color.stride,
|
||||
ptr + format.color.offset);
|
||||
}
|
||||
else
|
||||
glColor4fv(format.color.values);
|
||||
|
||||
if (format.normal.enabled)
|
||||
{
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(TransformType(format.normal.type),
|
||||
format.normal.stride,
|
||||
ptr + format.normal.offset);
|
||||
}
|
||||
else
|
||||
glNormal3fv(format.normal.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex1.size,
|
||||
TransformType(format.tex1.type),
|
||||
format.tex1.stride,
|
||||
ptr + format.tex1.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex1.values);
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(format.tex2.size,
|
||||
TransformType(format.tex2.type),
|
||||
format.tex2.stride,
|
||||
ptr + format.tex2.offset);
|
||||
}
|
||||
else
|
||||
glTexCoord2fv(format.tex2.values);
|
||||
|
||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (format.color.enabled) glDisableClientState(GL_COLOR_ARRAY);
|
||||
if (format.normal.enabled) glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
if (format.tex1.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
if (format.tex2.enabled)
|
||||
{
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||
|
@ -1365,26 +1208,10 @@ void CGL21Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
|||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
Vertex* vs = const_cast<Vertex*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
SetVertexAttributes(vertices);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
||||
|
@ -1393,33 +1220,10 @@ void CGL21Device::DrawPrimitives(PrimitiveType type, const VertexTex2 *vertices,
|
|||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
VertexTex2* vs = const_cast<VertexTex2*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), reinterpret_cast<GLfloat*>(&vs[0].texCoord2));
|
||||
|
||||
SetVertexAttributes(vertices);
|
||||
glColor4fv(color.Array());
|
||||
|
||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
void CGL21Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||
|
@ -1428,28 +1232,20 @@ void CGL21Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
|||
if (m_updateLights) UpdateLights();
|
||||
|
||||
BindVBO(0);
|
||||
|
||||
VertexCol* vs = const_cast<VertexCol*>(vertices);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].coord));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), reinterpret_cast<GLfloat*>(&vs[0].color));
|
||||
SetVertexAttributes(vertices);
|
||||
|
||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
unsigned int CGL21Device::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
|
||||
template <typename Vertex>
|
||||
unsigned int CGL21Device::CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = ++m_lastVboId;
|
||||
|
||||
VboObjectInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||
info.vertexType = Vertex::VERTEX_TYPE;
|
||||
info.vertexCount = vertexCount;
|
||||
info.bufferId = 0;
|
||||
info.size = vertexCount * sizeof(Vertex);
|
||||
|
@ -1463,47 +1259,8 @@ unsigned int CGL21Device::CreateStaticBuffer(PrimitiveType primitiveType, const
|
|||
return id;
|
||||
}
|
||||
|
||||
unsigned int CGL21Device::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = ++m_lastVboId;
|
||||
|
||||
VboObjectInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_TEX2;
|
||||
info.vertexCount = vertexCount;
|
||||
info.bufferId = 0;
|
||||
info.size = vertexCount * sizeof(VertexTex2);
|
||||
|
||||
glGenBuffers(1, &info.bufferId);
|
||||
BindVBO(info.bufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned int CGL21Device::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = ++m_lastVboId;
|
||||
|
||||
VboObjectInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_COL;
|
||||
info.vertexCount = vertexCount;
|
||||
info.bufferId = 0;
|
||||
info.size = vertexCount * sizeof(VertexCol);
|
||||
|
||||
glGenBuffers(1, &info.bufferId);
|
||||
BindVBO(info.bufferId);
|
||||
glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void CGL21Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
template <typename Vertex>
|
||||
void CGL21Device::UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
|
@ -1513,7 +1270,7 @@ void CGL21Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
|
|||
|
||||
VboObjectInfo& info = (*it).second;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||
info.vertexType = Vertex::VERTEX_TYPE;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
BindVBO(info.bufferId);
|
||||
|
@ -1529,58 +1286,6 @@ void CGL21Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
|
|||
}
|
||||
}
|
||||
|
||||
void CGL21Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VboObjectInfo& info = (*it).second;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_TEX2;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
int newSize = vertexCount * sizeof(VertexTex2);
|
||||
|
||||
BindVBO(info.bufferId);
|
||||
|
||||
if (info.size < newSize)
|
||||
{
|
||||
glBufferData(GL_ARRAY_BUFFER, newSize, vertices, GL_STATIC_DRAW);
|
||||
info.size = newSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, newSize, vertices);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL21Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VboObjectInfo& info = (*it).second;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_COL;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
int newSize = vertexCount * sizeof(VertexCol);
|
||||
|
||||
BindVBO(info.bufferId);
|
||||
|
||||
if (info.size < newSize)
|
||||
{
|
||||
glBufferData(GL_ARRAY_BUFFER, newSize, vertices, GL_STATIC_DRAW);
|
||||
info.size = newSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, newSize, vertices);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL21Device::DrawStaticBuffer(unsigned int bufferId)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
|
@ -1593,64 +1298,20 @@ void CGL21Device::DrawStaticBuffer(unsigned int bufferId)
|
|||
|
||||
if ((*it).second.vertexType == VERTEX_TYPE_NORMAL)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), static_cast<char*>(nullptr) + offsetof(Vertex, texCoord));
|
||||
SetVertexAttributes(static_cast<const Vertex*>(nullptr));
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_TEX2)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, coord));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, normal));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord));
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE1);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexTex2), static_cast<char*>(nullptr) + offsetof(VertexTex2, texCoord2));
|
||||
SetVertexAttributes(static_cast<const VertexTex2*>(nullptr));
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexCol), static_cast<char*>(nullptr) + offsetof(VertexCol, coord));
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(VertexCol), static_cast<char*>(nullptr) + offsetof(VertexCol, color));
|
||||
SetVertexAttributes(static_cast<const VertexCol*>(nullptr));
|
||||
}
|
||||
|
||||
GLenum mode = TranslateGfxPrimitive((*it).second.primitiveType);
|
||||
|
||||
glDrawArrays(mode, 0, (*it).second.vertexCount);
|
||||
|
||||
if ((*it).second.vertexType == VERTEX_TYPE_NORMAL)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE0
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_TEX2)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // GL_TEXTURE1
|
||||
|
||||
glClientActiveTexture(GL_TEXTURE0);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
else if ((*it).second.vertexType == VERTEX_TYPE_COL)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL21Device::DestroyStaticBuffer(unsigned int bufferId)
|
||||
|
|
|
@ -100,11 +100,6 @@ public:
|
|||
|
||||
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount) override;
|
||||
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
||||
|
@ -120,12 +115,30 @@ public:
|
|||
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||
int first[], int count[], int drawCount) override;
|
||||
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void DrawStaticBuffer(unsigned int bufferId) override;
|
||||
void DestroyStaticBuffer(unsigned int bufferId) override;
|
||||
|
||||
|
@ -192,6 +205,11 @@ private:
|
|||
//! Binds texture
|
||||
inline void BindTexture(int index, GLuint texture);
|
||||
|
||||
template <typename Vertex>
|
||||
unsigned int CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||
template <typename Vertex>
|
||||
void UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||
|
||||
private:
|
||||
//! Current config
|
||||
DeviceConfig m_config;
|
||||
|
@ -232,14 +250,6 @@ private:
|
|||
//! Map of framebuffers
|
||||
std::map<std::string, std::unique_ptr<CFramebuffer>> m_framebuffers;
|
||||
|
||||
//! Type of vertex structure
|
||||
enum VertexType
|
||||
{
|
||||
VERTEX_TYPE_NORMAL,
|
||||
VERTEX_TYPE_TEX2,
|
||||
VERTEX_TYPE_COL,
|
||||
};
|
||||
|
||||
//! Info about static VBO buffers
|
||||
struct VboObjectInfo
|
||||
{
|
||||
|
|
|
@ -1158,50 +1158,6 @@ void CGL33Device::DrawPrimitive(PrimitiveType type, const VertexCol *vertices, i
|
|||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
}
|
||||
|
||||
void CGL33Device::DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount)
|
||||
{
|
||||
if (m_updateLights) UpdateLights();
|
||||
|
||||
DynamicBuffer& buffer = m_dynamicBuffer;
|
||||
|
||||
BindVAO(buffer.vao);
|
||||
BindVBO(buffer.vbo);
|
||||
|
||||
unsigned int offset = UploadVertexData(buffer, vertices, size);
|
||||
|
||||
// Update vertex attribute bindings
|
||||
UpdateVertexAttribute(0, format.vertex, offset);
|
||||
UpdateVertexAttribute(1, format.normal, offset);
|
||||
UpdateVertexAttribute(2, format.color, offset);
|
||||
UpdateVertexAttribute(3, format.tex1, offset);
|
||||
UpdateVertexAttribute(4, format.tex2, offset);
|
||||
|
||||
glDrawArrays(TranslateGfxPrimitive(type), 0, vertexCount);
|
||||
}
|
||||
|
||||
void CGL33Device::DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount)
|
||||
{
|
||||
if (m_updateLights) UpdateLights();
|
||||
|
||||
DynamicBuffer& buffer = m_dynamicBuffer;
|
||||
|
||||
BindVAO(buffer.vao);
|
||||
BindVBO(buffer.vbo);
|
||||
|
||||
unsigned int offset = UploadVertexData(buffer, vertices, size);
|
||||
|
||||
// Update vertex attribute bindings
|
||||
UpdateVertexAttribute(0, format.vertex, offset);
|
||||
UpdateVertexAttribute(1, format.normal, offset);
|
||||
UpdateVertexAttribute(2, format.color, offset);
|
||||
UpdateVertexAttribute(3, format.tex1, offset);
|
||||
UpdateVertexAttribute(4, format.tex2, offset);
|
||||
|
||||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||
}
|
||||
|
||||
void CGL33Device::DrawPrimitives(PrimitiveType type, const Vertex *vertices,
|
||||
int first[], int count[], int drawCount, Color color)
|
||||
{
|
||||
|
@ -1358,7 +1314,82 @@ void CGL33Device::DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
|||
glMultiDrawArrays(TranslateGfxPrimitive(type), first, count, drawCount);
|
||||
}
|
||||
|
||||
unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
namespace
|
||||
{
|
||||
template <typename Vertex> void SetVertexAttributes();
|
||||
|
||||
template <> void SetVertexAttributes<Vertex>()
|
||||
{
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, coord)));
|
||||
|
||||
// Normal
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, normal)));
|
||||
|
||||
// Color
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib4f(2, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Texture coordinate 0
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, texCoord)));
|
||||
|
||||
// Texture coordinate 1
|
||||
glDisableVertexAttribArray(4);
|
||||
glVertexAttrib2f(4, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
template <> void SetVertexAttributes<VertexTex2>()
|
||||
{
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, coord)));
|
||||
|
||||
// Normal
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, normal)));
|
||||
|
||||
// Color
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib4f(2, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Texture coordinate 0
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, texCoord)));
|
||||
|
||||
// Texture coordinate 1
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, texCoord2)));
|
||||
}
|
||||
|
||||
template <> void SetVertexAttributes<VertexCol>()
|
||||
{
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexCol), reinterpret_cast<void*>(offsetof(VertexCol, coord)));
|
||||
|
||||
// Normal
|
||||
glDisableVertexAttribArray(1);
|
||||
glVertexAttrib3f(1, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Color
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexCol), reinterpret_cast<void*>(offsetof(VertexCol, color)));
|
||||
|
||||
// Texture coordinate 0
|
||||
glDisableVertexAttribArray(3);
|
||||
glVertexAttrib2f(3, 0.0f, 0.0f);
|
||||
|
||||
// Texture coordinate 1
|
||||
glDisableVertexAttribArray(4);
|
||||
glVertexAttrib2f(4, 0.0f, 0.0f);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template <typename Vertex>
|
||||
unsigned int CGL33Device::CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = 0;
|
||||
|
||||
|
@ -1366,7 +1397,7 @@ unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const
|
|||
|
||||
VertexBufferInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||
info.vertexType = Vertex::VERTEX_TYPE;
|
||||
info.vertexCount = vertexCount;
|
||||
info.size = vertexCount * sizeof(Vertex);
|
||||
|
||||
|
@ -1379,122 +1410,15 @@ unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const
|
|||
glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
|
||||
m_vboMemory += info.size;
|
||||
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, coord)));
|
||||
|
||||
// Normal
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, normal)));
|
||||
|
||||
// Color
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib4f(2, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Texture coordinate 0
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, texCoord)));
|
||||
|
||||
// Texture coordinate 1
|
||||
glDisableVertexAttribArray(4);
|
||||
glVertexAttrib2f(4, 0.0f, 0.0f);
|
||||
SetVertexAttributes<Vertex>();
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = 0;
|
||||
|
||||
id = ++m_lastVboId;
|
||||
|
||||
VertexBufferInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_TEX2;
|
||||
info.vertexCount = vertexCount;
|
||||
info.size = vertexCount * sizeof(VertexTex2);
|
||||
|
||||
glGenVertexArrays(1, &info.vao);
|
||||
BindVAO(info.vao);
|
||||
|
||||
glGenBuffers(1, &info.vbo);
|
||||
BindVBO(info.vbo);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
|
||||
m_vboMemory += info.size;
|
||||
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, coord)));
|
||||
|
||||
// Normal
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, normal)));
|
||||
|
||||
// Color
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib4f(2, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Texture coordinate 0
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, texCoord)));
|
||||
|
||||
// Texture coordinate 1
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, texCoord2)));
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned int CGL33Device::CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||
{
|
||||
unsigned int id = ++m_lastVboId;
|
||||
|
||||
VertexBufferInfo info;
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_COL;
|
||||
info.vertexCount = vertexCount;
|
||||
info.size = vertexCount * sizeof(VertexCol);
|
||||
|
||||
glGenVertexArrays(1, &info.vao);
|
||||
BindVAO(info.vao);
|
||||
|
||||
glGenBuffers(1, &info.vbo);
|
||||
BindVBO(info.vbo);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, info.size, vertices, GL_STATIC_DRAW);
|
||||
m_vboMemory += info.size;
|
||||
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexCol), reinterpret_cast<void*>(offsetof(VertexCol, coord)));
|
||||
|
||||
// Normal
|
||||
glDisableVertexAttribArray(1);
|
||||
glVertexAttrib3f(1, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Color
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexCol), reinterpret_cast<void*>(offsetof(VertexCol, color)));
|
||||
|
||||
// Texture coordinate 0
|
||||
glDisableVertexAttribArray(3);
|
||||
glVertexAttrib2f(3, 0.0f, 0.0f);
|
||||
|
||||
// Texture coordinate 1
|
||||
glDisableVertexAttribArray(4);
|
||||
glVertexAttrib2f(4, 0.0f, 0.0f);
|
||||
|
||||
m_vboObjects[id] = info;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
template <typename Vertex>
|
||||
void CGL33Device::UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
|
@ -1504,12 +1428,12 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
|
|||
|
||||
unsigned int size = vertexCount * sizeof(Vertex);
|
||||
|
||||
bool changed = (info.vertexType != VERTEX_TYPE_NORMAL) || (size > info.size);
|
||||
bool changed = (info.vertexType != Vertex::VERTEX_TYPE) || (size > info.size);
|
||||
|
||||
if (info.vertexType != VERTEX_TYPE_NORMAL) CLogger::GetInstance().Debug("Changing static buffer type\n");
|
||||
if (info.vertexType != Vertex::VERTEX_TYPE) CLogger::GetInstance().Debug("Changing static buffer type\n");
|
||||
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_NORMAL;
|
||||
info.vertexType = Vertex::VERTEX_TYPE;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
BindVBO(info.vbo);
|
||||
|
@ -1531,143 +1455,7 @@ void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primit
|
|||
{
|
||||
BindVAO(info.vao);
|
||||
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, coord)));
|
||||
|
||||
// Normal
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, normal)));
|
||||
|
||||
// Color
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib4f(2, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Texture coordinate 0
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(offsetof(Vertex, texCoord)));
|
||||
|
||||
// Texture coordinate 1
|
||||
glDisableVertexAttribArray(4);
|
||||
glVertexAttrib2f(4, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VertexBufferInfo& info = (*it).second;
|
||||
|
||||
unsigned int size = vertexCount * sizeof(VertexTex2);
|
||||
|
||||
bool changed = (info.vertexType != VERTEX_TYPE_TEX2) || (size > info.size);
|
||||
|
||||
if (info.vertexType != VERTEX_TYPE_TEX2) CLogger::GetInstance().Debug("Changing static buffer type\n");
|
||||
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_TEX2;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
BindVBO(info.vbo);
|
||||
|
||||
if (info.size < size)
|
||||
{
|
||||
CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
|
||||
m_vboMemory -= info.size;
|
||||
info.size = size;
|
||||
m_vboMemory += info.size;
|
||||
}
|
||||
else
|
||||
{
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, size, vertices);
|
||||
}
|
||||
|
||||
if (changed) // Update vertex array bindings
|
||||
{
|
||||
BindVAO(info.vao);
|
||||
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, coord)));
|
||||
|
||||
// Normal
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, normal)));
|
||||
|
||||
// Color
|
||||
glDisableVertexAttribArray(2);
|
||||
glVertexAttrib4f(2, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Texture coordinate 0
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, texCoord)));
|
||||
|
||||
// Texture coordinate 1
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(VertexTex2), reinterpret_cast<void*>(offsetof(VertexTex2, texCoord2)));
|
||||
}
|
||||
}
|
||||
|
||||
void CGL33Device::UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount)
|
||||
{
|
||||
auto it = m_vboObjects.find(bufferId);
|
||||
if (it == m_vboObjects.end())
|
||||
return;
|
||||
|
||||
VertexBufferInfo& info = (*it).second;
|
||||
|
||||
unsigned int size = vertexCount * sizeof(VertexCol);
|
||||
|
||||
bool changed = (info.vertexType != VERTEX_TYPE_COL) || (size > info.size);
|
||||
|
||||
if (info.vertexType != VERTEX_TYPE_NORMAL) CLogger::GetInstance().Debug("Changing static buffer type\n");
|
||||
|
||||
info.primitiveType = primitiveType;
|
||||
info.vertexType = VERTEX_TYPE_COL;
|
||||
info.vertexCount = vertexCount;
|
||||
|
||||
BindVBO(info.vbo);
|
||||
|
||||
if (info.size < size)
|
||||
{
|
||||
CLogger::GetInstance().Debug("Resizing static buffer: %d->%d\n", info.size, size);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW);
|
||||
m_vboMemory -= info.size;
|
||||
info.size = size;
|
||||
m_vboMemory += info.size;
|
||||
}
|
||||
else
|
||||
{
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, size, vertices);
|
||||
}
|
||||
|
||||
if (changed) // Update vertex array bindings
|
||||
{
|
||||
BindVAO(info.vao);
|
||||
|
||||
// Vertex coordinate
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexCol), reinterpret_cast<void*>(offsetof(VertexCol, coord)));
|
||||
|
||||
// Normal
|
||||
glDisableVertexAttribArray(1);
|
||||
glVertexAttrib3f(1, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Color
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(VertexCol), reinterpret_cast<void*>(offsetof(VertexCol, color)));
|
||||
|
||||
// Texture coordinate 0
|
||||
glDisableVertexAttribArray(3);
|
||||
glVertexAttrib2f(3, 0.0f, 0.0f);
|
||||
|
||||
// Texture coordinate 1
|
||||
glDisableVertexAttribArray(4);
|
||||
glVertexAttrib2f(4, 0.0f, 0.0f);
|
||||
SetVertexAttributes<Vertex>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2092,25 +1880,6 @@ unsigned int CGL33Device::UploadVertexData(DynamicBuffer& buffer, const void* da
|
|||
return currentOffset;
|
||||
}
|
||||
|
||||
void CGL33Device::UpdateVertexAttribute(int index, const VertexAttribute &attribute, int offset)
|
||||
{
|
||||
if (attribute.enabled)
|
||||
{
|
||||
glEnableVertexAttribArray(index);
|
||||
glVertexAttribPointer(index,
|
||||
attribute.size,
|
||||
TranslateType(attribute.type),
|
||||
attribute.normalized ? GL_TRUE : GL_FALSE,
|
||||
attribute.stride,
|
||||
reinterpret_cast<void*>(offset + attribute.offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisableVertexAttribArray(index);
|
||||
glVertexAttrib4fv(index, attribute.values);
|
||||
}
|
||||
}
|
||||
|
||||
bool CGL33Device::IsAnisotropySupported()
|
||||
{
|
||||
return m_capabilities.anisotropySupported;
|
||||
|
|
|
@ -115,11 +115,6 @@ public:
|
|||
|
||||
void SetTextureStageWrap(int index, Gfx::TexWrapMode wrapS, Gfx::TexWrapMode wrapT) override;
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int vertexCount) override;
|
||||
virtual void DrawPrimitives(PrimitiveType type, const void *vertices,
|
||||
int size, const VertexFormat &format, int first[], int count[], int drawCount) override;
|
||||
|
||||
virtual void DrawPrimitive(PrimitiveType type, const Vertex *vertices , int vertexCount,
|
||||
Color color = Color(1.0f, 1.0f, 1.0f, 1.0f)) override;
|
||||
virtual void DrawPrimitive(PrimitiveType type, const VertexTex2 *vertices, int vertexCount,
|
||||
|
@ -135,12 +130,30 @@ public:
|
|||
virtual void DrawPrimitives(PrimitiveType type, const VertexCol *vertices,
|
||||
int first[], int count[], int drawCount) override;
|
||||
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override;
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override;
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
unsigned int CreateStaticBuffer(PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override
|
||||
{
|
||||
return CreateStaticBufferImpl(primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexTex2* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void UpdateStaticBuffer(unsigned int bufferId, PrimitiveType primitiveType, const VertexCol* vertices, int vertexCount) override
|
||||
{
|
||||
UpdateStaticBufferImpl(bufferId, primitiveType, vertices, vertexCount);
|
||||
}
|
||||
void DrawStaticBuffer(unsigned int bufferId) override;
|
||||
void DestroyStaticBuffer(unsigned int bufferId) override;
|
||||
|
||||
|
@ -213,7 +226,10 @@ private:
|
|||
//! Uploads data to dynamic buffer and returns offset to it
|
||||
unsigned int UploadVertexData(DynamicBuffer& buffer, const void* data, unsigned int size);
|
||||
|
||||
inline void UpdateVertexAttribute(int index, const VertexAttribute &attribute, int offset);
|
||||
template <typename Vertex>
|
||||
unsigned int CreateStaticBufferImpl(PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||
template <typename Vertex>
|
||||
void UpdateStaticBufferImpl(unsigned int bufferId, PrimitiveType primitiveType, const Vertex* vertices, int vertexCount);
|
||||
|
||||
private:
|
||||
//! Current config
|
||||
|
@ -256,14 +272,6 @@ private:
|
|||
//! Free texture unit
|
||||
const int m_freeTexture = 3;
|
||||
|
||||
//! Type of vertex structure
|
||||
enum VertexType
|
||||
{
|
||||
VERTEX_TYPE_NORMAL,
|
||||
VERTEX_TYPE_TEX2,
|
||||
VERTEX_TYPE_COL,
|
||||
};
|
||||
|
||||
//! Info about static VBO buffers
|
||||
struct VertexBufferInfo
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ bool CGLFramebuffer::Create()
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
|
||||
|
||||
// create color texture
|
||||
if (m_params.colorTexture)
|
||||
if (m_params.colorAttachment == FramebufferParams::AttachmentType::Texture)
|
||||
{
|
||||
GLint previous;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous);
|
||||
|
@ -76,7 +76,7 @@ bool CGLFramebuffer::Create()
|
|||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorTexture, 0);
|
||||
}
|
||||
// create color renderbuffer
|
||||
else
|
||||
else if (m_params.colorAttachment == FramebufferParams::AttachmentType::Renderbuffer)
|
||||
{
|
||||
glGenRenderbuffers(1, &m_colorRenderbuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_colorRenderbuffer);
|
||||
|
@ -92,6 +92,10 @@ bool CGLFramebuffer::Create()
|
|||
glFramebufferRenderbuffer(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colorRenderbuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawBuffer(GL_NONE);
|
||||
}
|
||||
|
||||
GLuint depthFormat = 0;
|
||||
|
||||
|
@ -104,7 +108,7 @@ bool CGLFramebuffer::Create()
|
|||
}
|
||||
|
||||
// create depth texture
|
||||
if (m_params.depthTexture)
|
||||
if (m_params.depthAttachment == FramebufferParams::AttachmentType::Texture)
|
||||
{
|
||||
GLint previous;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous);
|
||||
|
@ -132,7 +136,7 @@ bool CGLFramebuffer::Create()
|
|||
GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0);
|
||||
}
|
||||
// create depth renderbuffer
|
||||
else
|
||||
else if (m_params.depthAttachment == FramebufferParams::AttachmentType::Renderbuffer)
|
||||
{
|
||||
glGenRenderbuffers(1, &m_depthRenderbuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_depthRenderbuffer);
|
||||
|
@ -323,7 +327,7 @@ bool CGLFramebufferEXT::Create()
|
|||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
|
||||
|
||||
// create color texture
|
||||
if (m_params.colorTexture)
|
||||
if (m_params.colorAttachment == FramebufferParams::AttachmentType::Texture)
|
||||
{
|
||||
GLint previous;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous);
|
||||
|
@ -346,7 +350,7 @@ bool CGLFramebufferEXT::Create()
|
|||
GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_colorTexture, 0);
|
||||
}
|
||||
// create color renderbuffer
|
||||
else
|
||||
else if (m_params.colorAttachment == FramebufferParams::AttachmentType::Renderbuffer)
|
||||
{
|
||||
glGenRenderbuffersEXT(1, &m_colorRenderbuffer);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_colorRenderbuffer);
|
||||
|
@ -363,6 +367,10 @@ bool CGLFramebufferEXT::Create()
|
|||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
|
||||
GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_colorRenderbuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawBuffer(GL_NONE);
|
||||
}
|
||||
|
||||
GLuint depthFormat = 0;
|
||||
|
||||
|
@ -375,7 +383,7 @@ bool CGLFramebufferEXT::Create()
|
|||
}
|
||||
|
||||
// create depth texture
|
||||
if (m_params.depthTexture)
|
||||
if (m_params.depthAttachment == FramebufferParams::AttachmentType::Texture)
|
||||
{
|
||||
GLint previous;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &previous);
|
||||
|
@ -403,7 +411,7 @@ bool CGLFramebufferEXT::Create()
|
|||
GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_depthTexture, 0);
|
||||
}
|
||||
// create depth renderbuffer
|
||||
else
|
||||
else if (m_params.depthAttachment == FramebufferParams::AttachmentType::Renderbuffer)
|
||||
{
|
||||
glGenRenderbuffersEXT(1, &m_depthRenderbuffer);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthRenderbuffer);
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "level/parser/parser.h"
|
||||
|
||||
#include "math/const.h"
|
||||
#include "math/func.h"
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/object.h"
|
||||
|
@ -119,6 +120,10 @@
|
|||
const float UNIT = 4.0f; // default for g_unit
|
||||
float g_unit; // conversion factor
|
||||
|
||||
// Min/max values for the game speed.
|
||||
const float MIN_SPEED = 1/8.0f;
|
||||
const float MAX_SPEED = 256.0f;
|
||||
|
||||
// Reference colors used when recoloring textures, see ChangeColor()
|
||||
const Gfx::Color COLOR_REF_BOT = Gfx::Color( 10.0f/256.0f, 166.0f/256.0f, 254.0f/256.0f); // blue
|
||||
const Gfx::Color COLOR_REF_ALIEN = Gfx::Color(135.0f/256.0f, 170.0f/256.0f, 13.0f/256.0f); // green
|
||||
|
@ -589,7 +594,7 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
ddim.x = dim.x*15; ddim.y = dim.y*3.0f;
|
||||
pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
|
||||
pe->SetGenericMode(true);
|
||||
pe->SetFontType(Gfx::FONT_COLOBOT);
|
||||
pe->SetFontType(Gfx::FONT_COMMON);
|
||||
pe->SetEditCap(false);
|
||||
pe->SetHighlightCap(false);
|
||||
pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/win.txt"));
|
||||
|
@ -779,7 +784,7 @@ bool CRobotMain::ProcessEvent(Event &event)
|
|||
|
||||
if (IsPhaseWithWorld(m_phase))
|
||||
{
|
||||
if (data->key == KEY(F11))
|
||||
if (data->key == KEY(F10))
|
||||
{
|
||||
m_debugMenu->ToggleInterface();
|
||||
return false;
|
||||
|
@ -2127,7 +2132,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
|
|||
|
||||
Math::Point start, end;
|
||||
|
||||
m_engine->GetText()->SizeText(text, Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL,
|
||||
m_engine->GetText()->SizeText(text, Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL,
|
||||
corner, Gfx::TEXT_ALIGN_LEFT,
|
||||
start, end);
|
||||
|
||||
|
@ -2162,7 +2167,7 @@ void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
|
|||
pw->SetState(Ui::STATE_SHADOW);
|
||||
pw->SetTrashEvent(false);
|
||||
|
||||
pos.y -= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL) / 2.0f;
|
||||
pos.y -= m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL) / 2.0f;
|
||||
pw->CreateLabel(pos, dim, -1, EVENT_LABEL2, text);
|
||||
}
|
||||
}
|
||||
|
@ -5358,10 +5363,11 @@ void CRobotMain::UpdateChapterPassed()
|
|||
return m_ui->UpdateChapterPassed();
|
||||
}
|
||||
|
||||
|
||||
//! Changes game speed
|
||||
void CRobotMain::SetSpeed(float speed)
|
||||
{
|
||||
speed = Math::Clamp(speed, MIN_SPEED, MAX_SPEED);
|
||||
|
||||
m_app->SetSimulationSpeed(speed);
|
||||
UpdateSpeedLabel();
|
||||
}
|
||||
|
@ -5913,7 +5919,7 @@ void CRobotMain::CreateCodeBattleInterface()
|
|||
|
||||
int numTeams = m_scoreboard ? GetAllTeams().size() : 0;
|
||||
assert(numTeams < EVENT_SCOREBOARD_MAX-EVENT_SCOREBOARD+1);
|
||||
float textHeight = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL);
|
||||
float textHeight = m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL);
|
||||
|
||||
//window
|
||||
ddim.x = 100.0f/640.0f;
|
||||
|
|
|
@ -82,12 +82,14 @@ void CAutoPowerPlant::DeleteObject(bool all)
|
|||
CObject* cargo = SearchMetal();
|
||||
if ( cargo != nullptr )
|
||||
{
|
||||
m_object->SetPower(nullptr);
|
||||
CObjectManager::GetInstancePointer()->DeleteObject(cargo);
|
||||
}
|
||||
|
||||
cargo = SearchPower();
|
||||
if ( cargo != nullptr )
|
||||
{
|
||||
m_object->SetPower(nullptr);
|
||||
CObjectManager::GetInstancePointer()->DeleteObject(cargo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,13 +284,19 @@ void COldObject::DeleteObject(bool bAll)
|
|||
if (m_power != nullptr)
|
||||
{
|
||||
if (m_power->Implements(ObjectInterfaceType::Old))
|
||||
{
|
||||
dynamic_cast<COldObject*>(m_power)->SetTransporter(nullptr);
|
||||
dynamic_cast<COldObject*>(m_power)->DeleteObject(bAll);
|
||||
}
|
||||
m_power = nullptr;
|
||||
}
|
||||
if (m_cargo != nullptr)
|
||||
{
|
||||
if (m_cargo->Implements(ObjectInterfaceType::Old))
|
||||
{
|
||||
dynamic_cast<COldObject*>(m_cargo)->SetTransporter(nullptr);
|
||||
dynamic_cast<COldObject*>(m_cargo)->DeleteObject(bAll);
|
||||
}
|
||||
m_cargo = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,6 +372,9 @@ std::string GetHelpFilename(const char *token)
|
|||
if ( strcmp(token, "synchronized" ) == 0 ) helpfile = "cbot/synchro";
|
||||
if ( strcmp(token, "new" ) == 0 ) helpfile = "cbot/new";
|
||||
if ( strcmp(token, "this" ) == 0 ) helpfile = "cbot/this";
|
||||
if ( strcmp(token, "switch" ) == 0 ||
|
||||
strcmp(token, "case" ) == 0 ||
|
||||
strcmp(token, "default" ) == 0 ) helpfile = "cbot/switch";
|
||||
|
||||
if (helpfile.empty())
|
||||
return "";
|
||||
|
@ -491,11 +494,14 @@ bool IsFunction(const char *token)
|
|||
|
||||
const char* GetHelpText(const char *token)
|
||||
{
|
||||
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }";
|
||||
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";
|
||||
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { code }";
|
||||
if ( strcmp(token, "else" ) == 0 ) return "else { code }";
|
||||
if ( strcmp(token, "for" ) == 0 ) return "for ( before ; condition ; end )";
|
||||
if ( strcmp(token, "while" ) == 0 ) return "while ( condition ) { bloc }";
|
||||
if ( strcmp(token, "do" ) == 0 ) return "do { bloc } while ( condition );";
|
||||
if ( strcmp(token, "while" ) == 0 ) return "while ( condition ) { code }";
|
||||
if ( strcmp(token, "do" ) == 0 ) return "do { code } while ( condition );";
|
||||
if ( strcmp(token, "switch" ) == 0 ) return "switch ( value ) { code }";
|
||||
if ( strcmp(token, "case" ) == 0 ) return "case label: { code }";
|
||||
if ( strcmp(token, "default" ) == 0 ) return "default: { code } ";
|
||||
if ( strcmp(token, "break" ) == 0 ) return "break;";
|
||||
if ( strcmp(token, "continue" ) == 0 ) return "continue;";
|
||||
if ( strcmp(token, "return" ) == 0 ) return "return;";
|
||||
|
|
|
@ -3412,9 +3412,9 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user)
|
|||
pVar = pVar->GetNext(); // "orientation"
|
||||
pVar->SetValFloat(Math::NormAngle(2*Math::PI - pos.y)*180.0f/Math::PI);
|
||||
pVar = pVar->GetNext(); // "pitch"
|
||||
pVar->SetValFloat(Math::NormAngle(pos.z)*180.0f/Math::PI);
|
||||
pVar->SetValFloat((Math::NormAngle(pos.z + Math::PI) - Math::PI)*180.0f/Math::PI);
|
||||
pVar = pVar->GetNext(); // "roll"
|
||||
pVar->SetValFloat(Math::NormAngle(pos.x)*180.0f/Math::PI);
|
||||
pVar->SetValFloat((Math::NormAngle(pos.x + Math::PI) - Math::PI)*180.0f/Math::PI);
|
||||
|
||||
// Updates the energy level of the object.
|
||||
pVar = pVar->GetNext(); // "energyLevel"
|
||||
|
|
|
@ -44,7 +44,7 @@ CControl::CControl()
|
|||
m_eventType = EVENT_NULL;
|
||||
m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT;
|
||||
m_fontSize = Gfx::FONT_SIZE_SMALL;
|
||||
m_fontType = Gfx::FONT_COLOBOT;
|
||||
m_fontType = Gfx::FONT_COMMON;
|
||||
m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
|
||||
m_bFocus = false;
|
||||
m_bCapture = false;
|
||||
|
|
|
@ -109,7 +109,7 @@ CEdit::CEdit()
|
|||
{
|
||||
m_len = 0;
|
||||
|
||||
m_fontType = Gfx::FONT_COURIER;
|
||||
m_fontType = Gfx::FONT_STUDIO;
|
||||
m_bEdit = true;
|
||||
m_bHilite = true;
|
||||
m_bInsideScroll = true;
|
||||
|
@ -1326,13 +1326,13 @@ void CEdit::SetText(const std::string& text, bool bNew)
|
|||
if ( text[i+1] == 'n' ) // normal ?
|
||||
{
|
||||
font &= ~Gfx::FONT_MASK_FONT;
|
||||
font |= Gfx::FONT_COLOBOT;
|
||||
font |= Gfx::FONT_COMMON;
|
||||
i += 2;
|
||||
}
|
||||
else if ( text[i+1] == 'c' ) // cbot ?
|
||||
{
|
||||
font &= ~Gfx::FONT_MASK_FONT;
|
||||
font |= Gfx::FONT_COURIER;
|
||||
font |= Gfx::FONT_STUDIO;
|
||||
i += 2;
|
||||
}
|
||||
else if ( text[i+1] == 'b' ) // big title ?
|
||||
|
@ -1522,7 +1522,7 @@ bool CEdit::ReadText(std::string filename)
|
|||
if ( m_bSoluce || !bInSoluce )
|
||||
{
|
||||
font &= ~Gfx::FONT_MASK_FONT;
|
||||
font |= Gfx::FONT_COLOBOT;
|
||||
font |= Gfx::FONT_COMMON;
|
||||
inCbot = false;
|
||||
}
|
||||
i += 3;
|
||||
|
@ -1532,7 +1532,7 @@ bool CEdit::ReadText(std::string filename)
|
|||
if ( m_bSoluce || !bInSoluce )
|
||||
{
|
||||
font &= ~Gfx::FONT_MASK_FONT;
|
||||
font |= Gfx::FONT_COURIER;
|
||||
font |= Gfx::FONT_STUDIO;
|
||||
if (!inCbot)
|
||||
{
|
||||
if (inCbotBackground)
|
||||
|
@ -1636,7 +1636,7 @@ bool CEdit::ReadText(std::string filename)
|
|||
|
||||
//? iWidth = m_lineHeight*RetValueParam(buffer.data()+i+7, 1);
|
||||
iWidth = static_cast<float>(GetValueParam(buffer.data()+i+7, 1));
|
||||
iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL);
|
||||
iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, Gfx::FONT_SIZE_SMALL);
|
||||
iLines = GetValueParam(buffer.data()+i+7, 2);
|
||||
|
||||
// A part of image per line of text.
|
||||
|
@ -2540,6 +2540,8 @@ bool CEdit::Paste()
|
|||
{
|
||||
char c;
|
||||
char* text;
|
||||
int iTabToInsert=0;
|
||||
int iTmp; //temp for tab space equivalant insertion
|
||||
|
||||
if ( !m_bEdit )
|
||||
{
|
||||
|
@ -2554,20 +2556,36 @@ bool CEdit::Paste()
|
|||
}
|
||||
|
||||
UndoMemorize(OPERUNDO_SPEC);
|
||||
for ( unsigned int i = 0; i < strlen(text); i++ )
|
||||
for (unsigned int i = 0; i<strlen(text); ++i)
|
||||
{
|
||||
c = text[i];
|
||||
if ( c == '\r' )
|
||||
switch(c)
|
||||
{
|
||||
case '\r':
|
||||
continue;
|
||||
case '\t':
|
||||
if (m_bAutoIndent)
|
||||
{
|
||||
if (0<m_cursor1 && m_cursor1<=m_len && '\n'!=m_text[m_cursor1-1])
|
||||
iTabToInsert++;
|
||||
continue;
|
||||
}
|
||||
if ( c == '\t' && m_bAutoIndent )
|
||||
break;
|
||||
case '\n':
|
||||
iTabToInsert=0;
|
||||
}
|
||||
if (0<iTabToInsert && m_bAutoIndent)
|
||||
{
|
||||
continue;
|
||||
for (iTmp=m_engine->GetEditIndentValue()*iTabToInsert; iTmp>0; --iTmp)
|
||||
InsertOne(' ');
|
||||
iTabToInsert=0;
|
||||
}
|
||||
InsertOne(c);
|
||||
}
|
||||
|
||||
if (0<iTabToInsert && m_bAutoIndent && 0<m_cursor1
|
||||
&& (m_cursor1>=m_len || '\n'!=m_text[m_cursor1]))
|
||||
for (iTmp=m_engine->GetEditIndentValue() ; iTmp>0; --iTmp)
|
||||
InsertOne(' ');
|
||||
SDL_free(text);
|
||||
Justif();
|
||||
ColumnFix();
|
||||
|
@ -2872,7 +2890,7 @@ int CEdit::IndentTabCount()
|
|||
return nb;
|
||||
}
|
||||
|
||||
// Adds or removes qq tabs.
|
||||
// Adds or removes some tabs.
|
||||
|
||||
void CEdit::IndentTabAdjust(int number)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ void CDebugMenu::ToggleInterface()
|
|||
{
|
||||
CreateInterface();
|
||||
CLabel* pl = m_interface->CreateLabel(Math::Point(0.0f, 0.9f), Math::Point(1.0f, 0.1f), -1, EVENT_LABEL19, "??");
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ class CInterface;
|
|||
|
||||
/**
|
||||
* \class CDebugMenu
|
||||
* \brief Handles debug menu (F11)
|
||||
* \brief Handles debug menu (F10)
|
||||
*
|
||||
* There should always be only one instance of this class for each associated CRobotMain class.
|
||||
*/
|
||||
|
|
|
@ -383,7 +383,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
|
|||
edit->SetState(STATE_SHADOW);
|
||||
edit->SetMultiFont(true);
|
||||
edit->SetMaxChar(10000);
|
||||
edit->SetFontType(Gfx::FONT_COLOBOT);
|
||||
edit->SetFontType(Gfx::FONT_SATCOM);
|
||||
edit->SetSoluceMode(bSoluce);
|
||||
edit->ReadText(filename.c_str());
|
||||
edit->HyperHome(filename.c_str());
|
||||
|
|
|
@ -197,7 +197,7 @@ void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height
|
|||
}
|
||||
|
||||
hBox = 0.045f;
|
||||
hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE);
|
||||
hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COMMON, FONTSIZE);
|
||||
|
||||
nLine = 0;
|
||||
for ( i=0 ; i<MAXDTLINE ; i++ )
|
||||
|
|
|
@ -323,7 +323,7 @@ void CMainDialog::StartInformation(const std::string& title, const std::string&
|
|||
ddim.x = 1.00f;
|
||||
ddim.y = 0.05f;
|
||||
pl = pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL, text);
|
||||
pl->SetFontType(Gfx::FONT_COLOBOT_BOLD);
|
||||
pl->SetFontType(Gfx::FONT_COMMON_BOLD);
|
||||
//TODO: Add \n support in CLabel
|
||||
pos.y -= ddim.y;
|
||||
pl = pw->CreateLabel(pos, ddim, -1, EVENT_DIALOG_LABEL1, details);
|
||||
|
|
|
@ -71,7 +71,7 @@ void CScreen::CreateVersionDisplay()
|
|||
ddim.x = 90.0f/640.0f;
|
||||
ddim.y = 10.0f/480.0f;
|
||||
CLabel* pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, COLOBOT_VERSION_DISPLAY);
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
pl->SetFontSize(9.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ void CScreenIO::IOReadName()
|
|||
CEdit* pe;
|
||||
std::string resume;
|
||||
char line[100];
|
||||
char name[100];
|
||||
std::string name;
|
||||
time_t now;
|
||||
|
||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
|
@ -81,10 +81,10 @@ void CScreenIO::IOReadName()
|
|||
|
||||
time(&now);
|
||||
strftime(line, 99, "%y.%m.%d %H:%M", localtime(&now));
|
||||
sprintf(name, "%s - %s %d", line, resume.c_str(), m_main->GetLevelRank());
|
||||
name = StrUtils::Format("%s - %s %d", line, resume.c_str(), m_main->GetLevelRank());
|
||||
|
||||
pe->SetText(name);
|
||||
pe->SetCursor(strlen(name), 0);
|
||||
pe->SetCursor(name.length(), 0);
|
||||
m_interface->SetFocus(pe);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ void CScreenIOWrite::CreateInterface()
|
|||
ddim.y = 18.0f/480.0f;
|
||||
pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_IONAME);
|
||||
pe->SetState(STATE_SHADOW);
|
||||
pe->SetFontType(Gfx::FONT_COLOBOT);
|
||||
pe->SetFontType(Gfx::FONT_COMMON);
|
||||
pe->SetMaxChar(35);
|
||||
IOReadName();
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ void CScreenMainMenu::CreateInterface()
|
|||
pg->SetState(STATE_SHADOW);
|
||||
pos.y -= 5.0f/480.0f;
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "TerranovaTeam");
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
|
||||
|
||||
// SatCom button
|
||||
|
|
|
@ -61,7 +61,7 @@ void CScreenQuit::CreateInterface()
|
|||
pe->SetGenericMode(true);
|
||||
pe->SetEditCap(false);
|
||||
pe->SetHighlightCap(false);
|
||||
pe->SetFontType(Gfx::FONT_COURIER);
|
||||
pe->SetFontType(Gfx::FONT_STUDIO);
|
||||
pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
|
||||
pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));
|
||||
|
||||
|
@ -71,13 +71,13 @@ void CScreenQuit::CreateInterface()
|
|||
ddim.y = 16.0f/480.0f;
|
||||
GetResource(RES_TEXT, RT_GENERIC_DEV1, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
|
||||
|
||||
pos.y = 13.0f/480.0f;
|
||||
GetResource(RES_TEXT, RT_GENERIC_DEV2, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
|
||||
|
||||
pos.x = 355.0f/640.0f;
|
||||
|
@ -86,13 +86,13 @@ void CScreenQuit::CreateInterface()
|
|||
ddim.y = 16.0f/480.0f;
|
||||
GetResource(RES_TEXT, RT_GENERIC_EDIT1, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name);
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
|
||||
|
||||
pos.y = 13.0f/480.0f;
|
||||
GetResource(RES_TEXT, RT_GENERIC_EDIT2, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name);
|
||||
pl->SetFontType(Gfx::FONT_COURIER);
|
||||
pl->SetFontType(Gfx::FONT_STUDIO);
|
||||
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
|
||||
|
||||
pos.x = 306.0f/640.0f;
|
||||
|
|
|
@ -101,6 +101,36 @@ void CScreenSetupDisplay::CreateInterface()
|
|||
pc->SetState(STATE_SHADOW);
|
||||
pc->SetState(STATE_CHECK, m_setupFull);
|
||||
|
||||
pos.x = ox+sx*10;
|
||||
pos.y = oy+sy*6.75f;
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*1;
|
||||
GetResource(RES_EVENT, EVENT_INTERFACE_VSYNC, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
|
||||
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
|
||||
|
||||
pos.x = ox+sx*10;
|
||||
pos.y = oy+sy*5.2f;
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*2;
|
||||
pli = pw->CreateList(pos, ddim, 0, EVENT_INTERFACE_VSYNC);
|
||||
pli->SetState(STATE_SHADOW);
|
||||
pli->SetItemName(0, "Off");
|
||||
pli->SetItemName(1, "Adaptive");
|
||||
pli->SetItemName(2, "On");
|
||||
switch(m_engine->GetVSync())
|
||||
{
|
||||
case -1: //Adaptive?
|
||||
pli->SetSelect(1);
|
||||
break;
|
||||
case 0: //Off?
|
||||
pli->SetSelect(0);
|
||||
break;
|
||||
case 1: //On?
|
||||
pli->SetSelect(2);
|
||||
break;
|
||||
}
|
||||
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*1;
|
||||
pos.x = ox+sx*10;
|
||||
|
@ -117,6 +147,7 @@ bool CScreenSetupDisplay::EventProcess(const Event &event)
|
|||
CWindow* pw;
|
||||
CCheck* pc;
|
||||
CButton* pb;
|
||||
CList* pl;
|
||||
|
||||
switch( event.type )
|
||||
{
|
||||
|
@ -153,6 +184,27 @@ bool CScreenSetupDisplay::EventProcess(const Event &event)
|
|||
UpdateApply();
|
||||
break;
|
||||
|
||||
case EVENT_INTERFACE_VSYNC:
|
||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == nullptr ) break;
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_VSYNC));
|
||||
if (pl == nullptr ) break;
|
||||
switch(pl->GetSelect())
|
||||
{
|
||||
case 0: //Off?
|
||||
m_engine->SetVSync(0);
|
||||
break;
|
||||
case 1: //Adaptive?
|
||||
m_engine->SetVSync(-1);
|
||||
break;
|
||||
case 2: //On?
|
||||
m_engine->SetVSync(1);
|
||||
break;
|
||||
}
|
||||
ChangeDisplay();
|
||||
UpdateApply();
|
||||
break;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@ void CScreenSetupGame::CreateInterface()
|
|||
pli->SetItemName(1+LANGUAGE_GERMAN, "German");
|
||||
pli->SetItemName(1+LANGUAGE_POLISH, "Polish");
|
||||
pli->SetItemName(1+LANGUAGE_RUSSIAN, "Russian");
|
||||
pli->SetItemName(1+LANGUAGE_PORTUGUESE_BRAZILIAN, "Brazilian Portuguese");
|
||||
|
||||
UpdateSetupButtons();
|
||||
}
|
||||
|
|
|
@ -627,7 +627,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
|
|||
edit->SetState(STATE_SHADOW);
|
||||
edit->SetInsideScroll(false);
|
||||
//? if ( m_bRunning ) edit->SetEdit(false);
|
||||
edit->SetFontType(Gfx::FONT_COURIER);
|
||||
edit->SetFontType(Gfx::FONT_STUDIO);
|
||||
edit->SetFontStretch(1.0f);
|
||||
edit->SetDisplaySpec(true);
|
||||
edit->SetAutoIndent(m_engine->GetEditIndentMode());
|
||||
|
@ -639,7 +639,7 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
|
|||
|
||||
list = pw->CreateList(pos, dim, 1, EVENT_STUDIO_LIST, 1.2f);
|
||||
list->SetState(STATE_SHADOW);
|
||||
list->SetFontType(Gfx::FONT_COURIER);
|
||||
list->SetFontType(Gfx::FONT_STUDIO);
|
||||
list->SetSelectCap(false);
|
||||
list->SetFontSize(Gfx::FONT_SIZE_SMALL*0.85f);
|
||||
//? list->SetFontStretch(1.0f);
|
||||
|
|
|
@ -73,7 +73,7 @@ codename = None
|
|||
data = open('CMakeLists.txt', 'r').readlines()
|
||||
|
||||
for i in range(len(data)):
|
||||
m = re.match(r'^set\(COLOBOT_VERSION_(MAJOR|MINOR|REVISION)( +)([0-9]+)\)$', data[i])
|
||||
m = re.match(r'^set\(COLOBOT_VERSION_(MAJOR|MINOR|REVISION)( +)([0-9]+(\.[0-9]+)?)\)$', data[i])
|
||||
if m:
|
||||
x = m.group(3)
|
||||
if m.group(1) == 'MAJOR':
|
||||
|
|
Loading…
Reference in New Issue