EgtGraphics 1.5b4 :

- aggiunta gestione dello sfondo anche sfumato
- adattamenti per modifiche a ICMdParser.
This commit is contained in:
Dario Sassi
2014-02-25 16:40:18 +00:00
parent 73ee89f9c5
commit cae2cf6ab0
8 changed files with 145 additions and 33 deletions
BIN
View File
Binary file not shown.
+12
View File
@@ -95,6 +95,10 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<OpenMPSupport>true</OpenMPSupport>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsCpp</CompileAs>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -118,6 +122,8 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -144,6 +150,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OpenMPSupport>true</OpenMPSupport>
<CompileAs>CompileAsCpp</CompileAs>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -172,6 +181,8 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<MinimalRebuild>false</MinimalRebuild>
<OpenMPSupport>true</OpenMPSupport>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -188,6 +199,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\Include\EGkColor.h" />
<ClInclude Include="..\Include\EGkGdbIterator.h" />
<ClInclude Include="..\Include\EgkObjGraphics.h" />
<ClInclude Include="..\Include\EGkPolyLine.h" />
+3
View File
@@ -63,6 +63,9 @@
<ClInclude Include="SceExecutor.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="..\Include\EGkColor.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
+3 -2
View File
@@ -61,8 +61,8 @@ ObjNewGraphics::AddPolyLine( const PolyLine& PL)
glBufferSubData( GL_ARRAY_BUFFER, m_nCount * SIZEV3F, SIZEV3F, &v3V) ;
++ m_nCount ;
}
glVertexAttribPointer( (GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0) ;
glEnableVertexAttribArray( 0) ;
glVertexPointer( 3, GL_FLOAT, 0, ((void*)(0))) ;
glEnableClientState( GL_VERTEX_ARRAY) ;
glBindVertexArray( 0) ;
return true ;
@@ -82,6 +82,7 @@ ObjNewGraphics::Draw( void)
if ( m_nVaoId != 0) {
glBindVertexArray( m_nVaoId) ;
glDrawArrays( m_nMode, 0, m_nCount) ;
glBindVertexArray( 0) ;
}
return true ;
+19 -25
View File
@@ -42,13 +42,24 @@ SceExecutor::~SceExecutor( void)
//----------------------------------------------------------------------------
bool
SceExecutor::Init( IEGrScene* pScene)
SceExecutor::SetScene( IEGrScene* pScene)
{
m_pScene = pScene ;
return ( m_pScene != nullptr) ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::SetCmdParser( ICmdParser* pParser)
{
// imposto eventuale parser dipendente
if ( m_pOtherExec != nullptr)
m_pOtherExec->SetCmdParser( pParser) ;
return true ;
}
//----------------------------------------------------------------------------
bool
SceExecutor::AddExecutor( ICmdExecutor* pOtherExec)
@@ -61,24 +72,7 @@ SceExecutor::AddExecutor( ICmdExecutor* pOtherExec)
bool
SceExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
{
string sOut ;
STRVECTOR::const_iterator theConstIter ;
// output di debug
sOut = " " + sCmd1 ;
if ( ! sCmd2.empty())
sOut += "." + sCmd2 ;
sOut += "( " ;
for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; ++theConstIter) {
if ( theConstIter != vsParams.begin())
sOut += ", " ;
sOut += *theConstIter ;
}
sOut += ")" ;
LOG_DBG_INFO( GetEGrLogger(), sOut.c_str())
// verifico validita Scene
// verifico validità Scene
if ( m_pScene == nullptr) {
LOG_ERROR( GetEGrLogger(), "Error : null Scene.")
return false ;
@@ -137,15 +131,15 @@ SceExecutor::ExecuteRedraw( const string& sCmd2, const STRVECTOR& vsParams)
bool
SceExecutor::ExecuteZoom( const string& sCmd2, const STRVECTOR& vsParams)
{
const double COEFF_PLUS = 0.9 ;
const double COEFF_MINUS = 1 / COEFF_PLUS ;
const double COEFF_IN = 0.9 ;
const double COEFF_OUT = 1 / COEFF_IN ;
if ( sCmd2 == "ALL")
m_pScene->ZoomAll() ;
else if ( sCmd2 == "PLUS")
m_pScene->ZoomChange( COEFF_PLUS) ;
else if ( sCmd2 == "MINUS")
m_pScene->ZoomChange( COEFF_MINUS) ;
else if ( sCmd2 == "IN")
m_pScene->ZoomChange( COEFF_IN) ;
else if ( sCmd2 == "OUT")
m_pScene->ZoomChange( COEFF_OUT) ;
else if ( sCmd2 == "CHANGE") {
// 1 parametro : fattore di zoom
if ( vsParams.size() != 1)
+3 -2
View File
@@ -21,9 +21,10 @@
class SceExecutor : public ISceExecutor
{
public :
virtual bool Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) ;
virtual bool SetCmdParser( ICmdParser* pParser) ;
virtual bool AddExecutor( ICmdExecutor* pOtherExec) ;
virtual bool Init( IEGrScene* pScene) ;
virtual bool Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) ;
virtual bool SetScene( IEGrScene* pScene) ;
public :
SceExecutor( void) ;
+5
View File
@@ -35,6 +35,7 @@ class Scene : public IEGrScene
virtual bool RedrawWindow( void) ;
virtual bool SetExtension( const BBox3d& b3Ext) ;
virtual bool Reshape( int nW, int nH) ;
virtual bool SetBackground( Color BackTop, Color BackBottom) ;
virtual bool Prepare( void) ;
virtual bool Draw( void) ;
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) ;
@@ -73,6 +74,7 @@ class Scene : public IEGrScene
bool CalcDimViewFromExtView( void) ;
bool AdjustDimView( double dHalfWidth, double dHalfHeight) ;
bool CalcClippingPlanesFromExtView( void) ;
bool Background( void) ;
// Camera
bool VerifyCamera( void) ;
bool CalcDirUp( void) ;
@@ -90,6 +92,9 @@ class Scene : public IEGrScene
GLEWContext m_glewc ; // GLEW Context
bool m_bNewWay ; // flag che indica nuova modalità (OpenGL 3.0 in poi)
Color m_BackTop ; // colore di sfondo in alto
Color m_BackBottom ; // colore di sfondo in basso
Point3d m_ptCenter ; // centro verso cui è rivolta la camera
Vector3d m_vtDirCamera ; // versore direzione dal centro alla camera
double m_dDistCamera ; // distanza dal centro alla camera
+100 -4
View File
@@ -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) ;