mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
renderer changes, temporary revert shaders for traction because of lack of texless shader
This commit is contained in:
@@ -476,10 +476,11 @@ TTraction::wire_color() const {
|
||||
}
|
||||
default: {break; }
|
||||
}
|
||||
color *= 0.2;
|
||||
// w zaleźności od koloru swiatła
|
||||
color.r *= Global::daylight.ambient.x;
|
||||
color.g *= Global::daylight.ambient.y;
|
||||
color.b *= Global::daylight.ambient.z;
|
||||
//color.r *= Global::daylight.ambient.x;
|
||||
//color.g *= Global::daylight.ambient.y;
|
||||
//color.b *= Global::daylight.ambient.z;
|
||||
}
|
||||
else {
|
||||
// tymczasowo pokazanie zasilanych odcinków
|
||||
|
||||
14
World.cpp
14
World.cpp
@@ -2273,10 +2273,10 @@ world_environment::update() {
|
||||
auto const moonlightlevel = m_moon.getIntensity() * 0.5f; // scaled down by arbitrary factor, it's pretty bright otherwise
|
||||
float keylightintensity;
|
||||
float twilightfactor;
|
||||
glm::vec3 keylightcolor;
|
||||
glm::vec3 keylightcolor(0.0f);
|
||||
if( moonlightlevel > sunlightlevel ) {
|
||||
WriteLog("using moon: " + std::to_string(moonlightlevel));
|
||||
|
||||
twilightfactor = 1.0f;
|
||||
/*
|
||||
// rare situations when the moon is brighter than the sun, typically at night
|
||||
Global::SunAngle = m_moon.getAngle();
|
||||
Global::daylight.direction = -1.0f * m_moon.getDirection();
|
||||
@@ -2284,10 +2284,9 @@ world_environment::update() {
|
||||
// if the moon is up, it overrides the twilight
|
||||
twilightfactor = 0.0f;
|
||||
keylightcolor = glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 202.0f / 255.0f );
|
||||
*/
|
||||
}
|
||||
else {
|
||||
WriteLog("using sun: " + std::to_string(sunlightlevel));
|
||||
|
||||
// regular situation with sun as the key light
|
||||
Global::SunAngle = m_sun.getAngle();
|
||||
Global::daylight.direction = -1.0f * m_sun.getDirection();
|
||||
@@ -2318,10 +2317,7 @@ world_environment::update() {
|
||||
// ...update light colours and intensity.
|
||||
keylightcolor = keylightcolor * diffuselevel;
|
||||
|
||||
if (sunlightlevel > moonlightlevel)
|
||||
Global::daylight.color = keylightcolor * 0.8f;
|
||||
else
|
||||
Global::daylight.color = glm::vec3(0.0f);
|
||||
Global::daylight.color = keylightcolor * 0.8f;
|
||||
|
||||
// tonal impact of skydome color is inversely proportional to how high the sun is above the horizon
|
||||
// (this is pure conjecture, aimed more to 'look right' than be accurate)
|
||||
|
||||
@@ -130,8 +130,7 @@ opengl_vbogeometrybank::create_( geometry_handle const &Geometry ) {
|
||||
// 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?
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
}
|
||||
|
||||
// replace() subclass details
|
||||
@@ -174,6 +173,7 @@ opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, unsigned int con
|
||||
bind_buffer();
|
||||
// NOTE: we're using static_draw since it's generally true for all we have implemented at the moment
|
||||
// TODO: allow to specify usage hint at the object creation, and pass it here
|
||||
m_activestreams = stream::none;
|
||||
::glBufferData(
|
||||
GL_ARRAY_BUFFER,
|
||||
datasize * sizeof( basic_vertex ),
|
||||
@@ -224,16 +224,14 @@ opengl_vbogeometrybank::bind_buffer() {
|
||||
glBindVertexArray(m_vao);
|
||||
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer );
|
||||
m_activebuffer = m_buffer;
|
||||
m_activestreams = stream::none;
|
||||
}
|
||||
|
||||
void
|
||||
opengl_vbogeometrybank::delete_buffer() {
|
||||
|
||||
glDeleteVertexArrays(1, &m_vao);
|
||||
if( m_buffer != NULL ) {
|
||||
|
||||
::glDeleteBuffers( 1, &m_buffer );
|
||||
glBindVertexArray(m_vao);
|
||||
if( m_activebuffer == m_buffer ) {
|
||||
m_activebuffer = NULL;
|
||||
bind_streams( stream::none );
|
||||
|
||||
17
renderer.cpp
17
renderer.cpp
@@ -1028,7 +1028,8 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
}
|
||||
|
||||
auto const originoffset = Node->m_rootposition - m_camera.position();
|
||||
active_shader->set_mv(glm::translate(OpenGLMatrices.data(GL_MODELVIEW), glm::vec3(originoffset.x, originoffset.y, originoffset.z)));
|
||||
glm::mat4 mm(glm::translate(OpenGLMatrices.data(GL_MODELVIEW), glm::vec3(originoffset.x, originoffset.y, originoffset.z)));
|
||||
active_shader->set_mv(mm);
|
||||
|
||||
switch (Node->iType)
|
||||
{
|
||||
@@ -1044,14 +1045,23 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
// na liniach kiepsko wygląda - robi gradient
|
||||
::glDisable( GL_LINE_SMOOTH );
|
||||
}
|
||||
|
||||
gl_program::unbind();
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glPushMatrix();
|
||||
glLoadMatrixf(glm::value_ptr(mm));
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(basic_vertex), static_cast<char *>(nullptr));
|
||||
|
||||
float const linealpha = static_cast<float>(
|
||||
std::min(
|
||||
1.25,
|
||||
5000 * Node->hvTraction->WireThickness / ( distancesquared + 1.0 ) ) ); // zbyt grube nie są dobre
|
||||
::glLineWidth( linealpha );
|
||||
// McZapkie-261102: kolor zalezy od materialu i zasniedzenia
|
||||
|
||||
auto const color { Node->hvTraction->wire_color() };
|
||||
::glColor4f( color.r, color.g, color.b, linealpha );
|
||||
//::glColor4f(0.0f, 0.0f, 0.0f, linealpha);
|
||||
|
||||
Bind( NULL );
|
||||
|
||||
@@ -1063,6 +1073,10 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
||||
::glEnable( GL_LINE_SMOOTH );
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
gl_program::bind_last();
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -1307,6 +1321,7 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel, glm::mat4 m) {
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(basic_vertex), static_cast<char *>(nullptr)); // pozycje
|
||||
|
||||
// setup
|
||||
::glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user