diff --git a/EGrDllMain.cpp b/EGrDllMain.cpp new file mode 100644 index 0000000..2fd70c5 --- /dev/null +++ b/EGrDllMain.cpp @@ -0,0 +1,67 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : EGrDllMain.cpp Data : 13.02.14 Versione : 1.5b1 +// Contenuto : Inizializzazione della DLL. +// +// +// +// Modifiche : 13.02.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include <\EgtDev\Include\EGrDllMain.h> +#include <\EgtDev\Include\EGnGetModuleVer.h> +#include <\EgtDev\Include\EgtTrace.h> + +//--------------------------- Costanti ---------------------------------------- +#if defined( _WIN64) + #if defined( _DEBUG) + const char* EGR_STR = "EgtGraphicsD64.dll ver. " ; + #else + const char* EGR_STR = "EgtGraphicsR64.dll ver. " ; + #endif +#elif defined( _WIN32) + #if defined( _DEBUG) + const char* EGR_STR = "EgtGraphicsD32.dll ver. " ; + #else + const char* EGR_STR = "EgtGraphicsR32.dll ver. " ; + #endif +#endif +const int STR_DIM = 40 ; + +//----------------------------------------------------------------------------- +static HINSTANCE s_hModule = NULL ; +static char s_szEGrNameVer[STR_DIM] ; + +//----------------------------------------------------------------------------- +BOOL APIENTRY +DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) +{ + + if ( dwReason == DLL_PROCESS_ATTACH) { + s_hModule = hModule ; + EGT_TRACE( "EgtGraphics.dll Initializing!\n") ; + } + else if ( dwReason == DLL_PROCESS_DETACH) { + s_hModule = NULL ; + EGT_TRACE( "EgtGraphics.dll Terminating!\n") ; + } + + return 1 ; +} + +//----------------------------------------------------------------------------- +const char* +GetEGrVersion( void) +{ + std::string sVer ; + + GetModuleVersion( s_hModule, sVer) ; + sprintf_s( s_szEGrNameVer, STR_DIM, "%s%s", EGR_STR, sVer.c_str()) ; + + return s_szEGrNameVer ; +} diff --git a/EGrGraphObjs.h b/EGrGraphObjs.h new file mode 100644 index 0000000..01f1d90 --- /dev/null +++ b/EGrGraphObjs.h @@ -0,0 +1,42 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2014 +//---------------------------------------------------------------------------- +// File : EGrGraphObjs.h Data : 06.02.14 Versione : 1.5b4 +// Contenuto : Oggetti grafici e loro raccolte. +// +// +// +// Modifiche : 06.02.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include +#include + +//---------------------------------------------------------------------------- +// Definizione di Vert3f +class Vert3f { + public : + Vert3f( double dX, double dY, double dZ) : x( (float)dX), y( (float)dY), z( (float)dZ) {} + Vert3f( void) : x( 0), y( 0), z( 0) {} + void Set( double dX, double dY, double dZ) { x = (float)dX ; y = (float)dY ; z = (float)dZ ;} + const Vert3f& operator =( const Vert3f& ptSrc) + { if ( &ptSrc != this) { + x = ptSrc.x , y = ptSrc.y , z = ptSrc.z ; } + return *this ; } + + public : + float x ; + float y ; + float z ; +} ; +const size_t SIZEV3F = sizeof( Vert3f) ; + + +//---------------------------------------------------------------------------- +// Raccolte di Vert3f +typedef std::vector V3FVECTOR ; // vettore di vertici +typedef std::list V3FLIST ; // lista di vertici diff --git a/EgtGraphics.rc b/EgtGraphics.rc new file mode 100644 index 0000000..791695f Binary files /dev/null and b/EgtGraphics.rc differ diff --git a/EgtGraphics.sln b/EgtGraphics.sln new file mode 100644 index 0000000..3efddda --- /dev/null +++ b/EgtGraphics.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtGraphics", "EgtGraphics.vcxproj", "{4EC970B1-B4D9-4088-8A31-B462CF72116E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Debug|Win32.ActiveCfg = Debug|Win32 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Debug|Win32.Build.0 = Debug|Win32 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Debug|x64.ActiveCfg = Debug|x64 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Debug|x64.Build.0 = Debug|x64 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Release|Win32.ActiveCfg = Release|Win32 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Release|Win32.Build.0 = Release|Win32 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Release|x64.ActiveCfg = Release|x64 + {4EC970B1-B4D9-4088-8A31-B462CF72116E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + VisualSVNWorkingCopyRoot = . + EndGlobalSection +EndGlobal diff --git a/EgtGraphics.vcxproj b/EgtGraphics.vcxproj new file mode 100644 index 0000000..7817673 --- /dev/null +++ b/EgtGraphics.vcxproj @@ -0,0 +1,211 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4EC970B1-B4D9-4088-8A31-B462CF72116E} + Win32Proj + EgtGraphics + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)D$(PlatformArchitecture) + + + true + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)D$(PlatformArchitecture) + + + false + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)R$(PlatformArchitecture) + + + false + $(SolutionDir)$(Configuration)$(PlatformArchitecture)\ + $(Configuration)$(PlatformArchitecture)\ + $(ProjectName)R$(PlatformArchitecture) + + + + Use + Level3 + Disabled + WIN32;I_AM_EGR;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + false + + + Windows + true + + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll32 + + + _UNICODE;UNICODE;_DEB32;%(PreprocessorDefinitions) + + + + + Use + Level3 + Disabled + WIN32;I_AM_EGR;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + false + + + Windows + true + + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll64 + + + _UNICODE;UNICODE;_DEB32;%(PreprocessorDefinitions) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;I_AM_EGR;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + Speed + AnySuitable + + + Windows + true + true + true + + + copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll32 + + + _UNICODE;UNICODE;NDEB32;%(PreprocessorDefinitions) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;I_AM_EGR;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + Speed + AnySuitable + false + + + Windows + true + true + true + + + copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ +copy $(TargetPath) \EgtProg\Dll64 + + + _UNICODE;UNICODE;NDEB32;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/EgtGraphics.vcxproj.filters b/EgtGraphics.vcxproj.filters new file mode 100644 index 0000000..d1c022d --- /dev/null +++ b/EgtGraphics.vcxproj.filters @@ -0,0 +1,56 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + + + File di origine + + + File di origine + + + File di origine + + + File di origine + + + File di origine + + + + + File di risorse + + + \ No newline at end of file diff --git a/Scene.h b/Scene.h new file mode 100644 index 0000000..1d1cd67 --- /dev/null +++ b/Scene.h @@ -0,0 +1,104 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2014 +//---------------------------------------------------------------------------- +// File : EGrScene.h Data : 03.02.14 Versione : 1.5b1 +// Contenuto : Dichiarazione della classe gestione scena. +// +// +// +// Modifiche : 29.01.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +//---------------------------------------------------------------------------- +#include "/EgtDev/Include/EGrScene.h" +#include "EGrGraphObjs.h" +#define GLEW_MX +#include "/EgtDev/Extern/GLEW/Include/glew.h" +#include "/EgtDev/Extern/GLEW/Include/wglew.h" + +//---------------------------------------------------------------------------- +class Scene : public IEGrScene +{ + public : + // Basic + virtual ~Scene( void) ; + virtual bool Init( IGeomDB* pGeomDB, ILogger* pLogger) ; + virtual bool CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits) ; + virtual bool IsValid( void) + { return ( m_hDC != nullptr && m_hRC != nullptr) ; } + virtual std::string GetOpenGLInfo( void) ; + virtual std::string GetGLSLInfo( void) ; + virtual std::string GetPixelFormatInfo( void) ; + virtual bool Reshape( int nW, int nH) ; + virtual bool SetExtension( const BBox3d& b3Ext) ; + virtual bool Prepare( void) ; + virtual bool Draw( void) ; + virtual bool Project( const Point3d& ptWorld, Point3d& ptView) ; + virtual bool UnProject( const Point3d& ptView, Point3d& ptWorld) ; + virtual void Destroy( void) ; + // Camera + virtual bool SetCenter( const Point3d& ptCenter) ; + virtual bool SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) ; + virtual bool SetCamera( int nDir, double dDist = 0) ; + virtual const Point3d& GetCenter( void) + { return m_ptCenter ; } + virtual Point3d GetProjectedCenter( void) ; + virtual void GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist = nullptr) ; + virtual int GetCameraDir( void) ; + virtual bool PanCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) ; + virtual bool RotateCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) ; + virtual bool ZoomAll( void) ; + virtual bool ZoomChange( double dCoeff) ; + virtual bool ZoomOnPoint( const Point3d& ptWin, double dCoeff) ; + + public : + // Basic + Scene( void) ; + + private : + // Basic + int ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBits) ; + bool MakeCurrent( void) ; + GLEWContext* glewGetContext( void) + { return &m_glewc ; } + WGLEWContext* wglewGetContext( void) + { return &m_wglewc ; } + bool CalcExtView( void) ; + bool CalcDimViewFromExtView( void) ; + bool AdjustDimView( double dHalfWidth, double dHalfHeight) ; + bool CalcClippingPlanesFromExtView( void) ; + // Camera + bool CalcDirUp( void) ; + // Geometry + bool DrawGroup( int nId) ; + + private : + IGeomDB* m_pGeomDB ; + ILogger* m_pLogger ; + + HDC m_hDC ; // Device Context + HGLRC m_hRC ; // OpenGL Rendering Context + WGLEWContext m_wglewc ; // WGLEW Context + GLEWContext m_glewc ; // GLEW Context + bool m_bNewWay ; // flag che indica nuova modalità (OpenGL 3.0 in poi) + + 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 + Vector3d m_vtUp ; // versore direzione Su della camera + bool m_bUpOk ; // flag per stato aggiornamento di Up + int m_nViewportW ; // larghezza della finestra + int m_nViewportH ; // altezza della finestra + + BBox3d m_b3ExtWorld ; // estensione della geometria + BBox3d m_b3ExtView ; // estensione nel riferimento di vista + bool m_bExtViewOk ; // flag per stato aggiornamento di EView + double m_dHalfWidth ; + double m_dHalfHeight ; + double m_dZNear ; + double m_dZFar ; +} ; diff --git a/SceneBasic.cpp b/SceneBasic.cpp new file mode 100644 index 0000000..1303389 --- /dev/null +++ b/SceneBasic.cpp @@ -0,0 +1,589 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2014 +//---------------------------------------------------------------------------- +// File : Scene.cpp Data : 03.02.14 Versione : 1.5b1 +// Contenuto : Implementazione della classe gestione scena. +// +// +// +// Modifiche : 29.01.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Scene.h" +#include "/EgtDev/Include/EgtILogger.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGkFrame3d.h" +#include "/EgtDev/Include/EGkGdbConst.h" + +using namespace std ; + +//--------------------------- Constants -------------------------------------- +static const double MIN_EXTENSION = 50 ; + + +//---------------------------------------------------------------------------- +IEGrScene* +CreateEGrScene( void) +{ + return static_cast ( new(nothrow) Scene) ; +} + +//---------------------------------------------------------------------------- +Scene::Scene( void) +{ + m_pGeomDB = nullptr ; + m_pLogger = nullptr ; + // Context data + m_hDC = nullptr ; + m_hRC = nullptr ; + memset( &m_wglewc, 0, sizeof( WGLEWContext)) ; + memset( &m_glewc, 0, sizeof( GLEWContext)) ; + m_bNewWay = false ; + // Geom data + SetExtension( BBox3d( -MIN_EXTENSION, -MIN_EXTENSION, -MIN_EXTENSION, + MIN_EXTENSION, MIN_EXTENSION, MIN_EXTENSION)) ; + // Viewport + m_nViewportW = 0 ; + m_nViewportH = 0 ; + // View data + m_ptCenter = ORIG ; + SetCamera( 0, 0, 0) ; +} + +//---------------------------------------------------------------------------- +Scene::~Scene( void) +{ +} + +//---------------------------------------------------------------------------- +bool +Scene::Init( IGeomDB* pGeomDB, ILogger* pLogger) +{ + m_pGeomDB = pGeomDB ; + m_pLogger = pLogger ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::CreateContext( HDC hDC, int nDriver, bool b2Buff, int nColorBits, int nDepthBits) +{ + // verifico validità Device Context + if ( hDC == nullptr) + return false ; + m_hDC = hDC ; + + // riporto nei limiti il tipo di driver + if ( nDriver < OD_SOFT) + nDriver = OD_SOFT ; + else if ( nDriver > OD_NEW) + nDriver = OD_NEW ; + + // assegno formato pixel + PIXELFORMATDESCRIPTOR pfd ; + memset( &pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)) ; + pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR) ; + pfd.nVersion = 1 ; + pfd.dwFlags = ( b2Buff ? PFD_DOUBLEBUFFER : 0) | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW ; + pfd.iPixelType = PFD_TYPE_RGBA ; + pfd.cColorBits = nColorBits ; + pfd.cDepthBits = nDepthBits ; + pfd.iLayerType = PFD_MAIN_PLANE ; + + int nPixelFormat = ChoosePixelFormat( m_hDC, &pfd) ; + if ( nPixelFormat == 0) + return false ; + if ( nDriver == OD_SOFT) { + int nPixFormGen = ChooseGenPixelFormat( nPixelFormat, b2Buff, nColorBits, nDepthBits) ; + if ( nPixFormGen != 0) + nPixelFormat = nPixFormGen ; + } + if ( ! SetPixelFormat( m_hDC, nPixelFormat, &pfd)) + return false ; + + HGLRC tempContext = wglCreateContext( m_hDC) ; + wglMakeCurrent( m_hDC, tempContext) ; + + GLenum WglewInitResult ; + WglewInitResult = wglewInit() ; + + if ( WglewInitResult != GLEW_OK) + LOG_INFO( m_pLogger, "WGLEW is not initialized !") + + int attribs[10] ; + if ( nDriver == OD_SOFT) { + attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB ; + attribs[1] = 1 ; + attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB ; + attribs[3] = 1 ; + attribs[4] = 0 ; + } + else if ( nDriver == OD_OLD) { + attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB ; + attribs[1] = 2 ; + attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB ; + attribs[3] = 0 ; + attribs[4] = 0 ; + } + else { + attribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB ; + attribs[1] = 3 ; + attribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB ; + attribs[3] = 0 ; + attribs[4] = WGL_CONTEXT_PROFILE_MASK_ARB ; + attribs[5] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB ; + attribs[6] = 0 ; + } + + if ( wglewIsSupported( "WGL_ARB_create_context") == 1) { + m_hRC = wglCreateContextAttribsARB( m_hDC, 0, attribs) ; + wglMakeCurrent( m_hDC, NULL) ; + wglDeleteContext( tempContext) ; + wglMakeCurrent( m_hDC, m_hRC) ; + } + else { + //It's not possible to make a GL 3.x context. Use the old style context (GL 2.1 and before) + m_hRC = tempContext ; + LOG_INFO( m_pLogger, "WGL_ARB_create_context missing !") + } + + // verifico validità Rendering Context + if ( m_hRC == nullptr) + return false ; + + GLenum GlewInitResult ; + glewExperimental = GL_TRUE ; + GlewInitResult = glewInit() ; + + if ( GlewInitResult != GLEW_OK) + LOG_INFO( m_pLogger, "GLEW is not initialized !") + + // verifico se posso lavorare in modalità nuova + m_bNewWay = ( nDriver == OD_NEW && glewIsSupported( "GL_VERSION_3_0") == 1) ; + if ( ! m_bNewWay) + LOG_INFO( m_pLogger, "OpenGL old way rendering !") + + // reset stato di errore di OpenGL + glGetError() ; + + return true ; +} + +//---------------------------------------------------------------------------- +int +Scene::ChooseGenPixelFormat( int nPfd, bool b2Buff, int nColorBits, int nDepthBits) +{ + PIXELFORMATDESCRIPTOR pfdR ; + + + // verifica del pixel format proposto + int nTotPfd = DescribePixelFormat( m_hDC, nPfd, sizeof(PIXELFORMATDESCRIPTOR), &pfdR) ; + if ( pfdR.dwFlags & PFD_GENERIC_FORMAT && + ! ( pfdR.dwFlags & PFD_GENERIC_ACCELERATED)) + return nPfd ; + + // eventuale ricerca di un pixel format soddisfacente + int nIOpt = 0 ; + int nErrOpt = 1000 ; + for ( int nI = 1 ; nI <= nTotPfd ; nI ++) { + DescribePixelFormat( m_hDC, nI, sizeof(PIXELFORMATDESCRIPTOR), &pfdR) ; + if ( pfdR.dwFlags & PFD_GENERIC_FORMAT && + ! (pfdR.dwFlags & PFD_GENERIC_ACCELERATED) && + ( ! b2Buff || pfdR.dwFlags & PFD_DOUBLEBUFFER)) { + int nErr = abs( nColorBits - pfdR.cColorBits) + + abs( nDepthBits - pfdR.cDepthBits) ; + if ( nErr < nErrOpt) { + nErrOpt = nErr ; + nIOpt = nI ; + } + } + } + + return nIOpt ; +} + +//---------------------------------------------------------------------------- +bool +Scene::MakeCurrent( void) +{ + // se RC della scena non è definito, errore + if ( m_hRC == nullptr) + return false ; + + // se RC della scena non è quello corrente, lo imposto + HGLRC hRC = wglGetCurrentContext() ; + if ( m_hRC != hRC) + return ( wglMakeCurrent( m_hDC, m_hRC) != 0) ; + + return true ; +} + +//---------------------------------------------------------------------------- +string +Scene::GetOpenGLInfo( void) +{ + string sInfo = "OpenGL " ; + + if ( MakeCurrent()) { + const char* p ; + if ( ( p = reinterpret_cast ( glGetString( GL_VERSION))) != nullptr) + sInfo += p ; + sInfo += " " ; + if ( ( p = reinterpret_cast ( glGetString( GL_VENDOR))) != nullptr) + sInfo += p ; + sInfo += " " ; + if ( ( p = reinterpret_cast ( glGetString( GL_RENDERER))) != nullptr) + sInfo += p ; + } + else + sInfo += "ERROR" ; + + // reset stato di errore di OpenGL + glGetError() ; + + return sInfo ; +} + +//---------------------------------------------------------------------------- +string +Scene::GetGLSLInfo( void) +{ + string sInfo = "GLSL " ; + + if ( MakeCurrent()) { + const char* p ; + if ( ( p = reinterpret_cast ( glGetString( GL_SHADING_LANGUAGE_VERSION))) != nullptr) + sInfo += p ; + else + sInfo += "NONE" ; + } + else + sInfo += "ERROR" ; + + // reset stato di errore di OpenGL + glGetError() ; + + return sInfo ; +} + +//---------------------------------------------------------------------------- +string +Scene::GetPixelFormatInfo( void) +{ + string sInfo = "PixFmt " ; + + if ( MakeCurrent()) { + int nPixFmt ; + PIXELFORMATDESCRIPTOR Pfd ; + if ( ( nPixFmt = GetPixelFormat( m_hDC)) > 0 && + DescribePixelFormat( m_hDC, nPixFmt, sizeof(PIXELFORMATDESCRIPTOR), &Pfd) > 0) { + // indice + sInfo += ToString( nPixFmt) ; + // tipo di driver + if ( ! ( Pfd.dwFlags & PFD_GENERIC_FORMAT)) + sInfo += " ICD" ; + else if ( Pfd.dwFlags & PFD_GENERIC_ACCELERATED) + sInfo += " MCD" ; + else + sInfo += " GEN" ; + // singolo o doppio buffer + sInfo += ( ( Pfd.dwFlags & PFD_DOUBLEBUFFER) ? " BUFF2" : " BUFF1") ; + // RGBA o COLORINDEX + sInfo += ( ( Pfd.iPixelType == PFD_TYPE_RGBA) ? " RGBA" : " CI") ; + // color bits + sInfo += ToString( Pfd.cColorBits) ; + // depth bits + sInfo += " Z" + ToString( Pfd.cDepthBits) ; + } + else + sInfo = "NO DESCRIBE" ; + } + else + sInfo += "ERROR" ; + + // reset stato di errore di OpenGL + glGetError() ; + + return sInfo ; +} + +//---------------------------------------------------------------------------- +bool +Scene::SetExtension( const BBox3d& b3Ext) +{ + if ( b3Ext.IsEmpty()) + return false ; + + m_b3ExtWorld = b3Ext ; + m_bExtViewOk = false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::CalcExtView( void) +{ + // verifico se il calcolo è necessario + if ( m_bExtViewOk && m_bUpOk) + return true ; + // calcolo direzione camera Up + if ( ! CalcDirUp()) + return false ; + // calcolo il riferimento di vista + Frame3d frView ; + Vector3d vtZ = m_vtDirCamera ; + Vector3d vtY = m_vtUp ; + Vector3d vtX = vtY ^ vtZ ; + if ( ! frView.Set( m_ptCenter + m_dDistCamera * vtZ, vtX, vtY, vtZ)) + return false ; + // calcolo l'estensione nel riferimento di vista + m_b3ExtView = m_b3ExtWorld ; + m_b3ExtView.ToLoc( frView) ; + m_bExtViewOk = true ; + return m_bExtViewOk ; +} + +//---------------------------------------------------------------------------- +bool +Scene::CalcDimViewFromExtView( void) +{ + // calcolo estensione nel riferimento di vista + if ( ! CalcExtView()) + return false ; + + // recupero gli ingombri + Point3d ptMin ; + Point3d ptMax ; + if ( ! m_b3ExtView.GetMinMax( ptMin, ptMax)) + return false ; + + // ricavo le dimensioni + const double COEFF = 1.05 ; + double dHalfWidth = COEFF * max( fabs( ptMin.x), fabs( ptMax.x)) ; + double dHalfHeight = COEFF * max( fabs( ptMin.y), fabs( ptMax.y)) ; + + // adatto le dimensioni a quelle della vista + return AdjustDimView( dHalfWidth, dHalfHeight) ; +} + +//---------------------------------------------------------------------------- +bool +Scene::AdjustDimView( double dHalfWidth, double dHalfHeight) +{ + // se non assegnate, recupero dimensioni vista + if ( m_nViewportW == 0) { + HWND hWnd = ::WindowFromDC( m_hDC) ; + RECT rect ; + if ( ! ::GetClientRect( hWnd, &rect)) + return false ; + m_nViewportW = rect.right ; + m_nViewportH = rect.bottom ; + // aggiorno la vista + glViewport( 0, 0, m_nViewportW, m_nViewportH) ; + // verifico presenza errori + GLenum nErr = glGetError() ; + if ( nErr != GL_NO_ERROR) { + string sOut = "First glViewport OpenGL error " + ToString( (int)nErr) ; + LOG_INFO( m_pLogger, sOut.c_str()) + } + } + + // adatto il rapporto tra le dimensioni calcolate a quello delle dimensioni della vista + double dAspect = m_nViewportH / ( double) m_nViewportW ; + if ( dAspect * dHalfWidth > dHalfHeight) { + m_dHalfWidth = dHalfWidth ; + m_dHalfHeight = dAspect * dHalfWidth ; + } + else { + m_dHalfWidth = dHalfHeight / dAspect ; + m_dHalfHeight = dHalfHeight ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::CalcClippingPlanesFromExtView( void) +{ + // calcolo estensione nel riferimento di vista + if ( ! CalcExtView()) + return false ; + + // recupero gli ingombri + Point3d ptCenter ; + Vector3d vtExtent ; + if ( ! m_b3ExtView.GetCenterExtent( ptCenter, vtExtent)) + return false ; + // ricavo la posizione dei piani di clipping sull'asse Z di vista + const double EXP_COEFF = 1.05 ; + double dExtent = __max( ( EXP_COEFF * vtExtent.z), MIN_EXTENSION) ; + m_dZNear = - ( ptCenter.z + dExtent) ; + m_dZFar = - ( ptCenter.z - dExtent) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::Reshape( int nW, int nH) +{ + if ( ! MakeCurrent()) + return false ; + + // assegno le dimensioni della vista + m_nViewportW = nW ; + m_nViewportH = nH ; + + // aggiorno la vista + glViewport( 0, 0, m_nViewportW, m_nViewportH) ; + + // verifico presenza errori + GLenum nErr = glGetError() ; + if ( nErr != GL_NO_ERROR) { + string sOut = "Reshape OpenGL error " + ToString( (int)nErr) ; + LOG_INFO( m_pLogger, sOut.c_str()) + } + + // aggiorno + AdjustDimView( m_dHalfWidth, m_dHalfHeight) ; + + // ridisegno + return Draw() ; +} + +//---------------------------------------------------------------------------- +bool +Scene::Prepare( void) +{ + // imposto il rendering corrente + if ( ! MakeCurrent()) + return false ; + + // imposto il colore dello sfondo + glClearColor( 0.1f, 0.1f, 0.5f, 0.0f) ; + + // eventuale ricalcolo parametri di vista + CalcDirUp() ; + + // imposto matrice di proiezione + glMatrixMode( GL_PROJECTION) ; + glLoadIdentity() ; + glOrtho( - m_dHalfWidth, m_dHalfWidth, - m_dHalfHeight, m_dHalfHeight, m_dZNear, m_dZFar) ; + + // imposto matrice modello/vista + glMatrixMode( GL_MODELVIEW) ; + glLoadIdentity() ; + Point3d ptCamera = m_ptCenter + m_dDistCamera * m_vtDirCamera ; + gluLookAt( ptCamera.x, ptCamera.y, ptCamera.z, + m_ptCenter.x, m_ptCenter.y, m_ptCenter.z, + m_vtUp.x, m_vtUp.y, m_vtUp.z) ; + + // verifico presenza errori + GLenum nErr = glGetError() ; + if ( nErr != GL_NO_ERROR) { + string sOut = "Prepare OpenGL error " + ToString( (int)nErr) ; + LOG_INFO( m_pLogger, sOut.c_str()) + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::Draw( void) +{ + // provvisorio + SetExtension( BBox3d( -1000, -1000, -1000, 1000, 1000, 1000)) ; + + // imposto + if ( ! Prepare()) + return false ; + + // cancello + glClear( GL_COLOR_BUFFER_BIT) ; + + // disegno + DrawGroup( GDB_ID_ROOT) ; + + // aggiorno + glFlush() ; + + // verifico presenza errori + GLenum nErr = glGetError() ; + if ( nErr != GL_NO_ERROR) { + string sOut = "Draw OpenGL error " + ToString( (int)nErr) ; + LOG_INFO( m_pLogger, sOut.c_str()) + } + + // scambio i buffer back e front ( eseguita solo se previsti) + if ( ! SwapBuffers( m_hDC)) + LOG_INFO( m_pLogger, "Draw SwapBuffers error") + + return true ; +} + +/*------------------------------------------------------------------------------------------*/ +bool +Scene::Project( const Point3d& ptWorld, Point3d& ptView) +{ + if ( ! MakeCurrent()) + return false ; + + // recupero le matrici + GLdouble ModelView[ 16] ; + glGetDoublev( GL_MODELVIEW_MATRIX, ModelView) ; + GLdouble Projection[ 16] ; + glGetDoublev( GL_PROJECTION_MATRIX, Projection) ; + GLint Viewport[ 4] ; + glGetIntegerv( GL_VIEWPORT, Viewport) ; + + // eseguo la proiezione + // l'asse y della vista OpenGL va in alto con l'origine in basso, + // quello di Windows va in basso con l'origine in alto + int nRes =gluProject( ptWorld.x, ptWorld.y, ptWorld.z, + ModelView, Projection, Viewport, + &ptView.x, &ptView.y, &ptView.z) ; + ptView.y = (double) Viewport[3] - ptView.y ; + + return ( nRes == GL_TRUE) ; +} + +/*------------------------------------------------------------------------------------------*/ +bool +Scene::UnProject( const Point3d& ptView, Point3d& ptWorld) +{ + if ( ! MakeCurrent()) + return false ; + + // recupero le matrici + GLdouble ModelView[ 16] ; + glGetDoublev( GL_MODELVIEW_MATRIX, ModelView) ; + GLdouble Projection[ 16] ; + glGetDoublev( GL_PROJECTION_MATRIX, Projection) ; + GLint Viewport[ 4] ; + glGetIntegerv( GL_VIEWPORT, Viewport) ; + + // eseguo la contro proiezione + // l'asse y della vista OpenGL va in alto con l'origine in basso, + // quello di Windows va in basso con l'origine in alto + int nRes = gluUnProject( ptView.x, ((double) Viewport[3] - ptView.y), ptView.z, + ModelView, Projection, Viewport, + &ptWorld.x, &ptWorld.y, &ptWorld.z) ; + + return ( nRes == GL_TRUE) ; +} + +//---------------------------------------------------------------------------- +void +Scene::Destroy( void) +{ + wglMakeCurrent( nullptr, nullptr) ; + if ( m_hRC != nullptr) { + wglDeleteContext( m_hRC) ; + m_hRC = nullptr ; + } +} diff --git a/SceneCamera.cpp b/SceneCamera.cpp new file mode 100644 index 0000000..27f2957 --- /dev/null +++ b/SceneCamera.cpp @@ -0,0 +1,295 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2014 +//---------------------------------------------------------------------------- +// File : SceneCamera.cpp Data : 10.02.14 Versione : 1.5b1 +// Contenuto : Implementazione della gestione camera della classe scena. +// +// +// +// Modifiche : 10.02.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Scene.h" +#include "/EgtDev/Include/EgtILogger.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGkFrame3d.h" + +using namespace std ; + +//--------------------------- Constants -------------------------------------- +static const double MIN_DIST_CAMERA = 10 ; +static const double STD_DIST_CAMERA = 1000 ; + +//---------------------------------------------------------------------------- +bool +Scene::SetCenter( const Point3d& ptCenter) +{ + // assegno il punto + m_ptCenter = ptCenter ; + // invalido ExtView + m_bExtViewOk = false ; + // calcolo nuovi dati di Z clipping + CalcClippingPlanesFromExtView() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::SetCamera( double dAngVertDeg, double dAngOrizzDeg, double dDist) +{ + // assegno la direzione e la distanza + m_vtDirCamera.FromSpherical( 1, dAngVertDeg, dAngOrizzDeg) ; + if ( dDist < EPS_SMALL) + m_dDistCamera = STD_DIST_CAMERA ; + else + m_dDistCamera = __max( dDist, MIN_DIST_CAMERA) ; + // invalido Up e ExtView + m_bUpOk = false ; + m_bExtViewOk = false ; + // calcolo nuovi dati di Z clipping + CalcClippingPlanesFromExtView() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::SetCamera( int nDir, double dDist) +{ + const double ANG_VERT_ISOVIEW = 54.73561032 ; + double dAngVertDeg ; + double dAngOrizzDeg ; + + + switch ( nDir) { + case CT_TOP : + dAngVertDeg = 0 ; + dAngOrizzDeg = 0 ; + break ; + case CT_FRONT : + dAngVertDeg = 90 ; + dAngOrizzDeg = -90 ; + break ; + case CT_RIGHT : + dAngVertDeg = 90 ; + dAngOrizzDeg = 0 ; + break ; + case CT_BACK : + dAngVertDeg = 90 ; + dAngOrizzDeg = 90 ; + break ; + case CT_LEFT : + dAngVertDeg = 90 ; + dAngOrizzDeg = 180 ; + break ; + case CT_BOTTOM : + dAngVertDeg = 180 ; + dAngOrizzDeg = 0 ; + break ; + case CT_ISO_SW : + dAngVertDeg = ANG_VERT_ISOVIEW ; + dAngOrizzDeg = -135 ; + break ; + case CT_ISO_SE : + dAngVertDeg = ANG_VERT_ISOVIEW ; + dAngOrizzDeg = -45 ; + break ; + case CT_ISO_NE : + dAngVertDeg = ANG_VERT_ISOVIEW ; + dAngOrizzDeg = 45 ; + break ; + case CT_ISO_NW : + dAngVertDeg = ANG_VERT_ISOVIEW ; + dAngOrizzDeg = 135 ; + break ; + default : + return false ; + break ; + } + + return SetCamera( dAngVertDeg, dAngOrizzDeg, dDist) ; +} + +//---------------------------------------------------------------------------- +void +Scene::GetCamera( double* pdAngVertDeg, double* pdAngOrizzDeg, double* pdDist) +{ + double dAngVertDeg ; + double dAngOrizzDeg ; + m_vtDirCamera.ToSpherical( nullptr, &dAngVertDeg, &dAngOrizzDeg) ; + if ( fabs( dAngVertDeg) < EPS_ANG_SMALL) + dAngOrizzDeg = -90 ; + if ( pdAngVertDeg != nullptr) + *pdAngVertDeg = dAngVertDeg ; + if ( pdAngOrizzDeg != nullptr) + *pdAngOrizzDeg = dAngOrizzDeg ; + if ( pdDist != nullptr) + *pdDist = m_dDistCamera ; +} + +//---------------------------------------------------------------------------- +int +Scene::GetCameraDir( void) +{ + if ( m_vtDirCamera.IsZplus()) + return CT_TOP ; + else if ( m_vtDirCamera.IsYminus()) + return CT_FRONT ; + else if ( m_vtDirCamera.IsXplus()) + return CT_RIGHT ; + else if ( m_vtDirCamera.IsYplus()) + return CT_BACK ; + else if ( m_vtDirCamera.IsXminus()) + return CT_LEFT ; + else if ( m_vtDirCamera.IsZminus()) + return CT_BOTTOM ; + else if ( AreSameVectorNear( m_vtDirCamera, Vector3d( SQRT1_3, - SQRT1_3, - SQRT1_3))) + return CT_ISO_SW ; + else if ( AreSameVectorNear( m_vtDirCamera, Vector3d( SQRT1_3, SQRT1_3, - SQRT1_3))) + return CT_ISO_SE ; + else if ( AreSameVectorNear( m_vtDirCamera, Vector3d( SQRT1_3, SQRT1_3, SQRT1_3))) + return CT_ISO_NE ; + else if ( AreSameVectorNear( m_vtDirCamera, Vector3d( SQRT1_3, - SQRT1_3, SQRT1_3))) + return CT_ISO_NW ; + else + return CT_NONE ; +} + +//---------------------------------------------------------------------------- +Point3d +Scene::GetProjectedCenter( void) +{ + Point3d ptVCen ; + if ( ! Project( m_ptCenter, ptVCen)) + ptVCen.Set( 0, 0, 0) ; + + return ptVCen ; +} + +//---------------------------------------------------------------------------- +bool +Scene::CalcDirUp( void) +{ + // verifico se il calcolo è necessario + if ( m_bUpOk) + return true ; + // direzione perpendicolare giacente nel piano XY + // ( m_vtDirCamera è opposta alla direzione in cui si guarda) + Vector3d vtPerpXY = m_vtDirCamera ^ Z_AX ; + if ( ! vtPerpXY.Normalize()) { + if ( m_vtDirCamera.z < 0) + vtPerpXY = X_AX ; + else + vtPerpXY = - X_AX ; + } + // direzione Up + m_vtUp = vtPerpXY ^ m_vtDirCamera ; + m_bUpOk = m_vtUp.Normalize() ; + // invalido ExtView + m_bExtViewOk = false ; + return m_bUpOk ; +} + +//---------------------------------------------------------------------------- +bool +Scene::PanCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) +{ + // porto i due punti in coordinate mondo + double dZCenter = GetProjectedCenter().z ; + Point3d ptViewOld( ptWinOld.x, ptWinOld.y, dZCenter) ; + Point3d ptWorldOld ; + if ( ! UnProject( ptViewOld, ptWorldOld)) + return false ; + Point3d ptViewNew( ptWinNew.x, ptWinNew.y, dZCenter) ; + Point3d ptWorldNew ; + if ( ! UnProject( ptViewNew, ptWorldNew)) + return false ; + // calcolo lo spostamento tra i due punti + Vector3d vtMove = ptWorldNew - ptWorldOld ; + // applico questo spostamento al centro di vista + return SetCenter( GetCenter() - vtMove) ; +} + +//---------------------------------------------------------------------------- +bool +Scene::RotateCamera( const Point3d& ptWinOld, const Point3d& ptWinNew) +{ + const double MIN_ANG_VERT = 0.1 ; + const double MAX_ANG_VERT = 179.9 ; + + // angoli correnti della camera + double dAngVertDeg ; + double dAngOrizzDeg ; + GetCamera( &dAngVertDeg, &dAngOrizzDeg) ; + + // incrementi + double dDeltaAngVertDeg = ( ptWinNew.y - ptWinOld.y) / m_nViewportH * 360 ; + double dDeltaAngOrizzDeg = ( ptWinNew.x - ptWinOld.x) / m_nViewportW * 360 ; + + // calcolo nuovi angoli e limitazione dell'angolo verticale + dAngVertDeg -= dDeltaAngVertDeg ; + if ( dAngVertDeg < MIN_ANG_VERT) + dAngVertDeg = MIN_ANG_VERT ; + else if ( dAngVertDeg > MAX_ANG_VERT) + dAngVertDeg = MAX_ANG_VERT ; + dAngOrizzDeg -= dDeltaAngOrizzDeg ; + + // imposto nuova direzione camera + return SetCamera( dAngVertDeg, dAngOrizzDeg, 0) ; +} + +//---------------------------------------------------------------------------- +bool +Scene::ZoomAll( void) +{ + // traslo il centro di vista nel centro del box + Point3d ptExtCent ; + if ( ! m_b3ExtWorld.GetCenter( ptExtCent)) + return false ; + m_ptCenter = ptExtCent ; + m_bExtViewOk = false ; + + // calcolo nuovi dati di ingombro + CalcDimViewFromExtView() ; + CalcClippingPlanesFromExtView() ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::ZoomChange( double dCoeff) +{ + const double MIN_COEFF = 0.5 ; + const double MAX_COEFF = 2 ; + + // controllo i limiti + if ( dCoeff < MIN_COEFF) + dCoeff = MIN_COEFF ; + else if ( dCoeff > MAX_COEFF) + dCoeff = MAX_COEFF ; + // cambio le dimensioni di zoom + m_dHalfWidth *= dCoeff ; + m_dHalfHeight *= dCoeff ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +Scene::ZoomOnPoint( const Point3d& ptWin, double dCoeff) +{ + // porto il punto in coordinate mondo + Point3d ptView( ptWin.x, ptWin.y, GetProjectedCenter().z) ; + Point3d ptWorld ; + if ( ! UnProject( ptView, ptWorld)) + return false ; + // modifico opportunamente il centro di vista + Point3d ptNewCen = ptWorld + ( GetCenter() - ptWorld) * dCoeff ; + SetCenter( ptNewCen) ; + // eseguo lo zoom + return ZoomChange( dCoeff) ; +} diff --git a/SceneGeom.cpp b/SceneGeom.cpp new file mode 100644 index 0000000..c2ac939 --- /dev/null +++ b/SceneGeom.cpp @@ -0,0 +1,95 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2014 +//---------------------------------------------------------------------------- +// File : EgrSceneGeom.cpp Data : 10.02.14 Versione : 1.5b1 +// Contenuto : Implementazione della gestione geometria della classe scena. +// +// +// +// Modifiche : 10.02.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "Scene.h" +#include "/EgtDev/Include/EgtILogger.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGkFrame3d.h" +#include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EGkGdbIterator.h" +#include "/EgtDev/Include/EGkCurve.h" + +using namespace std ; + + +/*------------------------------------------------------------------------------------------*/ +bool +Scene::DrawGroup( int nId) +{ + // recupero il riferimento del gruppo + Frame3d frFrame ; + //if ( ! m_pGeomDB->GetGroupGlobFrame( nId, frFrame)) + if ( ! m_pGeomDB->GetGroupFrame( nId, frFrame)) + return false ; + // se non è identità, lo imposto nello stack delle matrici MODELVIEW di OpenGL + bool bMatrix = ( frFrame.GetType() != Frame3d::TOP || ! frFrame.Orig().IsSmall()) ; + if ( bMatrix) { + glPushMatrix() ; + double Matrix[16] ; + Matrix[0] = frFrame.VersX().x ; + Matrix[1] = frFrame.VersX().y ; + Matrix[2] = frFrame.VersX().z ; + Matrix[3] = 0 ; + Matrix[4] = frFrame.VersY().x ; + Matrix[5] = frFrame.VersY().y ; + Matrix[6] = frFrame.VersY().z ; + Matrix[7] = 0 ; + Matrix[8] = frFrame.VersZ().x ; + Matrix[9] = frFrame.VersZ().y ; + Matrix[10] = frFrame.VersZ().z ; + Matrix[11] = 0 ; + Matrix[12] = frFrame.Orig().x ; + Matrix[13] = frFrame.Orig().y ; + Matrix[14] = frFrame.Orig().z ; + Matrix[15] = 1 ; + glMultMatrixd( Matrix) ; + } + // creo un iteratore + PtrOwner pIter( CreateGdbIterator()) ; + if ( ! ::IsValid( pIter)) + return false ; + // scandisco il gruppo + pIter->SetGDB( m_pGeomDB) ; + bool bNext = pIter->GoToFirstInGroup( nId) ; + while ( bNext) { + int nGdbType = pIter->GetGdbType() ; + if ( nGdbType == GDB_GEO) { + const ICurve* pCurve ; + // se curva, la emetto + if ( ( pCurve = GetCurve( pIter->GetGeoObj())) != nullptr) { + bool bFound ; + PolyLine PL ; + Point3d ptP ; + pCurve->ApproxWithLines( 0.1, 5, PL) ; + glBegin( GL_LINE_STRIP) ; + for ( bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) { + //ptP.ToGlob( frFrame) ; + glVertex3f( (GLfloat)ptP.x, (GLfloat)ptP.y, (GLfloat)ptP.z) ; + } + glEnd() ; + } + } + else if ( nGdbType == GDB_GROUP) { + if ( ! DrawGroup( pIter->GetId())) + return false ; + } + bNext = pIter->GoToNext() ; + } + // se necessario, ripristino lo stack delle matrici + if ( bMatrix) + glPopMatrix() ; + + return true ; +} diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..c35f41b Binary files /dev/null and b/resource.h differ diff --git a/stdafx.cpp b/stdafx.cpp new file mode 100644 index 0000000..071733f --- /dev/null +++ b/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : file di origine che include solo le inclusioni standard +// EgtGraphics.pch sarà l'intestazione precompilata +// stdafx.obj conterrà le informazioni sui tipi precompilati + +#include "stdafx.h" + +// TODO: fare riferimento alle intestazioni aggiuntive necessarie in STDAFX.H +// e non in questo file diff --git a/stdafx.h b/stdafx.h new file mode 100644 index 0000000..360af94 --- /dev/null +++ b/stdafx.h @@ -0,0 +1,40 @@ +// stdafx.h : file di inclusione per file di inclusione di sistema standard +// o file di inclusione specifici del progetto utilizzati di frequente, ma +// modificati raramente +// + +#pragma once + +#include "/EgtDev/Include/EgtTargetVer.h" + +#include +#include +#include +#include + +// in Debug riconoscimento memory leakage +#if defined( _DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include +#endif + +// in Debug controllo iteratori +#if defined( _DEBUG) + #define _SECURE_SCL 1 +#else + #define _SECURE_SCL 0 +#endif + +#include "/EgtDev/Include/EgtLibVer.h" + +#pragma comment(lib, "opengl32.lib") +#pragma comment(lib, "glu32.lib") +#if defined( _WIN64) +#pragma comment(lib, EGTEXTDIR "GLEW/lib/x64/glew32mx.lib") +#elif defined( _WIN32) +#pragma comment(lib, EGTEXTDIR "GLEW/lib/x32/glew32mx.lib") +#endif + +#pragma comment(lib, EGTLIBDIR "EgtGeneral" EGTLIBVER ".lib") +#pragma comment(lib, EGTLIBDIR "EgtGeomKernel" EGTLIBVER ".lib")