⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabtoolopengl.cpp

📁 这是关于飞机生存力计算软件
💻 CPP
字号:
// TabtoolOpenGL.cpp : implementation file
//

#include "stdafx.h"
#include "Simulate.h"
#include "TabtoolOpenGL.h"
#include "MainFrm.h"
#include "SimulateView.h"

#include <GL/gl.h>
#include <GL/glu.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTabtoolOpenGL dialog


CTabtoolOpenGL::CTabtoolOpenGL(CWnd* pParent /*=NULL*/)
	: CDialog(CTabtoolOpenGL::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTabtoolOpenGL)
	m_nModelMode = -1;
	m_bAntialias = FALSE;
	m_bSmooth = FALSE;
	//}}AFX_DATA_INIT
}


void CTabtoolOpenGL::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTabtoolOpenGL)
	DDX_Control(pDX, IDC_TABTOOL_OPENGL_MESHESLIST, m_MeshesList);
	DDX_Radio(pDX, IDC_TABTOOL_OPENGL_WIREFRAME, m_nModelMode);
	DDX_Check(pDX, IDC_TABTOOL_OPENGL_CHECK_ANTIALIAS, m_bAntialias);
	DDX_Check(pDX, IDC_TABTOOL_OPENGL_CHECK_SMOOTH, m_bSmooth);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTabtoolOpenGL, CDialog)
	//{{AFX_MSG_MAP(CTabtoolOpenGL)
	ON_BN_CLICKED(IDC_TABTOOL_OPENGL_FACE, OnTabtoolOpenglFace)
	ON_BN_CLICKED(IDC_TABTOOL_OPENGL_WIREFRAME, OnTabtoolOpenglWireframe)
	ON_BN_CLICKED(IDC_TABTOOL_OPENGL_CHECK_ANTIALIAS, OnTabtoolOpenglCheckAntialias)
	ON_BN_CLICKED(IDC_TABTOOL_OPENGL_CHECK_SMOOTH, OnTabtoolOpenglCheckSmooth)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTabtoolOpenGL message handlers

BOOL CTabtoolOpenGL::Create(CWnd* pParentWnd)
{
	return CDialog::Create(CTabtoolOpenGL::IDD, pParentWnd);
}

CView * CTabtoolOpenGL::GetRenderView()
{
	CSimulateApp *pApp = (CSimulateApp *)AfxGetApp();
	CMainFrame *pMainFrame = (CMainFrame *)pApp->m_pMainWnd;
	CView *pView = (CView *)pMainFrame->m_wndSplitter.GetPane(0,1);
	return pView;

}

void CTabtoolOpenGL::OnTabtoolOpenglFace() 
{
	// TODO: Add your control notification handler code here
	if(IsDlgButtonChecked(IDC_TABTOOL_OPENGL_FACE))
	{
		m_nModelMode = MODEL_FACE;
		glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
		glEnable(GL_LIGHTING);
		this->GetRenderView()->InvalidateRect(NULL,FALSE); 
	}
	
}

void CTabtoolOpenGL::OnTabtoolOpenglWireframe() 
{
	// TODO: Add your control notification handler code here
	if(IsDlgButtonChecked(IDC_TABTOOL_OPENGL_WIREFRAME))
	{
		m_nModelMode = MODEL_WIREFRAME;
		glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
		this->GetRenderView()->InvalidateRect(NULL,FALSE); 
	}
	
}

void CTabtoolOpenGL::OnTabtoolOpenglCheckAntialias() 
{
	// TODO: Add your control notification handler code here
	m_bAntialias = !m_bAntialias;

	if(m_bAntialias)
	{
		glEnable(GL_LINE_SMOOTH);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
		glLineWidth(1.5);
	}
	else
	{
		glDisable(GL_LINE_SMOOTH);
		glDisable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
		glLineWidth(1.0);
	}
	GetRenderView()->InvalidateRect(NULL,FALSE); 
	
}

BOOL CTabtoolOpenGL::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_nModelMode = MODEL_WIREFRAME;
	m_bAntialias = FALSE;
	m_bSmooth = FALSE;

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTabtoolOpenGL::OnOK()
{
	return;
}

void CTabtoolOpenGL::OnCancel()
{
	return;
}

void CTabtoolOpenGL::OnTabtoolOpenglCheckSmooth() 
{
	// TODO: Add your control notification handler code here
	m_bSmooth = !m_bSmooth;
	
	CSimulateView* SimulateView = (CSimulateView *)GetRenderView();
	SimulateView->m_bSmooth = m_bSmooth;
	glEnable(GL_LIGHTING);
	SimulateView->InvalidateRect(NULL,FALSE); 

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -