EgtGraphics 1.5b4 :
- aggiunta gestione dello sfondo anche sfumato - adattamenti per modifiche a ICMdParser.
This commit is contained in:
+100
-4
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "Scene.h"
|
||||
#include "GraphObjs.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EgtILogger.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
@@ -467,14 +468,105 @@ Scene::Reshape( int nW, int nH)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::Prepare( void)
|
||||
Scene::SetBackground( Color BackTop, Color BackBottom)
|
||||
{
|
||||
m_BackTop = BackTop ;
|
||||
m_BackBottom = BackBottom ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::Background( void)
|
||||
{
|
||||
// imposto il rendering corrente
|
||||
if ( ! MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// imposto il colore dello sfondo
|
||||
glClearColor( 0.1f, 0.1f, 0.5f, 0.0f) ;
|
||||
glClearColor( m_BackTop.GetRed(), m_BackTop.GetGreen(), m_BackTop.GetBlue(), m_BackTop.GetAlpha()) ;
|
||||
|
||||
// cancello
|
||||
glClear( GL_COLOR_BUFFER_BIT) ;
|
||||
|
||||
// se lo sfondo ha un colore uniforme, ho finito
|
||||
if ( m_BackTop == m_BackBottom)
|
||||
return true ;
|
||||
|
||||
// rendo neutre matrici di proiezione e di modello/vista
|
||||
glMatrixMode( GL_PROJECTION) ;
|
||||
glLoadIdentity() ;
|
||||
glMatrixMode( GL_MODELVIEW) ;
|
||||
glLoadIdentity() ;
|
||||
|
||||
// disegno lo sfondo con due colori
|
||||
if ( ! m_bNewWay) {
|
||||
glBegin( GL_TRIANGLE_STRIP) ;
|
||||
glColor3f( m_BackBottom.GetRed(), m_BackBottom.GetGreen(), m_BackBottom.GetBlue()) ;
|
||||
glVertex3f( -1, -1, 0.5) ;
|
||||
glVertex3f( 1, -1, 0.5) ;
|
||||
glColor3f( m_BackTop.GetRed(), m_BackTop.GetGreen(), m_BackTop.GetBlue()) ;
|
||||
glVertex3f( -1, 1, 0.5) ;
|
||||
glVertex3f( 1, 1, 0.5) ;
|
||||
glEnd() ;
|
||||
}
|
||||
else {
|
||||
unsigned int nVaoId ;
|
||||
unsigned int nVboId ;
|
||||
// definizione
|
||||
glGenVertexArrays( 1, &nVaoId) ;
|
||||
if ( nVaoId == 0)
|
||||
return false ;
|
||||
glBindVertexArray( nVaoId) ;
|
||||
glGenBuffers( 1, &nVboId) ;
|
||||
glBindBuffer( GL_ARRAY_BUFFER, nVboId) ;
|
||||
glBufferData( GL_ARRAY_BUFFER, 8 * SIZEV3F, NULL, GL_STATIC_DRAW) ;
|
||||
glVertexPointer( 3, GL_FLOAT, 2 * SIZEV3F, ((void*)(0))) ;
|
||||
glEnableClientState( GL_VERTEX_ARRAY) ;
|
||||
glColorPointer( 3, GL_FLOAT, 2 * SIZEV3F, ((void*)(1 * SIZEV3F))) ;
|
||||
glEnableClientState( GL_COLOR_ARRAY) ;
|
||||
Vert3f v3V ;
|
||||
Vert3f v3C ;
|
||||
// bottom left
|
||||
v3V.Set( -1, -1, 0.5) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 0 * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
v3C.Set( m_BackBottom.GetRed(), m_BackBottom.GetGreen(), m_BackBottom.GetBlue()) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 1 * SIZEV3F, SIZEV3F, &v3C) ;
|
||||
// bottom right
|
||||
v3V.Set( 1, -1, 0.5) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 2 * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
// v3C constant
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 3 * SIZEV3F, SIZEV3F, &v3C) ;
|
||||
// top left
|
||||
v3V.Set( -1, 1, 0.5) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 4 * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
v3C.Set( m_BackTop.GetRed(), m_BackTop.GetGreen(), m_BackTop.GetBlue()) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 5 * SIZEV3F, SIZEV3F, &v3C) ;
|
||||
// top right
|
||||
v3V.Set( 1, 1, 0.5) ;
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 6 * SIZEV3F, SIZEV3F, &v3V) ;
|
||||
// v3C constant
|
||||
glBufferSubData( GL_ARRAY_BUFFER, 7 * SIZEV3F, SIZEV3F, &v3C) ;
|
||||
// disegno
|
||||
glDrawArrays( GL_TRIANGLE_STRIP, 0, 4) ;
|
||||
// cancellazione
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
|
||||
glDeleteBuffers( 1, &nVboId) ;
|
||||
glBindVertexArray( 0) ;
|
||||
glDeleteVertexArrays( 1, &nVaoId) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Scene::Prepare( void)
|
||||
{
|
||||
// imposto il rendering corrente
|
||||
if ( ! MakeCurrent())
|
||||
return false ;
|
||||
|
||||
// eventuale ricalcolo parametri di vista
|
||||
CalcDirUp() ;
|
||||
@@ -506,12 +598,16 @@ Scene::Prepare( void)
|
||||
bool
|
||||
Scene::Draw( void)
|
||||
{
|
||||
// sistemo lo sfondo
|
||||
if ( ! Background())
|
||||
return false ;
|
||||
|
||||
// imposto
|
||||
if ( ! Prepare())
|
||||
return false ;
|
||||
|
||||
// cancello
|
||||
glClear( GL_COLOR_BUFFER_BIT) ;
|
||||
// colore di default
|
||||
glColor4f( 1, 1, 1, 1) ;
|
||||
|
||||
// disegno
|
||||
DrawGroup( GDB_ID_ROOT) ;
|
||||
|
||||
Reference in New Issue
Block a user