16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 15:59:18 +02:00

dynamically assigned render lights

This commit is contained in:
tmj-fstate
2017-02-27 02:58:38 +01:00
parent 0752024d47
commit 80b8da6749
16 changed files with 344 additions and 158 deletions

View File

@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
#include "opengl/glew.h"
#include "texture.h"
#include "lightarray.h"
#include "dumb3d.h"
struct opengl_light {
@@ -23,10 +24,10 @@ struct opengl_light {
GLfloat specular[ 4 ];
opengl_light() {
position[ 0 ] = position[ 1 ] = position[ 2 ] = 0.0f; position[ 3 ] = 1.0f;
ambient[ 0 ] = ambient[ 1 ] = ambient[ 2 ] = 0.0f; ambient[ 3 ] = 1.0f;
diffuse[ 0 ] = diffuse[ 1 ] = diffuse[ 2 ] = diffuse[ 3 ] = 1.0f;
specular[ 0 ] = specular[ 1 ] = specular[ 2 ] = specular[ 3 ] = 1.0f;
position[ 0 ] = position[ 1 ] = position[ 2 ] = 0.0f; position[ 3 ] = 1.0f; // 0,0,0,1
ambient[ 0 ] = ambient[ 1 ] = ambient[ 2 ] = 0.0f; ambient[ 3 ] = 1.0f; // 0,0,0,1
diffuse[ 0 ] = diffuse[ 1 ] = diffuse[ 2 ] = diffuse[ 3 ] = 1.0f; // 1,1,1,1
specular[ 0 ] = specular[ 1 ] = specular[ 2 ] = specular[ 3 ] = 1.0f; // 1,1,1,1
}
inline
@@ -72,33 +73,50 @@ struct opengl_material {
class opengl_renderer {
public:
GLenum static const sunlight{ GL_LIGHT0 };
GLenum static const vehiclelight{ GL_LIGHT1 };
GLenum static const vehiclelightrear{ GL_LIGHT2 };
// types
// methods
void
Init();
void
Update_Lights( light_array const &Lights );
void
Disable_Lights();
texture_manager::size_type
GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true ) {
return m_textures.GetTextureId( Filename, Dir, Filter, Loadnow );
}
void
Bind( texture_manager::size_type const Id ) {
// temporary until we separate the renderer
m_textures.Bind( Id );
}
opengl_texture &
Texture( texture_manager::size_type const Id ) {
return m_textures.Texture( Id );
}
// members
GLenum static const sunlight{ GL_LIGHT0 };
private:
// types
enum class rendermode {
color
};
typedef std::vector<opengl_light> opengllight_array;
// members
rendermode renderpass{ rendermode::color };
opengllight_array m_lights;
texture_manager m_textures;
};