merge, with tmj renderer

This commit is contained in:
milek7
2017-08-18 00:56:05 +02:00
85 changed files with 6815 additions and 3770 deletions

View File

@@ -3,8 +3,6 @@
#include "color.h"
#include "usefull.h"
#include "Globals.h"
// sky gradient based on "A practical analytic model for daylight"
// by A. J. Preetham Peter Shirley Brian Smits (University of Utah)
@@ -43,32 +41,18 @@ float CSkyDome::m_zenithymatrix[ 3 ][ 4 ] = {
//******************************************************************************//
float clamp( float const Value, float const Min, float const Max ) {
CSkyDome::CSkyDome (int const Tesselation) :
m_tesselation( Tesselation ) {
float value = Value;
if( value < Min ) { value = Min; }
if( value > Max ) { value = Max; }
return value;
// SetSunPosition( Math3D::vector3(75.0f, 0.0f, 0.0f) );
SetTurbidity( 3.0f );
SetExposure( true, 20.0f );
SetOvercastFactor( 0.05f );
SetGammaCorrection( 2.2f );
Generate();
}
float interpolate( float const First, float const Second, float const Factor ) {
return ( First * ( 1.0f - Factor ) ) + ( Second * Factor );
}
//******************************************************************************//
void CSkyDome::init(int const Tesselation)
{
m_tesselation = Tesselation;
// SetSunPosition( Math3D::vector3(75.0f, 0.0f, 0.0f) );
SetTurbidity(3.0f);
SetExposure(true, 20.0f);
SetOvercastFactor(0.05f);
SetGammaCorrection(2.2f);
m_shader = gl_program_mvp({ gl_shader("color.frag"),
gl_shader("vbocolor.vert") });
Generate();
CSkyDome::~CSkyDome() {
}
//******************************************************************************//
@@ -133,7 +117,7 @@ void CSkyDome::Update( glm::vec3 const &Sun ) {
// render skydome to screen
void CSkyDome::Render() {
if( m_vao == -1 ) {
if( m_vertexbuffer == -1 ) {
// build the buffers
::glGenBuffers( 1, &m_vertexbuffer );
::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer );
@@ -146,31 +130,23 @@ void CSkyDome::Render() {
::glGenBuffers( 1, &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 );
glGenVertexArrays(1, &m_vao);
glBindVertexArray(m_vao);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexbuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float3), 0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, m_coloursbuffer);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float3), 0);
glEnableVertexAttribArray(1);
glBindVertexArray(0);
// NOTE: vertex and index source data is superfluous past this point, but, eh
}
// begin
m_shader.bind();
glBindVertexArray(m_vao);
m_shader.copy_gl_mvp();
glDrawElements(GL_TRIANGLES, (GLsizei)m_indices.size(), GL_UNSIGNED_SHORT, 0);
glBindVertexArray(0);
m_shader.bind_last();
::glEnableClientState( GL_VERTEX_ARRAY );
::glEnableClientState( GL_COLOR_ARRAY );
// positions
::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer );
::glVertexPointer( 3, GL_FLOAT, sizeof( float3 ), reinterpret_cast<void const*>( 0 ) );
// colours
::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer );
::glColorPointer( 3, GL_FLOAT, sizeof( float3 ), reinterpret_cast<void const*>( 0 ) );
// indices
::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer );
::glDrawElements( GL_TRIANGLES, static_cast<GLsizei>( m_indices.size() ), GL_UNSIGNED_SHORT, reinterpret_cast<void const*>( 0 ) );
// cleanup
::glDisableClientState( GL_COLOR_ARRAY );
::glDisableClientState( GL_VERTEX_ARRAY );
}
bool CSkyDome::SetSunPosition( glm::vec3 const &Direction ) {