OpenGLDiagnostics.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:4k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // OpenGLDiagnostics.cpp : implementation file
- //
- // glOOP (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1998
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- // This program is -not- in the public domain.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "glOOP.h"
- #include "OpenGLDiagnostics.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // COpenGLDiagnostics dialog
- COpenGLDiagnostics::COpenGLDiagnostics(HDC hDC, HGLRC hRC, CWnd* pParent /*=NULL*/)
- : CDialog(COpenGLDiagnostics::IDD, pParent)
- {
- // Save the device context
- m_hDC = hDC;
- // Save the rendering context
- m_hRC = hRC;
- //{{AFX_DATA_INIT(COpenGLDiagnostics)
- // NOTE: the ClassWizard will add member initialization here
- m_szVendor = _T("");
- m_szExtensions = _T("");
- m_szRenderer = _T("");
- m_szVersion = _T("");
- m_szGluVendor = _T("");
- m_szGluExtensions = _T("");
- m_szError1 = _T("");
- m_szError2 = _T("");
- m_szError3 = _T("");
- m_szError4 = _T("");
- m_szError5 = _T("");
- m_szError6 = _T("");
- //}}AFX_DATA_INIT
- }
- void COpenGLDiagnostics::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(COpenGLDiagnostics)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- DDX_Text(pDX, IDC_VENDOR, m_szVendor);
- DDX_Text(pDX, IDC_EXTENSIONS, m_szExtensions);
- DDX_Text(pDX, IDC_RENDERER, m_szRenderer);
- DDX_Text(pDX, IDC_VERSION, m_szVersion);
- DDX_Text(pDX, IDC_GLU_VENDOR, m_szGluVendor);
- DDX_Text(pDX, IDC_GLU_EXTENSIONS, m_szGluExtensions);
- DDX_Text(pDX, IDC_ERROR1, m_szError1);
- DDX_Text(pDX, IDC_ERROR2, m_szError2);
- DDX_Text(pDX, IDC_ERROR3, m_szError3);
- DDX_Text(pDX, IDC_ERROR4, m_szError4);
- DDX_Text(pDX, IDC_ERROR5, m_szError5);
- DDX_Text(pDX, IDC_ERROR6, m_szError6);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(COpenGLDiagnostics, CDialog)
- //{{AFX_MSG_MAP(COpenGLDiagnostics)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COpenGLDiagnostics message handlers
- BOOL COpenGLDiagnostics::OnInitDialog()
- {
- CDialog::OnInitDialog();
- const GLubyte* ext;
- GLenum glError;
- CenterWindow();
- if(m_hDC && m_hRC) {
- // Make the glContext current
- the3dEngine.EnableRC(m_hDC, m_hRC, TRUE);
- // Get diagnostic data..
- ext = glGetString(GL_VENDOR);
- m_szVendor = ext;
- ext = glGetString(GL_RENDERER);
- m_szRenderer = ext;
- ext = glGetString(GL_VERSION);
- m_szVersion = ext;
- ext = glGetString(GL_EXTENSIONS);
- m_szExtensions = ext;
- ext = gluGetString(GLU_VERSION);
- m_szGluVendor = ext;
- ext = gluGetString(GLU_EXTENSIONS);
- m_szGluExtensions = ext;
- // Display any recent error messages
- int i = 1;
- do {
- glError = glGetError();
- ext = gluErrorString(glError);
- switch (i)
- {
- case 1:
- m_szError1 = ext;
- case 2:
- m_szError2 = ext;
- case 3:
- m_szError3 = ext;
- case 4:
- m_szError4 = ext;
- case 5:
- m_szError5 = ext;
- case 6:
- m_szError6 = ext;
- default:
- break;
- }
- i++;
- } while(i < 7 && glError != GL_NO_ERROR);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- }
- // Initialize dialog data
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }