mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 14:39:18 +02:00
merge fixes (still broken)
This commit is contained in:
@@ -69,6 +69,7 @@ set(SOURCES
|
||||
"command.cpp"
|
||||
"keyboardinput.cpp"
|
||||
"gamepadinput.cpp"
|
||||
"openglgeometrybank.cpp"
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
|
||||
7
EU07.cpp
7
EU07.cpp
@@ -298,6 +298,13 @@ int main(int argc, char *argv[])
|
||||
::SendMessage( Hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>( icon ) );
|
||||
#endif
|
||||
|
||||
if ((false == GfxRenderer.Init(window))
|
||||
|| (false == UILayer.init(window)))
|
||||
return -1;
|
||||
|
||||
input::Keyboard.init();
|
||||
input::Gamepad.init();
|
||||
|
||||
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
|
||||
try {
|
||||
if( false == World.Init( window ) ) {
|
||||
|
||||
@@ -522,7 +522,7 @@ TGroundRect::Init() {
|
||||
- glm::vec3( 500.0f, 0.0f, 500.0f ) // 'upper left' corner of rectangle
|
||||
+ glm::vec3( subrectsize * 0.5f, 0.0f, subrectsize * 0.5f ) // center of sub-rectangle
|
||||
+ glm::vec3( subrectsize * column, 0.0f, subrectsize * row );
|
||||
area.radius = subrectsize * M_SQRT2;
|
||||
area.radius = subrectsize * (float)M_SQRT2;
|
||||
// all subcells share the same geometry bank with their parent, to reduce buffer switching during render
|
||||
subcell->m_geometrybank = m_geometrybank;
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
tmp->iType = GL_TRIANGLES;
|
||||
|
||||
auto const nv = importedvertices.size();
|
||||
tmp->Init(nv); // utworzenie tablicy wierzchołków
|
||||
tmp->Init((int)nv); // utworzenie tablicy wierzchołków
|
||||
|
||||
for( std::size_t i = 0; i < nv; ++i ) {
|
||||
tmp->pCenter += importedvertices[ i ].position;
|
||||
@@ -1458,7 +1458,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
||||
|
||||
auto const nv = importedvertices.size();
|
||||
tmp->Points = new glm::dvec3[ nv ];
|
||||
tmp->iNumPts = nv;
|
||||
tmp->iNumPts = (int)nv;
|
||||
for( std::size_t i = 0; i < nv; ++i ) {
|
||||
tmp->Points[ i ] = importedvertices[ i ].position;
|
||||
tmp->pCenter += importedvertices[ i ].position;
|
||||
|
||||
16
Model3d.cpp
16
Model3d.cpp
@@ -1285,13 +1285,13 @@ void TSubModel::serialize(std::ostream &s,
|
||||
sn_utils::ls_float32(s, fVisible);
|
||||
sn_utils::ls_float32(s, fLight);
|
||||
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Ambient[i]);
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Diffuse[i]);
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Specular[i]);
|
||||
for (size_t i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++)
|
||||
sn_utils::ls_float32(s, f4Emision[i]);
|
||||
|
||||
sn_utils::ls_float32(s, fWireSize);
|
||||
@@ -1409,13 +1409,13 @@ void TSubModel::deserialize(std::istream &s)
|
||||
fVisible = sn_utils::ld_float32(s);
|
||||
fLight = sn_utils::ld_float32(s);
|
||||
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Ambient[i] = sn_utils::ld_float32(s);
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Diffuse[i] = sn_utils::ld_float32(s);
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Specular[i] = sn_utils::ld_float32(s);
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 4; ++i)
|
||||
f4Emision[i] = sn_utils::ld_float32(s);
|
||||
|
||||
fWireSize = sn_utils::ld_float32(s);
|
||||
|
||||
@@ -890,14 +890,14 @@ texture_manager::find_in_databank( std::string const &Texturename ) const {
|
||||
|
||||
auto lookup = m_texturemappings.find( Texturename );
|
||||
if( lookup != m_texturemappings.end() ) {
|
||||
return lookup->second;
|
||||
return (int)lookup->second;
|
||||
}
|
||||
// jeszcze próba z dodatkową ścieżką
|
||||
lookup = m_texturemappings.find( szTexturePath + Texturename );
|
||||
|
||||
return (
|
||||
lookup != m_texturemappings.end() ?
|
||||
lookup->second :
|
||||
(int)lookup->second :
|
||||
npos );
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,9 @@ opengl_vbogeometrybank::create_( geometry_handle const &Geometry ) {
|
||||
m_chunkrecords.emplace_back( chunk_record() );
|
||||
// kiss the existing buffer goodbye, new overall data size means we'll be making a new one
|
||||
delete_buffer();
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glGenVertexArrays(1, &m_vao); // TBD: m7todo: maybe vao should be global for all buffers?
|
||||
}
|
||||
|
||||
// replace() subclass details
|
||||
@@ -142,13 +145,11 @@ opengl_vbogeometrybank::replace_( geometry_handle const &Geometry ) {
|
||||
// draw() subclass details
|
||||
void
|
||||
opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, unsigned int const Streams ) {
|
||||
|
||||
if( m_buffer == NULL ) {
|
||||
// if there's no buffer, we'll have to make one
|
||||
// NOTE: this isn't exactly optimal in terms of ensuring the gfx card doesn't stall waiting for the data
|
||||
// may be better to initiate upload earlier (during update phase) and trust this effort won't go to waste
|
||||
if( true == m_chunks.empty() ) { return; }
|
||||
|
||||
std::size_t datasize{ 0 };
|
||||
auto chunkiterator = m_chunks.cbegin();
|
||||
for( auto &chunkrecord : m_chunkrecords ) {
|
||||
@@ -195,23 +196,18 @@ opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, unsigned int con
|
||||
chunk.vertices.data() );
|
||||
chunkrecord.is_good = true;
|
||||
}
|
||||
if( m_activestreams != Streams ) {
|
||||
if( m_activestreams != Streams ) {
|
||||
bind_streams( Streams );
|
||||
}
|
||||
glDebug("D97");
|
||||
// ...render...
|
||||
::glDrawArrays( chunk.type, chunkrecord.offset, chunkrecord.size );
|
||||
::glDrawArrays( chunk.type, (GLint)chunkrecord.offset, (GLsizei)chunkrecord.size );
|
||||
// ...post-render cleanup
|
||||
/*
|
||||
::glDisableClientState( GL_VERTEX_ARRAY );
|
||||
::glDisableClientState( GL_NORMAL_ARRAY );
|
||||
::glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
::glBindBuffer( GL_ARRAY_BUFFER, 0 ); m_activebuffer = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
opengl_vbogeometrybank::bind_buffer() {
|
||||
|
||||
glBindVertexArray(m_vao);
|
||||
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer );
|
||||
m_activebuffer = m_buffer;
|
||||
m_activestreams = stream::none;
|
||||
@@ -223,6 +219,7 @@ opengl_vbogeometrybank::delete_buffer() {
|
||||
if( m_buffer != NULL ) {
|
||||
|
||||
::glDeleteBuffers( 1, &m_buffer );
|
||||
glBindVertexArray(m_vao);
|
||||
if( m_activebuffer == m_buffer ) {
|
||||
m_activebuffer = NULL;
|
||||
}
|
||||
@@ -235,35 +232,36 @@ opengl_vbogeometrybank::delete_buffer() {
|
||||
|
||||
void
|
||||
opengl_vbogeometrybank::bind_streams( unsigned int const Streams ) {
|
||||
|
||||
if( Streams & stream::position ) {
|
||||
::glVertexPointer( 3, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) );
|
||||
::glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 8, (GLvoid*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
}
|
||||
else {
|
||||
::glDisableClientState( GL_VERTEX_ARRAY );
|
||||
glDisableVertexAttribArray(0);
|
||||
}
|
||||
|
||||
// NOTE: normal and color streams share the data, making them effectively mutually exclusive
|
||||
if( Streams & stream::normal ) {
|
||||
::glNormalPointer( GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) + sizeof( float ) * 3 );
|
||||
::glEnableClientState( GL_NORMAL_ARRAY );
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 8, (GLvoid*)(sizeof(float) * 3));
|
||||
glEnableVertexAttribArray(1);
|
||||
}
|
||||
else {
|
||||
::glDisableClientState( GL_NORMAL_ARRAY );
|
||||
glDisableVertexAttribArray(1);
|
||||
}
|
||||
|
||||
if( Streams & stream::color ) {
|
||||
::glColorPointer( 3, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) + sizeof( float ) * 3 );
|
||||
::glEnableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
}
|
||||
else {
|
||||
::glDisableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
}
|
||||
|
||||
if( Streams & stream::texture ) {
|
||||
::glTexCoordPointer( 2, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) + 24 );
|
||||
::glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 8, (GLvoid*)(sizeof(float) * 6));
|
||||
glEnableVertexAttribArray(2);
|
||||
}
|
||||
else {
|
||||
::glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glDisableVertexAttribArray(2);
|
||||
}
|
||||
|
||||
m_activestreams = Streams;
|
||||
@@ -331,10 +329,9 @@ opengl_dlgeometrybank::delete_list( geometry_handle const &Geometry ) {
|
||||
geometrybank_handle
|
||||
geometrybank_manager::create_bank() {
|
||||
|
||||
if( true == Global::bUseVBO ) { m_geometrybanks.emplace_back( std::make_shared<opengl_vbogeometrybank>() ); }
|
||||
else { m_geometrybanks.emplace_back( std::make_shared<opengl_dlgeometrybank>() ); }
|
||||
m_geometrybanks.emplace_back( std::make_shared<opengl_vbogeometrybank>() );
|
||||
// NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication
|
||||
return geometrybank_handle( m_geometrybanks.size(), 0 );
|
||||
return geometrybank_handle( (uint32_t)m_geometrybanks.size(), 0 );
|
||||
}
|
||||
|
||||
// creates a new geometry chunk of specified type from supplied vertex data, in specified bank. returns: handle to the chunk or NULL
|
||||
|
||||
@@ -190,6 +190,7 @@ private:
|
||||
static GLuint m_activebuffer; // buffer bound currently on the opengl end, if any
|
||||
static unsigned int m_activestreams;
|
||||
GLuint m_buffer { NULL }; // id of the buffer holding data on the opengl end
|
||||
GLuint m_vao = 0;
|
||||
std::size_t m_buffercapacity{ 0 }; // total capacity of the last established buffer
|
||||
chunkrecord_sequence m_chunkrecords; // helper data for all stored geometry chunks, in matching order
|
||||
|
||||
|
||||
112
renderer.cpp
112
renderer.cpp
@@ -157,7 +157,6 @@ opengl_renderer::Render() {
|
||||
// frustum tests are performed in 'world space' but after we set up frustum
|
||||
// we no longer need camera translation, only rotation
|
||||
::glMultMatrixd( glm::value_ptr( glm::dmat4( glm::dmat3( worldcamera ))));
|
||||
|
||||
glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
Render( &World.Environment );
|
||||
glUseProgram(World.shader);
|
||||
@@ -171,11 +170,10 @@ opengl_renderer::Render() {
|
||||
m_drawtime = std::max( 20.0f, 0.95f * m_drawtime + std::chrono::duration_cast<std::chrono::milliseconds>( ( std::chrono::steady_clock::now() - timestart ) ).count());
|
||||
m_drawcount = m_drawqueue.size();
|
||||
}
|
||||
|
||||
glDebug("dis1");
|
||||
glUseProgram(0);
|
||||
glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
UILayer.render();
|
||||
|
||||
glfwSwapBuffers( m_window );
|
||||
return true; // for now always succeed
|
||||
}
|
||||
@@ -204,10 +202,8 @@ opengl_renderer::Render( world_environment *Environment ) {
|
||||
else { ::glDisable( GL_FOG ); }
|
||||
|
||||
Environment->m_skydome.Render();
|
||||
if( true == Global::bUseVBO ) {
|
||||
// skydome uses a custom vbo which could potentially confuse the main geometry system. hardly elegant but, eh
|
||||
opengl_vbogeometrybank::reset();
|
||||
}
|
||||
// skydome uses a custom vbo which could potentially confuse the main geometry system. hardly elegant but, eh
|
||||
opengl_vbogeometrybank::reset();
|
||||
Environment->m_stars.render();
|
||||
|
||||
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
|
||||
@@ -366,6 +362,8 @@ opengl_renderer::Texture( texture_handle const Texture ) {
|
||||
bool
|
||||
opengl_renderer::Render( TGround *Ground ) {
|
||||
|
||||
World.shader.set_p(OpenGLMatrices.data(GL_PROJECTION));
|
||||
|
||||
::glEnable( GL_LIGHTING );
|
||||
::glDisable( GL_BLEND );
|
||||
::glAlphaFunc( GL_GREATER, 0.50f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
|
||||
@@ -408,7 +406,9 @@ opengl_renderer::Render( TGround *Ground ) {
|
||||
}
|
||||
|
||||
if( m_camera.visible( cell->m_area ) ) {
|
||||
glDebug("to tu?");
|
||||
Render( cell );
|
||||
glDebug("koniec to tu");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -443,7 +443,6 @@ opengl_renderer::Render( TGroundRect *Groundcell ) {
|
||||
}
|
||||
}
|
||||
if( Groundcell->nTerrain ) {
|
||||
|
||||
Render( Groundcell->nTerrain );
|
||||
}
|
||||
Groundcell->iLastDisplay = Groundcell->iFrameNumber; // drugi raz nie potrzeba
|
||||
@@ -506,6 +505,7 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
||||
/*
|
||||
Node->SetLastUsage( Timer::GetSimulationTime() );
|
||||
*/
|
||||
|
||||
switch (Node->iType)
|
||||
{ // obiekty renderowane niezależnie od odległości
|
||||
case TP_SUBMODEL:
|
||||
@@ -524,17 +524,14 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
World.shader.set_mv(glm::translate(OpenGLMatrices.data(GL_MODELVIEW), glm::vec3(originoffset.x, originoffset.y, originoffset.z)));
|
||||
|
||||
switch (Node->iType) {
|
||||
|
||||
case TP_TRACK: {
|
||||
// setup
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
// render
|
||||
Render( Node->pTrack );
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -553,23 +550,16 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
||||
::glColor4fv(
|
||||
glm::value_ptr(
|
||||
glm::vec4(
|
||||
Node->Diffuse * glm::make_vec3( Global::DayLight.ambient ),
|
||||
Node->Diffuse * Global::daylight.ambient,
|
||||
std::min(
|
||||
1.0,
|
||||
1000.0 * Node->fLineThickness / ( distancesquared + 1.0 ) ) ) ) );
|
||||
|
||||
GfxRenderer.Bind( 0 );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->m_geometry );
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -583,16 +573,9 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
||||
|
||||
Bind( Node->TextureID );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->m_geometry );
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -803,7 +786,7 @@ opengl_renderer::Render( TSubModel *Submodel, glm::mat4 m) {
|
||||
glUseProgram(0);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glLoadMatrixf(glm::value_ptr(mm));
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(CVertNormTex), static_cast<char *>(nullptr)); // pozycje
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(basic_vertex), static_cast<char *>(nullptr)); // pozycje
|
||||
|
||||
// material configuration:
|
||||
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_POINT_BIT );
|
||||
@@ -862,7 +845,7 @@ opengl_renderer::Render( TSubModel *Submodel, glm::mat4 m) {
|
||||
|
||||
if( Submodel->Next )
|
||||
if( Submodel->iAlpha & Submodel->iFlags & 0x1F000000 )
|
||||
Render( Submodel->Next ); // dalsze rekurencyjnie
|
||||
Render( Submodel->Next, m ); // dalsze rekurencyjnie
|
||||
}
|
||||
|
||||
void
|
||||
@@ -965,6 +948,9 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
World.shader.set_mv(glm::translate(OpenGLMatrices.data(GL_MODELVIEW), glm::vec3(originoffset.x, originoffset.y, originoffset.z)));
|
||||
|
||||
switch (Node->iType)
|
||||
{
|
||||
case TP_TRACTION: {
|
||||
@@ -990,16 +976,9 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
|
||||
Bind( NULL );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->hvTraction->m_geometry );
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
::glLineWidth( 1.0 );
|
||||
if( !Global::bSmoothTraction ) {
|
||||
::glEnable( GL_LINE_SMOOTH );
|
||||
@@ -1026,7 +1005,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
::glColor4fv(
|
||||
glm::value_ptr(
|
||||
glm::vec4(
|
||||
Node->Diffuse * glm::make_vec3( Global::DayLight.ambient ), // w zaleznosci od koloru swiatla
|
||||
Node->Diffuse * Global::daylight.ambient, // w zaleznosci od koloru swiatla
|
||||
std::min( 1.0, linewidth ) ) ) );
|
||||
if( linewidth > 1.0 ) {
|
||||
::glLineWidth( static_cast<float>(linewidth) );
|
||||
@@ -1034,10 +1013,6 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
|
||||
GfxRenderer.Bind( 0 );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->m_geometry );
|
||||
|
||||
@@ -1046,8 +1021,6 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
::glLineWidth( 1.0f );
|
||||
}
|
||||
|
||||
::glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1061,16 +1034,9 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
|
||||
Bind( Node->TextureID );
|
||||
|
||||
::glPushMatrix();
|
||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||
|
||||
// render
|
||||
m_geometry.draw( Node->m_geometry );
|
||||
|
||||
// post-render cleanup
|
||||
::glPopMatrix();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1209,27 +1175,29 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel, glm::mat4 m) {
|
||||
World.shader.set_mv(mm);
|
||||
}
|
||||
|
||||
if( Submodel->eType < TP_ROTATOR ) {
|
||||
// renderowanie obiektów OpenGL
|
||||
if( Submodel->iAlpha & Submodel->iFlags & 0x2F ) // rysuj gdy element przezroczysty
|
||||
{
|
||||
// textures...
|
||||
if( Submodel->TextureID < 0 ) { // zmienialne skóry
|
||||
Bind( Submodel->ReplacableSkinId[ -Submodel->TextureID ] );
|
||||
}
|
||||
else {
|
||||
// również 0
|
||||
Bind( Submodel->TextureID );
|
||||
}
|
||||
::glColor3fv( glm::value_ptr(Submodel->f4Diffuse) ); // McZapkie-240702: zamiast ub
|
||||
// ...luminance
|
||||
if( Global::fLuminance < Submodel->fLight ) {
|
||||
// zeby swiecilo na kolorowo
|
||||
::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr(Submodel->f4Diffuse) );
|
||||
}
|
||||
if (Submodel->eType < TP_ROTATOR) {
|
||||
// renderowanie obiektów OpenGL
|
||||
if (Submodel->iAlpha & Submodel->iFlags & 0x2F) // rysuj gdy element przezroczysty
|
||||
{
|
||||
// textures...
|
||||
if (Submodel->TextureID < 0) { // zmienialne skóry
|
||||
Bind(Submodel->ReplacableSkinId[-Submodel->TextureID]);
|
||||
}
|
||||
else {
|
||||
// również 0
|
||||
Bind(Submodel->TextureID);
|
||||
}
|
||||
::glColor3fv(glm::value_ptr(Submodel->f4Diffuse)); // McZapkie-240702: zamiast ub
|
||||
// ...luminance
|
||||
if (Global::fLuminance < Submodel->fLight) {
|
||||
// zeby swiecilo na kolorowo
|
||||
::glMaterialfv(GL_FRONT, GL_EMISSION, glm::value_ptr(Submodel->f4Diffuse));
|
||||
}
|
||||
|
||||
// main draw call
|
||||
m_geometry.draw( Submodel->m_geometry );
|
||||
// main draw call
|
||||
m_geometry.draw(Submodel->m_geometry);
|
||||
}
|
||||
}
|
||||
|
||||
else if( Submodel->eType == TP_FREESPOTLIGHT ) {
|
||||
|
||||
|
||||
13
renderer.h
13
renderer.h
@@ -78,18 +78,12 @@ public:
|
||||
Render( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
||||
bool
|
||||
Render( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
||||
void
|
||||
Render( TSubModel *Submodel );
|
||||
void Render( TSubModel *Submodel );
|
||||
void Render(TSubModel *Submodel, glm::mat4 m);
|
||||
void Render_Alpha(TSubModel *Submodel);
|
||||
void
|
||||
Render( TMemCell *Memcell );
|
||||
bool
|
||||
Render_Alpha( TDynamicObject *Dynamic );
|
||||
bool
|
||||
Render_Alpha( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
||||
void
|
||||
Render_Alpha( TSubModel *Submodel, glm::mat4 m);
|
||||
bool
|
||||
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
||||
// maintenance jobs
|
||||
@@ -136,6 +130,8 @@ private:
|
||||
color
|
||||
};
|
||||
|
||||
typedef std::pair<double, TSubRect*> distancesubcell_pair;
|
||||
|
||||
// methods
|
||||
bool
|
||||
Init_caps();
|
||||
@@ -161,11 +157,12 @@ private:
|
||||
Render_Alpha( TGroundNode *Node );
|
||||
void
|
||||
Render_Alpha( TSubModel *Submodel );
|
||||
void
|
||||
Render_Alpha(TSubModel *Submodel, glm::mat4 m);
|
||||
void
|
||||
Update_Lights( light_array const &Lights );
|
||||
|
||||
// members
|
||||
opengllight_array m_lights;
|
||||
geometrybank_manager m_geometry;
|
||||
texture_manager m_textures;
|
||||
opengl_camera m_camera;
|
||||
|
||||
@@ -169,6 +169,7 @@ void CSkyDome::Render() {
|
||||
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)m_indices.size(), GL_UNSIGNED_SHORT, 0);
|
||||
glBindVertexArray(0);
|
||||
glDebug("dis2");
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user