TestEGr 1.5a1 : Primo commit.

This commit is contained in:
Dario Sassi
2014-01-31 14:52:38 +00:00
parent f159ac62c0
commit bf3cc032b0
15 changed files with 1081 additions and 0 deletions
+322
View File
@@ -0,0 +1,322 @@
// OpenGLRenderer.cpp : implementation file
//
#include "stdafx.h"
#include "OpenGLRenderer.h"
// OpenGLRenderer
//----------------------------------------------------------------------------
OpenGLRenderer::OpenGLRenderer( void)
{
m_hdc = nullptr ;
m_hrc = nullptr ;
}
//----------------------------------------------------------------------------
OpenGLRenderer::~OpenGLRenderer( void)
{
}
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( OpenGLRenderer, CWnd)
// ON_WM_PAINT()
END_MESSAGE_MAP()
// OpenGLRenderer message handlers
bool
OpenGLRenderer::CreateGLContext( CRect rect, CWnd *parent)
{
CString className = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW | CS_OWNDC, NULL, (HBRUSH)GetStockObject(WHITE_BRUSH), NULL) ; //default background colour
CreateEx( 0, className, _T("OpenGL with MFC/CDialog"), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0) ;
m_rectWin = rect ;
if ( ! InitContext()) {
MessageBox( _T("ERROR Creating InitContext")) ;
return false ;
}
// Setup the OpenGL Window's timer to render
//m_unpTimer = SetTimer( 1, 20, 0) ;
return true ;
}
//----------------------------------------------------------------------------
bool
OpenGLRenderer::InitContext( void)
{
PIXELFORMATDESCRIPTOR pfd ;
memset( &pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)) ;
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR) ;
pfd.nVersion = 1 ;
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW ;
pfd.iPixelType = PFD_TYPE_RGBA ;
pfd.cColorBits = 32 ;
pfd.cDepthBits = 32 ;
pfd.iLayerType = PFD_MAIN_PLANE ;
m_hdc = GetDC()->m_hDC ;
int nPixelFormat = ChoosePixelFormat( m_hdc, &pfd) ;
if ( nPixelFormat == 0)
return false ;
BOOL bResult = SetPixelFormat (m_hdc, nPixelFormat, &pfd) ;
if ( ! bResult)
return false ;
HGLRC tempContext = wglCreateContext( m_hdc) ;
wglMakeCurrent( m_hdc, tempContext) ;
GLenum WglewInitResult ;
WglewInitResult = wglewInit() ;
if ( WglewInitResult != GLEW_OK) {
AfxMessageBox( _T("WGLEW is not initialized!")) ;
}
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
//WGL_CONTEXT_FLAGS_ARB, 0,
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;
}
if ( ! m_hrc)
return false;
GLenum GlewInitResult;
glewExperimental = GL_TRUE ;
GlewInitResult = glewInit() ;
if ( GlewInitResult != GLEW_OK) {
AfxMessageBox( _T("GLEW is not initialized!")) ;
}
CString str;
str.Format(_T("OpenGL version: %s\n"),(CString)glGetString(GL_VERSION));
TRACE(str);
return true;
}
//----------------------------------------------------------------------------
void
OpenGLRenderer::PrepareScene( void)
{
wglMakeCurrent( m_hdc, m_hrc) ;
glClearColor(0.0, 0.0, 1.0, 0.0); //background to clear with.
GLenum qq = glGetError() ;
//do other preparations here
glMatrixMode( GL_PROJECTION) ;
qq = glGetError() ;
glLoadIdentity() ;
qq = glGetError() ;
glOrtho( -10, 10, -10, 10, 1, 1000) ;
qq = glGetError() ;
glMatrixMode( GL_MODELVIEW) ;
qq = glGetError() ;
glLoadIdentity() ;
qq = glGetError() ;
gluLookAt( 0, 0, 10,
0, 0, -100,
0, 1, 0) ;
qq = glGetError() ;
wglMakeCurrent( m_hdc, NULL) ;
}
//----------------------------------------------------------------------------
void
OpenGLRenderer::Reshape( int nW, int nH)
{
if ( m_hdc == NULL)
return ;
m_rectWin.SetRect( m_rectWin.left, m_rectWin.top, m_rectWin.left + nW, m_rectWin.top + nH) ;
MoveWindow( m_rectWin, FALSE) ;
if ( wglMakeCurrent( m_hdc, m_hrc))
glViewport( 0, 0, (GLsizei)nW, (GLsizei)nH) ;
wglMakeCurrent( m_hdc, NULL) ;
DrawScene() ;
}
//----------------------------------------------------------------------------
//void
//OpenGLRenderer::OnPaint( void)
//{
// DrawScene();
//}
//----------------------------------------------------------------------------
void
OpenGLRenderer::DrawScene( void)
{
wglMakeCurrent( m_hdc, m_hrc) ;
//--------------------------------
//--------------------------------
glClear( GL_COLOR_BUFFER_BIT) ;
for ( int i=0; i<2; i++) {
if ( m_vaoID[i] != 0) {
glBindVertexArray( m_vaoID[i]) ;
glDrawArrays( GL_LINE_STRIP, 0, m_GLSizeCount) ;
}
}
//--------------------------------
glFlush() ;
SwapBuffers( m_hdc) ;
wglMakeCurrent( m_hdc, NULL) ;
}
//----------------------------------------------------------------------------
void
OpenGLRenderer::SetData( int iType)
{
const int SQUARE = 1 ;
//const int CUBE = 2 ;
const int TRIANGLE = 3 ;
m_iShapeType = iType ;
switch ( iType) {
case SQUARE :
SetSquare() ;
break;
case TRIANGLE:
SetTriangle() ;
break;
default:
SetTriangle() ;
}
}
//----------------------------------------------------------------------------
void
OpenGLRenderer::SetSquare( void)
{
wglMakeCurrent( m_hdc, m_hrc) ;
// First simple object
m_GLSizeCount = 5 ;
m_GLIntSize = 4 ;
GLfloat Square[] = {
-0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, 0.5f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 1.0f,
0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.0f, 1.0f
} ;
// inizializzo VAOs a non allocati
m_vaoID[0] = 0 ;
m_vaoID[1] = 0 ;
// VAO allocation
glGenVertexArrays( 1, &m_vaoID[0]) ;
if ( m_vaoID[0] == 0)
return ;
// First VAO setup
glBindVertexArray( m_vaoID[0]) ;
glGenBuffers( 1, &m_vboID[0]) ;
glBindBuffer( GL_ARRAY_BUFFER, m_vboID[0]) ;
glBufferData( GL_ARRAY_BUFFER, sizeof( Square), Square, GL_STATIC_DRAW) ;
glVertexAttribPointer( (GLuint)0, m_GLIntSize, GL_FLOAT, GL_FALSE, 0, 0) ;
glEnableVertexAttribArray( 0) ;
glBindVertexArray( 0) ;
wglMakeCurrent( m_hdc, NULL) ;
}
//----------------------------------------------------------------------------
void
OpenGLRenderer::SetTriangle( void)
{
wglMakeCurrent( m_hdc, m_hrc) ;
m_GLIntSize = 4; //number of floats per item. i.e. number of floats per point in space.
m_GLSizeCount = 4; //number of items. ie sizeof(TriangleA)/m_GLIntSize
GLfloat TriangleA[] = {
-0.3f, 0.5f, -1.0f, 1.0f,
-0.8f, -0.5f, -1.0f, 1.0f,
0.2f, -0.5f, -1.0f, 1.0f,
-0.3f, 0.5f, -1.0f, 1.0f
} ;
GLfloat TriangleB[] = {
-0.2f, 0.5f, -1.0f, 1.0f,
0.3f, -0.5f, -1.0f, 1.0f,
0.8f, 0.5f, -1.0f, 1.0f,
-0.2f, 0.5f, -1.0f, 1.0f
} ;
// inizializzo VAOs a non allocati
m_vaoID[0] = 0 ;
m_vaoID[1] = 0 ;
// VAOs allocation
glGenVertexArrays( 2, &m_vaoID[0]) ;
// First VAO setup
glBindVertexArray( m_vaoID[0]) ;
glGenBuffers( 1, &m_vboID[0]) ; //VBO allocation
glBindBuffer( GL_ARRAY_BUFFER, m_vboID[0]) ;
glBufferData( GL_ARRAY_BUFFER, sizeof(TriangleA), TriangleA, GL_STATIC_DRAW) ;
glVertexAttribPointer( (GLuint)0, m_GLIntSize, GL_FLOAT, GL_FALSE, 0, 0) ;
glEnableVertexAttribArray( 0) ;
glBindVertexArray( 0) ;
// Second VAO setup
glBindVertexArray( m_vaoID[1]) ;
glGenBuffers( 1, &m_vboID[1]) ; //VBO allocation
glBindBuffer( GL_ARRAY_BUFFER, m_vboID[1]) ;
glBufferData( GL_ARRAY_BUFFER, sizeof(TriangleB), TriangleB, GL_STATIC_DRAW) ;
glVertexAttribPointer( (GLuint)0, m_GLIntSize, GL_FLOAT, GL_FALSE, 0, 0) ;
glEnableVertexAttribArray( 0) ;
glBindVertexArray( 0) ;
wglMakeCurrent( m_hdc, NULL) ;
}
//----------------------------------------------------------------------------
void
OpenGLRenderer::DestroyScene( void)
{
wglMakeCurrent( m_hdc, m_hrc) ;
glBindBuffer( GL_ARRAY_BUFFER, 0) ;
glDeleteBuffers( 2, m_vboID) ;
glBindVertexArray( 0) ;
glDeleteVertexArrays( 2, m_vaoID) ;
wglMakeCurrent( nullptr, nullptr) ;
if ( m_hrc != nullptr) {
wglDeleteContext( m_hrc) ;
m_hrc = nullptr ;
}
}
+60
View File
@@ -0,0 +1,60 @@
#pragma once
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#if defined( _WIN64)
#pragma comment(lib, "/EgtDev/Extern/GLEW/lib/x64/glew32mx.lib") //make sure project settings have: Linker -> Additional Library Directories -> include path for library.
#else
#pragma comment(lib, "/EgtDev/Extern/GLEW/lib/x32/glew32mx.lib") //make sure project settings have: Linker -> Additional Library Directories -> include path for library.
#endif
#define GLEW_MX
#include "/EgtDev/Extern/GLEW/Include/glew.h"
#include "/EgtDev/Extern/GLEW/Include/wglew.h"
// OpenGLRenderer
class OpenGLRenderer : public CWnd
{
public:
OpenGLRenderer( void);
virtual ~OpenGLRenderer( void);
bool CreateGLContext( CRect rect, CWnd *parent);
void PrepareScene( void) ; // Scene preparation
void Reshape( int nW, int nH) ;
void DrawScene( void) ; // Draw scene
void DestroyScene( void) ; // Cleanup
CRect& GetWinRect( void)
{ return m_rectWin ; }
void SetData( int iType) ; // Creates VAO and VBOs and fill them with data
GLEWContext* glewGetContext( void)
{ return &m_glewc ; }
WGLEWContext* wglewGetContext( void)
{ return &m_wglewc ; }
protected :
void SetTriangle( void) ;
void SetSquare( void) ;
bool InitContext( void) ; // Creates OpenGL Rendering Context
afx_msg void OnPaint( void) ;
HDC m_hdc ;
HGLRC m_hrc ; // OpenGL Rendering Context
GLEWContext m_glewc ; // GLEW Context
WGLEWContext m_wglewc ; // WGLEW Context
CRect m_rectWin ;
GLuint m_vaoID[2] ; // 2 vertex array objects
GLuint m_vboID[2] ; // 2 VBOs
int m_GLIntSize ;
int m_GLSizeCount ;
int m_iShapeType ; //1,3 for triangle & square.
DECLARE_MESSAGE_MAP()
} ;
+75
View File
@@ -0,0 +1,75 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : TestEGr.cpp Data : 29.01.14 Versione : 1.5a1
// Contenuto : Implementazione della classe applicazione test grafica.
//
//
//
// Modifiche : 29.01.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "TestEGr.h"
#include "TestEGrDlg.h"
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//----------------------------------------------------------------------------
// The one and only CTestEGrApp object
CTestEGrApp theApp ;
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CTestEGrApp, CWinApp)
ON_COMMAND( ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
CTestEGrApp::CTestEGrApp( void)
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
//----------------------------------------------------------------------------
BOOL
CTestEGrApp::InitInstance( void)
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls ;
InitCtrls.dwSize = sizeof( InitCtrls) ;
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES ;
InitCommonControlsEx( &InitCtrls) ;
CWinApp::InitInstance() ;
AfxEnableControlContainer() ;
CTestEGrDlg dlg ;
m_pMainWnd = &dlg ;
INT_PTR nResponse = dlg.DoModal() ;
if ( nResponse == IDOK) {
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if ( nResponse == IDCANCEL) {
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE ;
}
+32
View File
@@ -0,0 +1,32 @@
// TestEGr.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CTestEGrApp:
// See TestEGr.cpp for the implementation of this class
//
class CTestEGrApp : public CWinApp
{
public:
CTestEGrApp();
// Overrides
public:
virtual BOOL InitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CTestEGrApp theApp;
BIN
View File
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestEGr", "TestEGr.vcxproj", "{F93E2F86-DD41-466C-9069-6EF7B660EA3D}"
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
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Debug|Win32.ActiveCfg = Debug|Win32
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Debug|Win32.Build.0 = Debug|Win32
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Debug|x64.ActiveCfg = Debug|x64
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Debug|x64.Build.0 = Debug|x64
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Release|Win32.ActiveCfg = Release|Win32
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Release|Win32.Build.0 = Release|Win32
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Release|x64.ActiveCfg = Release|x64
{F93E2F86-DD41-466C-9069-6EF7B660EA3D}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+233
View File
@@ -0,0 +1,233 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F93E2F86-DD41-466C-9069-6EF7B660EA3D}</ProjectGuid>
<RootNamespace>TestEGr</RootNamespace>
<Keyword>MFCProj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)D$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)D$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)$(PlatformArchitecture)\</OutDir>
<IntDir>$(Configuration)$(PlatformArchitecture)\</IntDir>
<TargetName>$(ProjectName)R$(PlatformArchitecture)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;_DEB32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>copy $(TargetPath) \EgtProg\TestEGr\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;_DEB32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>copy $(TargetPath) \EgtProg\TestEGr\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;NDEB32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>copy $(TargetPath) \EgtProg\TestEGr\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;NDEB32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<PostBuildEvent>
<Command>copy $(TargetPath) \EgtProg\TestEGr\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="res\TestEGr.ico" />
<None Include="res\TestEGr.rc2" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="OpenGLRenderer.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TestEGr.h" />
<ClInclude Include="TestEGrDlg.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="OpenGLRenderer.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TestEGr.cpp" />
<ClCompile Include="TestEGrDlg.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="TestEGr.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="TestEGr.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
+214
View File
@@ -0,0 +1,214 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : TestEGrDlg.cpp Data : 29.01.14 Versione : 1.5a1
// Contenuto : Implementazione della classe gestione dialogo principale.
//
//
//
// Modifiche : 29.01.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "TestEGr.h"
#include "TestEGrDlg.h"
#include "afxdialogex.h"
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//----------------------------------------------------------------------------
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialogEx
{
public :
CAboutDlg( void) ;
DECLARE_MESSAGE_MAP()
} ;
//----------------------------------------------------------------------------
CAboutDlg::CAboutDlg( void) : CDialogEx( IDD_ABOUTBOX)
{
}
BEGIN_MESSAGE_MAP( CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
// CTestEGrDlg dialog
//----------------------------------------------------------------------------
CTestEGrDlg::CTestEGrDlg( CWnd* pParent)
: CDialogEx( IDD_TESTEGR_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME) ;
m_bOpenGLWindowsExists = false ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::DoDataExchange( CDataExchange* pDX)
{
CDialogEx::DoDataExchange( pDX) ;
}
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CTestEGrDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
BOOL
CTestEGrDlg::OnInitDialog( void)
{
CDialogEx::OnInitDialog() ;
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX) ;
ASSERT(IDM_ABOUTBOX < 0xF000) ;
CMenu* pSysMenu = GetSystemMenu( FALSE) ;
if ( pSysMenu != NULL) {
BOOL bNameValid ;
CString strAboutMenu ;
bNameValid = strAboutMenu.LoadString( IDS_ABOUTBOX) ;
ASSERT( bNameValid) ;
if ( ! strAboutMenu.IsEmpty()) {
pSysMenu->AppendMenu( MF_SEPARATOR) ;
pSysMenu->AppendMenu( MF_STRING, IDM_ABOUTBOX, strAboutMenu) ;
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon( m_hIcon, TRUE) ; // Set big icon
SetIcon( m_hIcon, FALSE) ; // Set small icon
StartOpenGL() ;
return TRUE ; // return TRUE unless you set the focus to a control
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnOK( void)
{
m_OGL_Window.DestroyScene() ;
CDialogEx::OnOK() ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnSysCommand( UINT nID, LPARAM lParam)
{
if ( (nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout ;
dlgAbout.DoModal() ;
}
else {
CDialogEx::OnSysCommand( nID, lParam) ;
}
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnPaint( void)
{
if ( IsIconic()) {
CPaintDC dc( this) ; // device context for painting
SendMessage( WM_ICONERASEBKGND, reinterpret_cast<WPARAM>( dc.GetSafeHdc()), 0) ;
// Center icon in client rectangle
int cxIcon = GetSystemMetrics( SM_CXICON) ;
int cyIcon = GetSystemMetrics( SM_CYICON) ;
CRect rect ;
GetClientRect( &rect) ;
int x = ( rect.Width() - cxIcon + 1) / 2 ;
int y = ( rect.Height() - cyIcon + 1) / 2 ;
// Draw the icon
dc.DrawIcon( x, y, m_hIcon) ;
}
else {
CDialogEx::OnPaint() ;
m_OGL_Window.DrawScene() ;
m_OGL_Window.ValidateRgn( NULL) ;
}
}
//----------------------------------------------------------------------------
HCURSOR
CTestEGrDlg::OnQueryDragIcon( void)
{
return static_cast<HCURSOR>( m_hIcon) ;
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnSize( UINT nType, int cx, int cy)
{
const int SIDEBAR_W = 200 ;
CDialogEx::OnSize( nType, cx, cy) ;
// se ridotta a icona non si fa alcunché
if ( cx <= 0 || cy <= 0 || nType == SIZE_MINIMIZED)
return ;
// se cambiata dimensione
if ( nType == SIZE_RESTORED || nType == SIZE_MAXIMIZED) {
// spostamento comandi
CWnd* pOK = GetDlgItem( IDOK) ;
if ( pOK != nullptr) {
CRect rect ;
pOK->GetWindowRect( rect) ;
pOK->MoveWindow( cx - rect.Width() / 2 - SIDEBAR_W / 2, cy - rect.Height(),
rect.Width(), rect.Height(), TRUE) ;
}
// adattamento finestra
if ( m_bOpenGLWindowsExists) {
CRect rect = m_OGL_Window.GetWinRect() ;
m_OGL_Window.Reshape( cx - rect.left - SIDEBAR_W, cy - rect.top) ;
}
}
}
//----------------------------------------------------------------------------
void
CTestEGrDlg::StartOpenGL( void)
{
CRect rectWin ;
GetDlgItem( IDC_SCENE)->GetWindowRect( rectWin) ;
ScreenToClient( rectWin) ;
if ( m_bOpenGLWindowsExists) {
m_OGL_Window.DestroyScene() ;
m_bOpenGLWindowsExists = false ;
}
// Create OpenGL Control window
if ( ! m_bOpenGLWindowsExists) {
m_OGL_Window.CreateGLContext( rectWin, this) ;
m_OGL_Window.PrepareScene() ;
m_OGL_Window.SetData( 1) ;
m_bOpenGLWindowsExists = true ;
}
}
+45
View File
@@ -0,0 +1,45 @@
//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : TestEGrDlg.h Data : 29.01.14 Versione : 1.5a1
// Contenuto : Dichiarazione della classe gestione dialogo principale.
//
//
//
// Modifiche : 29.01.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "OpenGLRenderer.h"
//----------------------------------------------------------------------------
class CTestEGrDlg : public CDialogEx
{
public :
CTestEGrDlg( CWnd* pParent = NULL) ;
protected :
virtual void DoDataExchange( CDataExchange* pDX) ;
protected :
virtual BOOL OnInitDialog( void) ;
virtual void OnOK( void) ;
afx_msg void OnSysCommand( UINT nID, LPARAM lParam) ;
afx_msg void OnPaint( void) ;
afx_msg HCURSOR OnQueryDragIcon( void) ;
afx_msg void OnSize( UINT nType, int cx, int cy) ;
private :
void StartOpenGL( void) ;
private :
HICON m_hIcon ;
bool m_bOpenGLWindowsExists ;
OpenGLRenderer m_OGL_Window ;
DECLARE_MESSAGE_MAP()
} ;
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// TestEGr.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
+58
View File
@@ -0,0 +1,58 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
+8
View File
@@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>