mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-23 03:02:50 +03:00
Some work on the OpenGL 3 renderer.
This commit is contained in:
@@ -93,7 +93,7 @@
|
||||
#define EE_ENDIAN EE_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_LINUX
|
||||
#if EE_PLATFORM == EE_PLATFORM_WIN || EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_LINUX || !defined( EE_GLES )
|
||||
#define EE_GLEW_AVAILABLE
|
||||
#else
|
||||
#warning Platform not supported.
|
||||
|
||||
@@ -27,7 +27,6 @@ using namespace EE::System;
|
||||
|
||||
#include "renders.hpp"
|
||||
|
||||
//#define EE_GLES
|
||||
#ifdef EE_GLES
|
||||
#define EE_QUAD_VERTEX 6
|
||||
#else
|
||||
|
||||
@@ -127,9 +127,15 @@ void cBatchRenderer::Flush() {
|
||||
Uint32 alloc = sizeof(eeVertex) * NumVertex;
|
||||
|
||||
GLi->VertexPointer ( 2, GL_FLOAT , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) , alloc );
|
||||
GLi->TexCoordPointer( 2, GL_FLOAT , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) + sizeof(eeVector2f) , alloc );
|
||||
GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) + sizeof(eeVector2f) + sizeof(eeTexCoord) , alloc );
|
||||
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
if ( NULL != mTexture )
|
||||
GLi->TexCoordPointer( 2, GL_FLOAT , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) + sizeof(eeVector2f) , alloc );
|
||||
} else {
|
||||
GLi->TexCoordPointer( 2, GL_FLOAT , sizeof(eeVertex), reinterpret_cast<char*> ( &mVertex[0] ) + sizeof(eeVector2f) , alloc );
|
||||
}
|
||||
|
||||
#ifdef EE_GLES
|
||||
if ( DM_QUADS == mCurrentMode ) {
|
||||
GLi->DrawArrays( DM_TRIANGLES, 0, NumVertex );
|
||||
|
||||
@@ -28,19 +28,19 @@ cFrameBufferFBO::~cFrameBufferFBO() {
|
||||
return;
|
||||
|
||||
GLint curFB;
|
||||
glGetIntegerv( GL_FRAMEBUFFER_BINDING_EXT, &curFB );
|
||||
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &curFB );
|
||||
|
||||
if ( curFB == mFrameBuffer )
|
||||
Unbind();
|
||||
|
||||
if ( mDepthBuffer ) {
|
||||
GLuint depthBuffer = static_cast<GLuint>( mDepthBuffer );
|
||||
glDeleteFramebuffersEXT( 1, &depthBuffer );
|
||||
glDeleteFramebuffers( 1, &depthBuffer );
|
||||
}
|
||||
|
||||
if ( mFrameBuffer ) {
|
||||
GLuint frameBuffer = static_cast<GLuint>( mFrameBuffer );
|
||||
glDeleteFramebuffersEXT( 1, &frameBuffer );
|
||||
glDeleteFramebuffers( 1, &frameBuffer );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,30 +58,30 @@ bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height, bool De
|
||||
|
||||
GLuint frameBuffer = 0;
|
||||
|
||||
glGenFramebuffersEXT( 1, &frameBuffer );
|
||||
glGenFramebuffers( 1, &frameBuffer );
|
||||
|
||||
mFrameBuffer = static_cast<unsigned int>( frameBuffer );
|
||||
|
||||
if ( !mFrameBuffer)
|
||||
return false;
|
||||
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, mFrameBuffer );
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, mFrameBuffer );
|
||||
|
||||
if ( DepthBuffer ) {
|
||||
GLuint depth = 0;
|
||||
|
||||
glGenRenderbuffersEXT( 1, &depth );
|
||||
glGenRenderbuffers( 1, &depth );
|
||||
|
||||
mDepthBuffer = static_cast<unsigned int>(depth);
|
||||
|
||||
if ( !mDepthBuffer )
|
||||
return false;
|
||||
|
||||
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, mDepthBuffer );
|
||||
glBindRenderbuffer( GL_RENDERBUFFER, mDepthBuffer );
|
||||
|
||||
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, Width, Height );
|
||||
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT, Width, Height );
|
||||
|
||||
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepthBuffer );
|
||||
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mDepthBuffer );
|
||||
}
|
||||
|
||||
if ( NULL == mTexture ) {
|
||||
@@ -94,22 +94,22 @@ bool cFrameBufferFBO::Create( const Uint32& Width, const Uint32& Height, bool De
|
||||
}
|
||||
}
|
||||
|
||||
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mTexture->Handle(), 0 );
|
||||
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture->Handle(), 0 );
|
||||
|
||||
if ( glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT ) {
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
|
||||
if ( glCheckFramebufferStatus( GL_FRAMEBUFFER ) != GL_FRAMEBUFFER_COMPLETE ) {
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cFrameBufferFBO::Bind() {
|
||||
if ( mFrameBuffer ) {
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, mFrameBuffer );
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, mFrameBuffer );
|
||||
SetBufferView();
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void cFrameBufferFBO::Bind() {
|
||||
void cFrameBufferFBO::Unbind() {
|
||||
if ( mFrameBuffer ) {
|
||||
RecoverView();
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,10 +280,51 @@ bool cShaderProgram::SetUniform( const std::string& Name, Int32 Value ) {
|
||||
return ( Location >= 0 );
|
||||
}
|
||||
|
||||
bool cShaderProgram::SetUniformMatrix( const Int32& Id, const float * Value ) {
|
||||
glUniformMatrix4fv( Id, 1, false, Value );
|
||||
bool cShaderProgram::SetUniform( const Int32& Location, Int32 Value ) {
|
||||
if ( -1 != Location ) {
|
||||
glUniform1i( Location, Value );
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cShaderProgram::SetUniform( const Int32& Location, eeFloat Value ) {
|
||||
if ( -1 != Location ) {
|
||||
glUniform1f( Location, Value );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cShaderProgram::SetUniform( const Int32& Location, eeVector2f Value ) {
|
||||
if ( -1 != Location ) {
|
||||
glUniform2fv( Location, 1, reinterpret_cast<eeFloat*>( &Value ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cShaderProgram::SetUniform( const Int32& Location, eeVector3f Value ) {
|
||||
if ( -1 != Location ) {
|
||||
glUniform3fv( Location, 1, reinterpret_cast<eeFloat*>( &Value ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cShaderProgram::SetUniformMatrix( const Int32& Location, const float * Value ) {
|
||||
if ( -1 != Location ) {
|
||||
glUniformMatrix4fv( Location, 1, false, Value );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cShaderProgram::SetUniformMatrix( const std::string Name, const float * Value ) {
|
||||
|
||||
@@ -74,9 +74,17 @@ class EE_API cShaderProgram {
|
||||
/** @overload */
|
||||
bool SetUniform( const std::string& Name, Int32 Value );
|
||||
|
||||
bool SetUniform( const Int32& Location, Int32 Value );
|
||||
|
||||
bool SetUniform( const Int32& Location, eeFloat Value );
|
||||
|
||||
bool SetUniform( const Int32& Location, eeVector2f Value );
|
||||
|
||||
bool SetUniform( const Int32& Location, eeVector3f Value );
|
||||
|
||||
bool SetUniformMatrix( const std::string Name, const float * Value );
|
||||
|
||||
bool SetUniformMatrix( const Int32& Id, const float * Value );
|
||||
bool SetUniformMatrix( const Int32& Location, const float * Value );
|
||||
|
||||
/** @return The id of the program (the handle) */
|
||||
const Uint32& Handler() const { return mHandler; }
|
||||
|
||||
@@ -155,10 +155,6 @@ void cVertexBuffer::Unbind() {
|
||||
}
|
||||
|
||||
if( !VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) {
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
}
|
||||
|
||||
GLi->Enable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ void cVertexBufferOGL::SetVertexStates() {
|
||||
if ( GLi->IsExtension( EEGL_ARB_multitexture ) ) {
|
||||
for ( Int32 i = 0; i < 5; i++ ) {
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) {
|
||||
glClientActiveTextureARB( GL_TEXTURE0_ARB + i );
|
||||
GLi->ClientActiveTexture( GL_TEXTURE0 + i );
|
||||
GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, sizeof(float) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 + i ][0], alloc );
|
||||
} else {
|
||||
//GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
GLi->Disable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -75,8 +75,8 @@ void cVertexBufferOGL::SetVertexStates() {
|
||||
}
|
||||
}
|
||||
|
||||
GLi->ActiveTexture( GL_TEXTURE0_ARB );
|
||||
glClientActiveTextureARB( GL_TEXTURE0_ARB );
|
||||
GLi->ActiveTexture( GL_TEXTURE0 );
|
||||
GLi->ClientActiveTexture( GL_TEXTURE0 );
|
||||
}
|
||||
|
||||
void cVertexBufferOGL::Update( const Uint32& Types, bool Indices ) {
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace EE { namespace Graphics {
|
||||
cVertexBufferVBO::cVertexBufferVBO( const Uint32& VertexFlags, EE_DRAW_MODE DrawType, const Int32& ReserveVertexSize, const Int32& ReserveIndexSize, EE_VBO_USAGE_TYPE UsageType ) :
|
||||
cVertexBuffer( VertexFlags, DrawType, ReserveVertexSize, ReserveIndexSize, UsageType ),
|
||||
mCompiled( false ),
|
||||
mBuffersSet( false ),
|
||||
mTextured( false ),
|
||||
mVAO( 0 ),
|
||||
mElementHandle( 0 )
|
||||
{
|
||||
@@ -83,7 +85,8 @@ bool cVertexBufferVBO::Compile() {
|
||||
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
|
||||
}
|
||||
|
||||
mCompiled = true;
|
||||
mCompiled = true;
|
||||
mBuffersSet = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -94,6 +97,10 @@ void cVertexBufferVBO::Draw() {
|
||||
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
glBindVertexArray( mVAO );
|
||||
|
||||
if ( !mTextured ) {
|
||||
GLi->Disable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) {
|
||||
@@ -110,17 +117,31 @@ void cVertexBufferVBO::Draw() {
|
||||
} else {
|
||||
glDrawArrays( mDrawType, 0, GetVertexCount() );
|
||||
}
|
||||
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
if ( !mTextured ) {
|
||||
GLi->Enable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cVertexBufferVBO::SetVertexStates() {
|
||||
GLint index;
|
||||
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
if ( mBuffersSet ) {
|
||||
if ( !mTextured ) {
|
||||
GLi->Disable( GL_TEXTURE_2D );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
glBindVertexArray( mVAO );
|
||||
}
|
||||
|
||||
/// POSITION
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) {
|
||||
if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) {
|
||||
GLi->EnableClientState( GL_VERTEX_ARRAY );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mArrayHandle[ VERTEX_FLAG_POSITION ] );
|
||||
|
||||
@@ -130,7 +151,7 @@ void cVertexBufferVBO::SetVertexStates() {
|
||||
if ( -1 != index )
|
||||
glVertexAttribPointer( index, eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, GL_FALSE, 0, 0 );
|
||||
} else {
|
||||
glVertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, 0, (char*)NULL );
|
||||
GLi->VertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FLOAT, 0, (char*)NULL, 0 );
|
||||
}
|
||||
} else {
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
@@ -139,7 +160,7 @@ void cVertexBufferVBO::SetVertexStates() {
|
||||
}
|
||||
|
||||
/// COLOR
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) {
|
||||
if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) {
|
||||
GLi->EnableClientState( GL_COLOR_ARRAY );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mArrayHandle[ VERTEX_FLAG_COLOR ] );
|
||||
|
||||
@@ -149,7 +170,7 @@ void cVertexBufferVBO::SetVertexStates() {
|
||||
if ( -1 != index )
|
||||
glVertexAttribPointer( index, eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, GL_TRUE, 0, 0 );
|
||||
} else {
|
||||
glColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, 0, (char*)NULL );
|
||||
GLi->ColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, 0, (char*)NULL, 0 );
|
||||
}
|
||||
} else {
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
@@ -162,57 +183,61 @@ void cVertexBufferVBO::SetVertexStates() {
|
||||
for ( Int32 i = 0; i < 5; i++ ) {
|
||||
if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 + i ) ) {
|
||||
if ( GLv_3 != GLi->Version() ) {
|
||||
glClientActiveTexture( GL_TEXTURE0 + i );
|
||||
GLi->ClientActiveTexture( GL_TEXTURE0 + i );
|
||||
}
|
||||
|
||||
GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mArrayHandle[ VERTEX_FLAG_TEXTURE0 + i ] );
|
||||
|
||||
if ( GLv_3 == GLi->Version() ) { /** FIXME: Give Support for multitexturing */
|
||||
if ( GLv_3 == GLi->Version() ) { /** FIXME: Support for multitexturing */
|
||||
index = GLi->GetRendererGL3()->GetStateIndex( EEGL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
if ( -1 != index && 0 == i )
|
||||
glVertexAttribPointer( index, eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, GL_FALSE, 0, 0 );
|
||||
} else {
|
||||
glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, 0, (char*)NULL );
|
||||
}
|
||||
} else {
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FLOAT, 0, (char*)NULL, 0 );
|
||||
}
|
||||
|
||||
mTextured = true;
|
||||
} else {
|
||||
GLi->Disable( GL_TEXTURE_2D );
|
||||
|
||||
mTextured = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) {
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mArrayHandle[ VERTEX_FLAG_TEXTURE0 ] );
|
||||
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
index = GLi->GetRendererGL3()->GetStateIndex( EEGL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
if ( -1 != index ) // Give Support for multitexturing
|
||||
glVertexAttribPointer( index, eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FLOAT, GL_FALSE, 0, 0 );
|
||||
} else {
|
||||
glTexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FLOAT, 0, (char*)NULL );
|
||||
}
|
||||
} else {
|
||||
if ( GLv_3 == GLi->Version() ) {
|
||||
GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
index = GLi->GetRendererGL3()->GetStateIndex( EEGL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
if ( -1 != index ) /** FIXME: Support for multitexturing */
|
||||
glVertexAttribPointer( index, eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FLOAT, GL_FALSE, 0, 0 );
|
||||
} else {
|
||||
GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FLOAT, 0, (char*)NULL, 0 );
|
||||
}
|
||||
|
||||
mTextured = true;
|
||||
} else {
|
||||
GLi->Disable( GL_TEXTURE_2D );
|
||||
|
||||
mTextured = false;
|
||||
}
|
||||
}
|
||||
|
||||
GLi->ActiveTexture( GL_TEXTURE0 );
|
||||
|
||||
if ( GLv_3 != GLi->Version() ) {
|
||||
glClientActiveTexture( GL_TEXTURE0 );
|
||||
GLi->ClientActiveTexture( GL_TEXTURE0 );
|
||||
}
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
|
||||
mBuffersSet = true;
|
||||
}
|
||||
|
||||
void cVertexBufferVBO::Update( const Uint32& Types, bool Indices ) {
|
||||
@@ -242,10 +267,14 @@ void cVertexBufferVBO::Update( const Uint32& Types, bool Indices ) {
|
||||
|
||||
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
|
||||
}
|
||||
|
||||
mBuffersSet = false;
|
||||
}
|
||||
|
||||
void cVertexBufferVBO::Reload() {
|
||||
mCompiled = false;
|
||||
mCompiled = false;
|
||||
mBuffersSet = false;
|
||||
|
||||
Compile();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ class cVertexBufferVBO : public cVertexBuffer {
|
||||
|
||||
bool mCompiled;
|
||||
|
||||
bool mBuffersSet;
|
||||
|
||||
bool mTextured;
|
||||
|
||||
GLuint mVAO;
|
||||
|
||||
Uint32 mElementHandle;
|
||||
|
||||
@@ -29,9 +29,9 @@ cGL * cGL::CreateSingleton() {
|
||||
if ( ms_singleton == 0 ) {
|
||||
#ifdef EE_GL3_ENABLED
|
||||
/** Implement an OpenGL3 compilant renderer */
|
||||
/*if ( '3' == glGetString(GL_VERSION)[0] )
|
||||
if ( '3' == glGetString(GL_VERSION)[0] )
|
||||
ms_singleton = eeNew( cRendererGL3, () );
|
||||
else*/
|
||||
else
|
||||
#endif
|
||||
ms_singleton = eeNew( cRendererGL, () );
|
||||
}
|
||||
|
||||
@@ -28,13 +28,14 @@ enum EEGL_ARRAY_STATES {
|
||||
EEGL_INDEX_ARRAY = 3,
|
||||
EEGL_TEXTURE_COORD_ARRAY = 4,
|
||||
EEGL_EDGE_FLAG_ARRAY = 5,
|
||||
EEGL_ARRAY_STATES_SIZE
|
||||
EEGL_ARRAY_STATES_COUNT
|
||||
};
|
||||
|
||||
enum EEGL_SHADERS_NUM {
|
||||
enum EEGL_SHADERS {
|
||||
EEGL_SHADER_BASE_TEX,
|
||||
EEGL_SHADER_BASE,
|
||||
EEGL_SHADER_POINT_SPRITE,
|
||||
EEGL_SHADER_CLIP,
|
||||
EEGL_SHADERS_COUNT
|
||||
};
|
||||
|
||||
@@ -109,6 +110,8 @@ class cGL {
|
||||
|
||||
void Viewport ( GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
|
||||
virtual void ClientActiveTexture( GLenum texture ) = 0;
|
||||
|
||||
virtual void Disable ( GLenum cap );
|
||||
|
||||
virtual void Enable( GLenum cap );
|
||||
@@ -147,6 +150,10 @@ class cGL {
|
||||
|
||||
virtual void SetShader( cShaderProgram * Shader );
|
||||
|
||||
virtual void ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) = 0;
|
||||
|
||||
virtual void ClipPlaneDisable() = 0;
|
||||
|
||||
cRendererGL * GetRendererGL();
|
||||
|
||||
cRendererGL3 * GetRendererGL3();
|
||||
|
||||
@@ -72,4 +72,37 @@ void cRendererGL::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, con
|
||||
glTexCoordPointer( size, type, stride, pointer );
|
||||
}
|
||||
|
||||
void cRendererGL::ClientActiveTexture( GLenum texture ) {
|
||||
glClientActiveTexture( texture );
|
||||
}
|
||||
|
||||
void cRendererGL::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
|
||||
GLdouble tX = (GLdouble)x;
|
||||
GLdouble tY = (GLdouble)y;
|
||||
GLdouble tW = (GLdouble)Width;
|
||||
GLdouble tH = (GLdouble)Height;
|
||||
|
||||
GLdouble clip_left[] = { 1.0 , 0.0 , 0.0, -tX };
|
||||
GLdouble clip_right[] = { -1.0, 0.0 , 0.0, tX + tW };
|
||||
GLdouble clip_top[] = { 0.0 , 1.0 , 0.0, -tY };
|
||||
GLdouble clip_bottom[] = { 0.0 , -1.0 , 0.0, tY + tH };
|
||||
|
||||
GLi->Enable(GL_CLIP_PLANE0);
|
||||
GLi->Enable(GL_CLIP_PLANE1);
|
||||
GLi->Enable(GL_CLIP_PLANE2);
|
||||
GLi->Enable(GL_CLIP_PLANE3);
|
||||
|
||||
glClipPlane(GL_CLIP_PLANE0, clip_left);
|
||||
glClipPlane(GL_CLIP_PLANE1, clip_right);
|
||||
glClipPlane(GL_CLIP_PLANE2, clip_top);
|
||||
glClipPlane(GL_CLIP_PLANE3, clip_bottom);
|
||||
}
|
||||
|
||||
void cRendererGL::ClipPlaneDisable() {
|
||||
GLi->Disable(GL_CLIP_PLANE0);
|
||||
GLi->Disable(GL_CLIP_PLANE1);
|
||||
GLi->Disable(GL_CLIP_PLANE2);
|
||||
GLi->Disable(GL_CLIP_PLANE3);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -13,6 +13,8 @@ class cRendererGL : public cGL {
|
||||
|
||||
EEGL_version Version();
|
||||
|
||||
void ClientActiveTexture( GLenum texture );
|
||||
|
||||
void PushMatrix();
|
||||
|
||||
void PopMatrix();
|
||||
@@ -42,6 +44,10 @@ class cRendererGL : public cGL {
|
||||
void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate );
|
||||
|
||||
void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate );
|
||||
|
||||
void ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height );
|
||||
|
||||
void ClipPlaneDisable();
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ const GLchar * EEGL_SHADER_BASE_VS[] = {
|
||||
"void main(void)\n",
|
||||
"{\n",
|
||||
" Color = dgl_Color;\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex.x, dgl_Vertex.y, 0.0, 1.0 );\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n",
|
||||
" gl_Position = dgl_ProjectionMatrix * dgl_ModelViewMatrix * v4;\n",
|
||||
"}\n"
|
||||
};
|
||||
@@ -53,7 +53,7 @@ const GLchar * EEGL_SHADER_BASE_TEX_VS[] = {
|
||||
"{\n",
|
||||
" Color = dgl_Color;\n",
|
||||
" TexCoord = dgl_TexCoord;\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex.x, dgl_Vertex.y, 0.0, 1.0 );\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n",
|
||||
" gl_Position = dgl_ProjectionMatrix * dgl_ModelViewMatrix * v4;\n",
|
||||
"}\n"
|
||||
};
|
||||
@@ -85,7 +85,7 @@ const GLchar * EEGL_SHADER_POINT_SPRITE_VS[] = {
|
||||
"void main(void)\n",
|
||||
"{\n",
|
||||
" Color = dgl_Color;\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex.x, dgl_Vertex.y, 0.0, 1.0 );\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n",
|
||||
" gl_Position = dgl_ProjectionMatrix * dgl_ModelViewMatrix * v4;\n",
|
||||
"}\n"
|
||||
};
|
||||
@@ -101,11 +101,53 @@ const GLchar * EEGL_SHADER_POINT_SPRITE_FS[] = {
|
||||
"}\n"
|
||||
};
|
||||
|
||||
const GLchar * EEGL_SHADER_CLIP_VS[] = {
|
||||
"#version 150\n",
|
||||
"#extension GL_ARB_explicit_attrib_location : enable\n",
|
||||
"uniform mat4 dgl_ProjectionMatrix;\n",
|
||||
"uniform mat4 dgl_ModelViewMatrix;\n",
|
||||
"uniform vec4 dgl_ClipPlane[ 4 ];\n",
|
||||
"layout(location = 0) in vec2 dgl_Vertex;\n",
|
||||
"layout(location = 2) in vec4 dgl_Color;\n",
|
||||
"layout(location = 4) in vec2 dgl_TexCoord;\n",
|
||||
"invariant out vec4 Color;\n",
|
||||
"invariant out vec2 TexCoord;\n",
|
||||
"void main(void)\n",
|
||||
"{\n",
|
||||
" Color = dgl_Color;\n",
|
||||
" TexCoord = dgl_TexCoord;\n",
|
||||
" vec4 v4 = vec4( dgl_Vertex, 0.0, 1.0 );\n",
|
||||
" gl_Position = dgl_ProjectionMatrix * dgl_ModelViewMatrix * v4;\n",
|
||||
" gl_ClipDistance[0] = dot( v4, dgl_ClipPlane[0] * dgl_ModelViewMatrix );",
|
||||
" gl_ClipDistance[1] = dot( v4, dgl_ClipPlane[1] * dgl_ModelViewMatrix );",
|
||||
" gl_ClipDistance[2] = dot( v4, dgl_ClipPlane[2] * dgl_ModelViewMatrix );",
|
||||
" gl_ClipDistance[3] = dot( v4, dgl_ClipPlane[3] * dgl_ModelViewMatrix );",
|
||||
"}\n"
|
||||
};
|
||||
|
||||
const GLchar * EEGL_SHADER_CLIP_FS[] = {
|
||||
"#version 150\n",
|
||||
"uniform int TexActive = 1;\n",
|
||||
"invariant in vec4 Color;\n",
|
||||
"invariant in vec2 TexCoord;\n",
|
||||
"out vec4 dgl_FragColor;\n",
|
||||
"uniform sampler2D textureUnit0;\n",
|
||||
"void main(void)\n",
|
||||
"{\n",
|
||||
" if ( 1 == TexActive )\n",
|
||||
" dgl_FragColor = Color * texture2D( textureUnit0, TexCoord );\n",
|
||||
" else\n",
|
||||
" dgl_FragColor = Color;\n",
|
||||
"}\n"
|
||||
};
|
||||
|
||||
cRendererGL3::cRendererGL3() :
|
||||
mProjectionMatrix_id(0),
|
||||
mModelViewMatrix_id(0),
|
||||
mCurrentMode(0),
|
||||
mCurShader(NULL)
|
||||
mCurShader(NULL),
|
||||
mShaderPrev(NULL),
|
||||
mTexActive(1)
|
||||
{
|
||||
mProjectionMatrix.push ( glm::mat4( 1.0f ) ); // identity matrix
|
||||
mModelViewMatrix.push ( glm::mat4( 1.0f ) ); // identity matrix
|
||||
@@ -129,7 +171,7 @@ GLuint cRendererGL3::BaseShaderId() {
|
||||
return mCurShader->Handler();
|
||||
}
|
||||
|
||||
void cRendererGL3::SetShader( const EEGL_SHADERS_NUM& Shader ) {
|
||||
void cRendererGL3::SetShader( const EEGL_SHADERS& Shader ) {
|
||||
SetShader( mShaders[ Shader ] );
|
||||
}
|
||||
|
||||
@@ -142,14 +184,20 @@ void cRendererGL3::SetShader( cShaderProgram * Shader ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mShaders[ EEGL_SHADER_CLIP ] != mCurShader ) {
|
||||
mShaderPrev = mCurShader;
|
||||
}
|
||||
|
||||
mCurShader = Shader;
|
||||
mProjectionMatrix_id = mCurShader->UniformLocation( "dgl_ProjectionMatrix" );
|
||||
mModelViewMatrix_id = mCurShader->UniformLocation( "dgl_ModelViewMatrix" );
|
||||
|
||||
for ( Uint32 i = 0; i < EEGL_ARRAY_STATES_SIZE; i++ ) {
|
||||
for ( Uint32 i = 0; i < EEGL_ARRAY_STATES_COUNT; i++ ) {
|
||||
mStates[ i ] = mCurShader->AttributeLocation( EEGL_STATES_NAME[ i ] );
|
||||
}
|
||||
|
||||
mTexActiveLoc = mCurShader->UniformLocation( "TexActive" );
|
||||
|
||||
glUseProgram( mCurShader->Handler() );
|
||||
|
||||
GLenum CM = mCurrentMode;
|
||||
@@ -162,25 +210,40 @@ void cRendererGL3::SetShader( cShaderProgram * Shader ) {
|
||||
}
|
||||
|
||||
void cRendererGL3::Disable ( GLenum cap ) {
|
||||
cGL::Disable( cap );
|
||||
|
||||
if ( GL_TEXTURE_2D == cap ) {
|
||||
mCurShader->SetUniform( "TexActive", 0 );
|
||||
if ( glIsEnabled( cap ) ) {
|
||||
mTexActive = 0;
|
||||
mCurShader->SetUniform( mTexActiveLoc, mTexActive );
|
||||
|
||||
//DisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
//SetShader( EEGL_SHADER_BASE );
|
||||
/// Reset the vertex attrib to zero to avoid crashes on draw calls
|
||||
TexCoordPointer( 2, GL_FLOAT, 0, (const GLvoid*)NULL, 0 );
|
||||
}
|
||||
|
||||
/// Disabled shader changing because it seems to be slower than just passing a state flag
|
||||
/**
|
||||
DisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
SetShader( EEGL_SHADER_BASE );
|
||||
*/
|
||||
}
|
||||
|
||||
cGL::Disable( cap );
|
||||
}
|
||||
|
||||
void cRendererGL3::Enable( GLenum cap ) {
|
||||
cGL::Enable( cap );
|
||||
|
||||
if ( GL_TEXTURE_2D == cap ) {
|
||||
mCurShader->SetUniform( "TexActive", 1 );
|
||||
if ( !glIsEnabled( cap ) ) {
|
||||
mTexActive = 1;
|
||||
mCurShader->SetUniform( mTexActiveLoc, mTexActive );
|
||||
}
|
||||
|
||||
//EnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
//SetShader( EEGL_SHADER_BASE_TEX );
|
||||
/**
|
||||
TexCoordPointer( 2, GL_FLOAT, 0, (const GLvoid*)NULL, 0 );
|
||||
EnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
SetShader( EEGL_SHADER_BASE_TEX );
|
||||
*/
|
||||
}
|
||||
|
||||
cGL::Enable( cap );
|
||||
}
|
||||
|
||||
void cRendererGL3::Init() {
|
||||
@@ -189,9 +252,8 @@ void cRendererGL3::Init() {
|
||||
mShaders[ EEGL_SHADER_BASE ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_BASE_VS, sizeof(EEGL_SHADER_BASE_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_BASE_FS, sizeof(EEGL_SHADER_BASE_FS)/sizeof(const GLchar*), "EEGL_SHADER_BASE" ) );
|
||||
mShaders[ EEGL_SHADER_BASE_TEX ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_BASE_TEX_VS, sizeof(EEGL_SHADER_BASE_TEX_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_BASE_TEX_FS, sizeof(EEGL_SHADER_BASE_TEX_FS)/sizeof(const GLchar*), "EEGL_SHADER_BASE_TEX" ) );
|
||||
mShaders[ EEGL_SHADER_POINT_SPRITE ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_POINT_SPRITE_VS, sizeof(EEGL_SHADER_POINT_SPRITE_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_POINT_SPRITE_FS, sizeof(EEGL_SHADER_POINT_SPRITE_FS)/sizeof(const GLchar*), "EEGL_SHADER_POINT_SPRITE" ) );
|
||||
mShaders[ EEGL_SHADER_CLIP ] = eeNew( cShaderProgram, ( (const char**)EEGL_SHADER_CLIP_VS, sizeof(EEGL_SHADER_CLIP_VS)/sizeof(const GLchar*), (const char**)EEGL_SHADER_CLIP_FS, sizeof(EEGL_SHADER_CLIP_FS)/sizeof(const GLchar*), "EEGL_SHADER_CLIP" ) );
|
||||
|
||||
//SetShader( mShaders[ EEGL_SHADER_BASE ] );
|
||||
//SetShader( mShaders[ EEGL_SHADER_POINT_SPRITE ] );
|
||||
SetShader( mShaders[ EEGL_SHADER_BASE_TEX ] );
|
||||
|
||||
glGenVertexArrays( 1, &mVAO );
|
||||
@@ -199,7 +261,7 @@ void cRendererGL3::Init() {
|
||||
|
||||
memset( mVBO, 0, eeARRAY_SIZE( mVBO ) );
|
||||
|
||||
glGenBuffers( EEGL_ARRAY_STATES_SIZE, &mVBO[0] );
|
||||
glGenBuffers( EEGL_ARRAY_STATES_COUNT, &mVBO[0] );
|
||||
|
||||
//"in vec2 dgl_Vertex;",
|
||||
glBindBuffer(GL_ARRAY_BUFFER, mVBO[ EEGL_VERTEX_ARRAY ] );
|
||||
@@ -307,7 +369,6 @@ void cRendererGL3::VertexPointer ( GLint size, GLenum type, GLsizei stride, cons
|
||||
if ( -1 != index ) {
|
||||
glBindVertexArray( mVAO );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mVBO[ EEGL_VERTEX_ARRAY ] );
|
||||
//glBufferData( GL_ARRAY_BUFFER, allocate, pointer, GL_STREAM_DRAW );
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 0, allocate, pointer );
|
||||
|
||||
glVertexAttribPointer( index, size, type, GL_FALSE, stride, 0 );
|
||||
@@ -320,7 +381,6 @@ void cRendererGL3::ColorPointer ( GLint size, GLenum type, GLsizei stride, const
|
||||
if ( -1 != index ) {
|
||||
glBindVertexArray( mVAO );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mVBO[ EEGL_COLOR_ARRAY ] );
|
||||
//glBufferData( GL_ARRAY_BUFFER, allocate, pointer, GL_STREAM_DRAW );
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 0, allocate, pointer );
|
||||
|
||||
if ( type == GL_UNSIGNED_BYTE ) {
|
||||
@@ -337,7 +397,6 @@ void cRendererGL3::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, co
|
||||
if ( -1 != index ) {
|
||||
glBindVertexArray( mVAO );
|
||||
glBindBuffer( GL_ARRAY_BUFFER, mVBO[ EEGL_TEXTURE_COORD_ARRAY ] );
|
||||
//glBufferData( GL_ARRAY_BUFFER, allocate, pointer, GL_STREAM_DRAW );
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 0, allocate, pointer );
|
||||
|
||||
glVertexAttribPointer( index, size, type, GL_FALSE, stride, 0 );
|
||||
@@ -345,10 +404,49 @@ void cRendererGL3::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, co
|
||||
}
|
||||
|
||||
GLint cRendererGL3::GetStateIndex( const Uint32& State ) {
|
||||
eeASSERT( State < EEGL_ARRAY_STATES_SIZE );
|
||||
eeASSERT( State < EEGL_ARRAY_STATES_COUNT );
|
||||
return mStates[ State ];
|
||||
}
|
||||
|
||||
void cRendererGL3::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
|
||||
GLfloat tX = (GLfloat)x;
|
||||
GLfloat tY = (GLfloat)y;
|
||||
GLfloat tW = (GLfloat)Width;
|
||||
GLfloat tH = (GLfloat)Height;
|
||||
|
||||
GLfloat clip_left[] = { 1.0 , 0.0 , 0.0 , -tX };
|
||||
GLfloat clip_right[] = { -1.0 , 0.0 , 0.0 , tX + tW };
|
||||
GLfloat clip_top[] = { 0.0 , 1.0 , 0.0 , -tY };
|
||||
GLfloat clip_bottom[] = { 0.0 , -1.0 , 0.0 , tY + tH };
|
||||
|
||||
GLi->Enable(GL_CLIP_PLANE0);
|
||||
GLi->Enable(GL_CLIP_PLANE1);
|
||||
GLi->Enable(GL_CLIP_PLANE2);
|
||||
GLi->Enable(GL_CLIP_PLANE3);
|
||||
|
||||
SetShader( EEGL_SHADER_CLIP );
|
||||
|
||||
mCurShader->SetUniform( "TexActive", mTexActive );
|
||||
|
||||
glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[0]" ), 1, clip_left );
|
||||
glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[1]" ), 1, clip_right );
|
||||
glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[2]" ), 1, clip_top );
|
||||
glUniform4fv( glGetUniformLocation( mCurShader->Handler(), "dgl_ClipPlane[3]" ), 1, clip_bottom );
|
||||
}
|
||||
|
||||
void cRendererGL3::ClipPlaneDisable() {
|
||||
GLi->Disable(GL_CLIP_PLANE0);
|
||||
GLi->Disable(GL_CLIP_PLANE1);
|
||||
GLi->Disable(GL_CLIP_PLANE2);
|
||||
GLi->Disable(GL_CLIP_PLANE3);
|
||||
|
||||
SetShader( mShaderPrev );
|
||||
}
|
||||
|
||||
void cRendererGL3::ClientActiveTexture( GLenum texture ) {
|
||||
//! TODO: Implement multitexturing in GL3 renderer
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -64,13 +64,19 @@ class cRendererGL3 : public cGL {
|
||||
|
||||
void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate );
|
||||
|
||||
void ClientActiveTexture( GLenum texture );
|
||||
|
||||
GLuint BaseShaderId();
|
||||
|
||||
void SetShader( cShaderProgram * Shader );
|
||||
|
||||
void SetShader( const EEGL_SHADERS_NUM& Shader );
|
||||
void SetShader( const EEGL_SHADERS& Shader );
|
||||
|
||||
GLint GetStateIndex( const Uint32& State );
|
||||
|
||||
void ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height );
|
||||
|
||||
void ClipPlaneDisable();
|
||||
protected:
|
||||
std::stack<glm::mat4> mProjectionMatrix; // cpu-side
|
||||
GLint mProjectionMatrix_id; // cpu-side hook to shader uniform
|
||||
@@ -81,8 +87,11 @@ class cRendererGL3 : public cGL {
|
||||
cShaderProgram * mShaders[ EEGL_SHADERS_COUNT ];
|
||||
cShaderProgram * mCurShader;
|
||||
GLuint mVAO;
|
||||
GLuint mVBO[ EEGL_ARRAY_STATES_SIZE ];
|
||||
GLint mStates[ EEGL_ARRAY_STATES_SIZE ];
|
||||
GLuint mVBO[ EEGL_ARRAY_STATES_COUNT ];
|
||||
GLint mStates[ EEGL_ARRAY_STATES_COUNT ];
|
||||
cShaderProgram * mShaderPrev;
|
||||
Int32 mTexActive;
|
||||
GLint mTexActiveLoc;
|
||||
|
||||
void UpdateMatrix();
|
||||
};
|
||||
|
||||
@@ -24,9 +24,9 @@ class CP_API cPhysicsManager : public tSingleton<cPhysicsManager> {
|
||||
LineThickness( 1.5f )
|
||||
{}
|
||||
|
||||
int DrawHash;
|
||||
int DrawBBs;
|
||||
int DrawShapes;
|
||||
bool DrawHash;
|
||||
bool DrawBBs;
|
||||
bool DrawShapes;
|
||||
cpFloat CollisionPointSize;
|
||||
cpFloat BodyPointSize;
|
||||
cpFloat LineThickness;
|
||||
|
||||
@@ -1705,7 +1705,7 @@ void cEETest::Demo1Create() {
|
||||
Physics::cShape::ResetShapeIdCounter();
|
||||
|
||||
mSpace = Physics::cSpace::New();
|
||||
mSpace->Iterations( 30 );
|
||||
//mSpace->Iterations( 30 );
|
||||
mSpace->ResizeStaticHash( 40.f, 1000 );
|
||||
mSpace->ResizeActiveHash( 40.f, 1000 );
|
||||
mSpace->Gravity( cVectNew( 0, 100 ) );
|
||||
@@ -1889,11 +1889,13 @@ void cEETest::PhysicsCreate() {
|
||||
cPhysicsManager::CreateSingleton();
|
||||
cPhysicsManager::instance()->CollisionSlop( 0.2 );
|
||||
cPhysicsManager * PM = cPhysicsManager::instance();
|
||||
PM->GetDrawOptions()->DrawHash = 1;
|
||||
PM->GetDrawOptions()->DrawBBs = 1;
|
||||
PM->GetDrawOptions()->DrawShapes = 1;
|
||||
PM->GetDrawOptions()->BodyPointSize = 4;
|
||||
PM->GetDrawOptions()->LineThickness = 1;
|
||||
cPhysicsManager::cDrawSpaceOptions * DSO = PM->GetDrawOptions();
|
||||
|
||||
DSO->DrawHash = false;
|
||||
DSO->DrawBBs = false;
|
||||
DSO->DrawShapes = true;
|
||||
DSO->BodyPointSize = 4;
|
||||
DSO->LineThickness = 1;
|
||||
|
||||
mDemo.clear();
|
||||
|
||||
|
||||
@@ -279,9 +279,8 @@ void cEngine::Setup2D( const bool& KeepView ) {
|
||||
cTextureFactory::instance()->SetPreBlendFunc( ALPHA_BLENDONE ); // This is to fix a little bug on windows when the resolution change. I don't know why it happens, but this line fix it.
|
||||
cTextureFactory::instance()->SetPreBlendFunc( ALPHA_NORMAL );
|
||||
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
|
||||
if ( GLv_3 != GLi->Version() ) {
|
||||
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
glShadeModel( GL_SMOOTH );
|
||||
}
|
||||
|
||||
@@ -1066,34 +1065,13 @@ void cEngine::SetDefaultContext() {
|
||||
void cEngine::ClipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height ) {
|
||||
cGlobalBatchRenderer::instance()->Draw();
|
||||
|
||||
GLdouble tX = (GLdouble)x;
|
||||
GLdouble tY = (GLdouble)y;
|
||||
GLdouble tW = (GLdouble)Width;
|
||||
GLdouble tH = (GLdouble)Height;
|
||||
|
||||
GLdouble clip_left[] = { 1.0 , 0.0 , 0.0, -tX };
|
||||
GLdouble clip_right[] = { -1.0, 0.0 , 0.0, tX + tW };
|
||||
GLdouble clip_top[] = { 0.0 , 1.0 , 0.0, -tY };
|
||||
GLdouble clip_bottom[] = { 0.0 , -1.0 , 0.0, tY + tH };
|
||||
|
||||
GLi->Enable(GL_CLIP_PLANE0);
|
||||
GLi->Enable(GL_CLIP_PLANE1);
|
||||
GLi->Enable(GL_CLIP_PLANE2);
|
||||
GLi->Enable(GL_CLIP_PLANE3);
|
||||
|
||||
glClipPlane(GL_CLIP_PLANE0, clip_left);
|
||||
glClipPlane(GL_CLIP_PLANE1, clip_right);
|
||||
glClipPlane(GL_CLIP_PLANE2, clip_top);
|
||||
glClipPlane(GL_CLIP_PLANE3, clip_bottom);
|
||||
GLi->ClipPlaneEnable( x, y, Width, Height );
|
||||
}
|
||||
|
||||
void cEngine::ClipPlaneDisable() {
|
||||
cGlobalBatchRenderer::instance()->Draw();
|
||||
|
||||
GLi->Disable(GL_CLIP_PLANE0);
|
||||
GLi->Disable(GL_CLIP_PLANE1);
|
||||
GLi->Disable(GL_CLIP_PLANE2);
|
||||
GLi->Disable(GL_CLIP_PLANE3);
|
||||
GLi->ClipPlaneDisable();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user