mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 12:49:18 +02:00
skydome optimization, vsync .ini setting
This commit is contained in:
2
EU07.cpp
2
EU07.cpp
@@ -281,7 +281,7 @@ int main( int argc, char *argv[] ) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
glfwMakeContextCurrent( window );
|
glfwMakeContextCurrent( window );
|
||||||
glfwSwapInterval( 0 ); //vsync // NOTE: disabled, as slight drop below refresh rate seems to cause drastic drop in framerate
|
glfwSwapInterval( (Global::VSync ? 1 : 0) ); //vsync
|
||||||
glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED ); //capture cursor
|
glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED ); //capture cursor
|
||||||
glfwSetCursorPos( window, 0.0, 0.0 );
|
glfwSetCursorPos( window, 0.0, 0.0 );
|
||||||
glfwSetFramebufferSizeCallback( window, window_resize_callback );
|
glfwSetFramebufferSizeCallback( window, window_resize_callback );
|
||||||
|
|||||||
84
Globals.cpp
84
Globals.cpp
@@ -125,6 +125,7 @@ int Global::iFeedbackMode = 1; // tryb pracy informacji zwrotnej
|
|||||||
int Global::iFeedbackPort = 0; // dodatkowy adres dla informacji zwrotnych
|
int Global::iFeedbackPort = 0; // dodatkowy adres dla informacji zwrotnych
|
||||||
bool Global::bFreeFly = false;
|
bool Global::bFreeFly = false;
|
||||||
bool Global::bFullScreen = false;
|
bool Global::bFullScreen = false;
|
||||||
|
bool Global::VSync{ true };
|
||||||
bool Global::bInactivePause = true; // automatyczna pauza, gdy okno nieaktywne
|
bool Global::bInactivePause = true; // automatyczna pauza, gdy okno nieaktywne
|
||||||
float Global::fMouseXScale = 1.5;
|
float Global::fMouseXScale = 1.5;
|
||||||
float Global::fMouseYScale = 0.2;
|
float Global::fMouseYScale = 0.2;
|
||||||
@@ -308,15 +309,18 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bFullScreen;
|
||||||
Global::bFullScreen = (token == "yes");
|
}
|
||||||
|
else if( token == "vsync" ) {
|
||||||
|
|
||||||
|
Parser.getTokens();
|
||||||
|
Parser >> Global::VSync;
|
||||||
}
|
}
|
||||||
else if (token == "freefly")
|
else if (token == "freefly")
|
||||||
{ // Mczapkie-130302
|
{ // Mczapkie-130302
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bFreeFly;
|
||||||
Global::bFreeFly = (token == "yes");
|
|
||||||
Parser.getTokens(3, false);
|
Parser.getTokens(3, false);
|
||||||
Parser >> Global::pFreeCameraInit[0].x, Global::pFreeCameraInit[0].y,
|
Parser >> Global::pFreeCameraInit[0].x, Global::pFreeCameraInit[0].y,
|
||||||
Global::pFreeCameraInit[0].z;
|
Global::pFreeCameraInit[0].z;
|
||||||
@@ -325,23 +329,20 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bWireFrame;
|
||||||
Global::bWireFrame = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "debugmode")
|
else if (token == "debugmode")
|
||||||
{ // McZapkie! - DebugModeFlag uzywana w mover.pas,
|
{ // McZapkie! - DebugModeFlag uzywana w mover.pas,
|
||||||
// warto tez blokowac cheaty gdy false
|
// warto tez blokowac cheaty gdy false
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> DebugModeFlag;
|
||||||
DebugModeFlag = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "soundenabled")
|
else if (token == "soundenabled")
|
||||||
{ // McZapkie-040302 - blokada dzwieku - przyda
|
{ // McZapkie-040302 - blokada dzwieku - przyda
|
||||||
// sie do debugowania oraz na komp. bez karty
|
// sie do debugowania oraz na komp. bez karty
|
||||||
// dzw.
|
// dzw.
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bSoundEnabled;
|
||||||
Global::bSoundEnabled = (token == "yes");
|
|
||||||
}
|
}
|
||||||
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
|
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
|
||||||
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
|
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
|
||||||
@@ -349,15 +350,13 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{ // McZapkie-030402 - logowanie parametrow
|
{ // McZapkie-030402 - logowanie parametrow
|
||||||
// fizycznych dla kazdego pojazdu z maszynista
|
// fizycznych dla kazdego pojazdu z maszynista
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> WriteLogFlag;
|
||||||
WriteLogFlag = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "physicsdeactivation")
|
else if (token == "physicsdeactivation")
|
||||||
{ // McZapkie-291103 - usypianie fizyki
|
{ // McZapkie-291103 - usypianie fizyki
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> PhysicActivationFlag;
|
||||||
PhysicActivationFlag = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "debuglog")
|
else if (token == "debuglog")
|
||||||
{
|
{
|
||||||
@@ -381,8 +380,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// McZapkie-240403 - czestotliwosc odswiezania ekranu
|
// McZapkie-240403 - czestotliwosc odswiezania ekranu
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bAdjustScreenFreq;
|
||||||
Global::bAdjustScreenFreq = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "mousescale")
|
else if (token == "mousescale")
|
||||||
{
|
{
|
||||||
@@ -394,15 +392,13 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// Winger 040204 - 'zywe' patyki dostosowujace sie do trakcji; Ra 2014-03: teraz łamanie
|
// Winger 040204 - 'zywe' patyki dostosowujace sie do trakcji; Ra 2014-03: teraz łamanie
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bEnableTraction;
|
||||||
Global::bEnableTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "loadtraction")
|
else if (token == "loadtraction")
|
||||||
{
|
{
|
||||||
// Winger 140404 - ladowanie sie trakcji
|
// Winger 140404 - ladowanie sie trakcji
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bLoadTraction;
|
||||||
Global::bLoadTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "friction")
|
else if (token == "friction")
|
||||||
{ // mnożnik tarcia - KURS90
|
{ // mnożnik tarcia - KURS90
|
||||||
@@ -415,8 +411,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
// Winger 160404 - zaleznosc napiecia loka od trakcji;
|
// Winger 160404 - zaleznosc napiecia loka od trakcji;
|
||||||
// Ra 2014-03: teraz prąd przy braku sieci
|
// Ra 2014-03: teraz prąd przy braku sieci
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bLiveTraction;
|
||||||
Global::bLiveTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "skyenabled")
|
else if (token == "skyenabled")
|
||||||
{
|
{
|
||||||
@@ -429,15 +424,13 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bManageNodes;
|
||||||
Global::bManageNodes = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "decompressdds")
|
else if (token == "decompressdds")
|
||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bDecompressDDS;
|
||||||
Global::bDecompressDDS = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "defaultext")
|
else if (token == "defaultext")
|
||||||
{
|
{
|
||||||
@@ -460,8 +453,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bnewAirCouplers;
|
||||||
Global::bnewAirCouplers = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "defaultfiltering")
|
else if (token == "defaultfiltering")
|
||||||
{
|
{
|
||||||
@@ -567,8 +559,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// podwójna jasność ambient
|
// podwójna jasność ambient
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bDoubleAmbient;
|
||||||
Global::bDoubleAmbient = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "movelight")
|
else if (token == "movelight")
|
||||||
{
|
{
|
||||||
@@ -594,8 +585,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// podwójna jasność ambient
|
// podwójna jasność ambient
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bSmoothTraction;
|
||||||
Global::bSmoothTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "timespeed")
|
else if (token == "timespeed")
|
||||||
{
|
{
|
||||||
@@ -613,8 +603,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// tekst generowany przez GLUT
|
// tekst generowany przez GLUT
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bGlutFont;
|
||||||
Global::bGlutFont = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "latitude")
|
else if (token == "latitude")
|
||||||
{
|
{
|
||||||
@@ -632,8 +621,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// automatyczna pauza, gdy okno nieaktywne
|
// automatyczna pauza, gdy okno nieaktywne
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bInactivePause;
|
||||||
Global::bInactivePause = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "slowmotion")
|
else if (token == "slowmotion")
|
||||||
{
|
{
|
||||||
@@ -651,22 +639,19 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// hunter-271211: ukrywanie konsoli
|
// hunter-271211: ukrywanie konsoli
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bHideConsole;
|
||||||
Global::bHideConsole = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "oldsmudge")
|
else if (token == "oldsmudge")
|
||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bOldSmudge;
|
||||||
Global::bOldSmudge = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "rollfix")
|
else if (token == "rollfix")
|
||||||
{
|
{
|
||||||
// Ra: poprawianie przechyłki, aby wewnętrzna szyna była "pozioma"
|
// Ra: poprawianie przechyłki, aby wewnętrzna szyna była "pozioma"
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bRollFix;
|
||||||
Global::bRollFix = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "fpsaverage")
|
else if (token == "fpsaverage")
|
||||||
{
|
{
|
||||||
@@ -791,8 +776,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// czy grupować eventy o tych samych nazwach
|
// czy grupować eventy o tych samych nazwach
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bJoinEvents;
|
||||||
Global::bJoinEvents = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "hiddenevents")
|
else if (token == "hiddenevents")
|
||||||
{
|
{
|
||||||
@@ -837,14 +821,12 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
// maciek001: ustawienia MWD
|
// maciek001: ustawienia MWD
|
||||||
else if (token == "mwdmasterenable") { // główne włączenie maszyny!
|
else if (token == "mwdmasterenable") { // główne włączenie maszyny!
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDmasterEnable;
|
||||||
bMWDmasterEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable) WriteLog("SerialPort Master Enable");
|
if (bMWDdebugEnable) WriteLog("SerialPort Master Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwddebugenable") { // logowanie pracy
|
else if (token == "mwddebugenable") { // logowanie pracy
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDdebugEnable;
|
||||||
bMWDdebugEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable) WriteLog("MWD Debug Mode On");
|
if (bMWDdebugEnable) WriteLog("MWD Debug Mode On");
|
||||||
}
|
}
|
||||||
else if (token == "mwddebugmode") { // co ma być debugowane?
|
else if (token == "mwddebugmode") { // co ma być debugowane?
|
||||||
@@ -864,14 +846,12 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
}
|
}
|
||||||
else if (token == "mwdinputenable") { // włącz wejścia
|
else if (token == "mwdinputenable") { // włącz wejścia
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDInputEnable;
|
||||||
bMWDInputEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable && bMWDInputEnable) WriteLog("MWD Input Enable");
|
if (bMWDdebugEnable && bMWDInputEnable) WriteLog("MWD Input Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwdbreakenable") { // włącz obsługę hamulców
|
else if (token == "mwdbreakenable") { // włącz obsługę hamulców
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDBreakEnable;
|
||||||
bMWDBreakEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable && bMWDBreakEnable) WriteLog("MWD Break Enable");
|
if (bMWDdebugEnable && bMWDBreakEnable) WriteLog("MWD Break Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwdmainbreakconfig") { // ustawienia hamulca zespolonego
|
else if (token == "mwdmainbreakconfig") { // ustawienia hamulca zespolonego
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ class Global
|
|||||||
static float fDistanceFactor;
|
static float fDistanceFactor;
|
||||||
static int iBpp;
|
static int iBpp;
|
||||||
static bool bFullScreen;
|
static bool bFullScreen;
|
||||||
|
static bool VSync;
|
||||||
static bool bFreeFly;
|
static bool bFreeFly;
|
||||||
// float RunningTime;
|
// float RunningTime;
|
||||||
static bool bWireFrame;
|
static bool bWireFrame;
|
||||||
|
|||||||
56
skydome.cpp
56
skydome.cpp
@@ -78,49 +78,44 @@ void CSkyDome::Generate() {
|
|||||||
float const offset = 0.1f * radius; // horizontal offset, a cheap way to prevent a gap between ground and horizon
|
float const offset = 0.1f * radius; // horizontal offset, a cheap way to prevent a gap between ground and horizon
|
||||||
|
|
||||||
// create geometry chunk
|
// create geometry chunk
|
||||||
int const latitudes = m_tesselation / 2;
|
int const latitudes = m_tesselation / 2 / 2; // half-sphere only
|
||||||
int const longitudes = m_tesselation;
|
int const longitudes = m_tesselation;
|
||||||
|
|
||||||
std::uint16_t index = 0;
|
std::uint16_t index = 0;
|
||||||
|
|
||||||
for( int i = 0; i < latitudes; ++i ) {
|
for( int i = 0; i <= latitudes; ++i ) {
|
||||||
|
|
||||||
float lat0 = M_PI * ( -0.5f + (float)( i ) / latitudes );
|
float const latitude = M_PI * ( -0.5f + (float)( i ) / latitudes / 2 ); // half-sphere only
|
||||||
float z0 = std::sin( lat0 );
|
float const z = std::sin( latitude );
|
||||||
float zr0 = std::cos( lat0 );
|
float const zr = std::cos( latitude );
|
||||||
|
|
||||||
float lat1 = M_PI * ( -0.5f + (float)( i + 1 ) / latitudes );
|
for( int j = 0; j <= longitudes; ++j ) {
|
||||||
float z1 = std::sin( lat1 );
|
|
||||||
float zr1 = std::cos( lat1 );
|
|
||||||
|
|
||||||
// quad strip
|
float const longitude = 2.0 * M_PI * (float)( j ) / longitudes;
|
||||||
for( int j = 0; j <= longitudes / 2; ++j ) {
|
float const x = std::cos( longitude );
|
||||||
|
float const y = std::sin( longitude );
|
||||||
|
/*
|
||||||
|
m_vertices.emplace_back( float3( x * zr, y * zr - offset, z ) * radius );
|
||||||
|
// we aren't using normals, but the code is left here in case it's ever needed
|
||||||
|
// m_normals.emplace_back( float3( x * zr, -y * zr, -z ) );
|
||||||
|
*/
|
||||||
|
// cartesian to opengl swap: -x, -z, -y
|
||||||
|
m_vertices.emplace_back( float3( -x * zr, -z - offset, -y * zr ) * radius );
|
||||||
|
m_colours.emplace_back( float3( 0.75f, 0.75f, 0.75f ) ); // placeholder
|
||||||
|
|
||||||
float longitude = 2.0 * M_PI * (float)( j ) / longitudes;
|
if( (i == 0) || (j == 0) ) {
|
||||||
float x = std::cos( longitude );
|
// initial edge of the dome, don't start indices yet
|
||||||
float y = std::sin( longitude );
|
++index;
|
||||||
|
|
||||||
m_vertices.emplace_back( float3( x * zr0, y * zr0 - offset, z0 ) * radius );
|
|
||||||
// m_normals.emplace_back( float3( -x * zr0, -y * zr0, -z0 ) );
|
|
||||||
m_colours.emplace_back( float3( 0.75f, 0.75f, 0.75f ) );
|
|
||||||
|
|
||||||
m_vertices.emplace_back( float3( x * zr1, y * zr1 - offset, z1 ) * radius );
|
|
||||||
// m_normals.emplace_back( float3( -x * zr1, -y * zr1, -z1 ) );
|
|
||||||
m_colours.emplace_back( float3( 0.75f, 0.75f, 0.75f ) );
|
|
||||||
|
|
||||||
if( j == 0 ) {
|
|
||||||
// beginning of the strip, don't start indices yet
|
|
||||||
index += 2;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// indices for two triangles
|
// indices for two triangles, formed between current and previous latitude
|
||||||
m_indices.emplace_back( index - 2 );
|
m_indices.emplace_back( index - 1 - (longitudes + 1) );
|
||||||
m_indices.emplace_back( index - 1 );
|
m_indices.emplace_back( index - 1 );
|
||||||
m_indices.emplace_back( index );
|
m_indices.emplace_back( index );
|
||||||
m_indices.emplace_back( index );
|
m_indices.emplace_back( index );
|
||||||
m_indices.emplace_back( index - 1 );
|
m_indices.emplace_back( index - ( longitudes + 1 ) );
|
||||||
m_indices.emplace_back( index + 1 );
|
m_indices.emplace_back( index - 1 - ( longitudes + 1 ) );
|
||||||
index += 2;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,6 +147,7 @@ void CSkyDome::Render() {
|
|||||||
::glGenBuffers( 1, &m_indexbuffer );
|
::glGenBuffers( 1, &m_indexbuffer );
|
||||||
::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer );
|
::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer );
|
||||||
::glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), m_indices.data(), GL_STATIC_DRAW );
|
::glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), m_indices.data(), GL_STATIC_DRAW );
|
||||||
|
// NOTE: vertex and index source data is superfluous past this point, but, eh
|
||||||
}
|
}
|
||||||
// begin
|
// begin
|
||||||
::glEnableClientState( GL_VERTEX_ARRAY );
|
::glEnableClientState( GL_VERTEX_ARRAY );
|
||||||
|
|||||||
Reference in New Issue
Block a user