mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Added MSAA option to Preferences Dialog.
This commit is contained in:
parent
b310864b18
commit
719f88af51
9 changed files with 76 additions and 29 deletions
|
@ -100,19 +100,19 @@ int stricmp(const char* str1, const char* str2);
|
|||
#define LC_STR_VERSION "LeoCAD 0.7 Project\0\0" // char[20]
|
||||
|
||||
|
||||
// #define DET_BACKFACES 0x00001 // Draw backfaces
|
||||
// #define DET_DEPTH 0x00002 // Enable depth test
|
||||
// #define DET_CLEAR 0x00004 // Use clear colors
|
||||
//#define DET_BACKFACES 0x00001 // Draw backfaces
|
||||
//#define DET_DEPTH 0x00002 // Enable depth test
|
||||
//#define DET_CLEAR 0x00004 // Use clear colors
|
||||
#define LC_DET_LIGHTING 0x00008 // Lighting
|
||||
#define LC_DET_SMOOTH 0x00010 // Smooth shading
|
||||
// #define DET_STUDS 0x00020 // Draw studs
|
||||
// #define DET_WIREFRAME 0x00040 // Wireframe
|
||||
#define LC_DET_ANTIALIAS 0x00080 // Turn on anti-aliasing
|
||||
//#define DET_STUDS 0x00020 // Draw studs
|
||||
//#define DET_WIREFRAME 0x00040 // Wireframe
|
||||
//#define LC_DET_ANTIALIAS 0x00080 // Turn on anti-aliasing
|
||||
#define LC_DET_BRICKEDGES 0x00100 // Draw lines
|
||||
//#define LC_DET_DITHER 0x00200 // Enable dithering
|
||||
//#define LC_DET_BOX_FILL 0x00400 // Filled boxes
|
||||
//#define LC_DET_HIDDEN_LINE 0x00800 // Remove hidden lines
|
||||
// #define DET_STUDS_BOX 0x01000 // Draw studs as boxes
|
||||
//#define DET_STUDS_BOX 0x01000 // Draw studs as boxes
|
||||
//#define LC_DET_LINEAR 0x02000 // Linear filtering
|
||||
#define LC_DET_FAST 0x04000 // Fast rendering (boxes)
|
||||
//#define LC_DET_BACKGROUND 0x08000 // Background rendering
|
||||
|
|
|
@ -5257,6 +5257,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
strcpy(opts.strPath, m_strModelsPath);
|
||||
opts.nDetail = m_nDetail;
|
||||
opts.fLineWidth = m_fLineWidth;
|
||||
opts.AASamples = Sys_ProfileLoadInt("Default", "AASamples", 1);
|
||||
opts.nSnap = m_nSnap;
|
||||
opts.nAngleSnap = m_nAngleSnap;
|
||||
opts.nGridSize = m_nGridSize;
|
||||
|
|
|
@ -353,6 +353,7 @@ struct LC_PREFERENCESDLG_OPTS
|
|||
char strPath[LC_MAXPATH];
|
||||
unsigned long nDetail;
|
||||
float fLineWidth;
|
||||
int AASamples;
|
||||
unsigned long nSnap;
|
||||
unsigned short nAngleSnap;
|
||||
unsigned short nGridSize;
|
||||
|
|
|
@ -847,12 +847,13 @@ CAPTION "Render"
|
|||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
CONTROL "Draw edge lines",IDC_DETDLG_EDGES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,11,130,8
|
||||
CONTROL "Enable lighting",IDC_DETDLG_LIGHTING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,27,130,8
|
||||
CONTROL "Smooth shading",IDC_DETDLG_SMOOTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,43,130,8
|
||||
CONTROL "Anti-aliasing",IDC_DETDLG_ANTIALIAS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,59,130,8
|
||||
CONTROL "Fast rendering",IDC_DETDLG_FAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,75,130,8
|
||||
LTEXT "Line width",IDC_STATIC,10,91,34,8
|
||||
EDITTEXT IDC_DETDLG_LINE,50,89,26,12,ES_AUTOHSCROLL
|
||||
LTEXT "Line width",IDC_STATIC,21,29,50,8
|
||||
EDITTEXT IDC_DETDLG_LINE,78,27,34,12,ES_AUTOHSCROLL
|
||||
LTEXT "Anti-aliasing",IDC_STATIC,21,47,50,8
|
||||
COMBOBOX IDC_DETDLG_ANTIALIAS,78,44,34,12,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "Enable lighting",IDC_DETDLG_LIGHTING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,65,130,8
|
||||
CONTROL "Smooth shading",IDC_DETDLG_SMOOTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,81,130,8
|
||||
CONTROL "Fast rendering",IDC_DETDLG_FAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,97,130,8
|
||||
END
|
||||
|
||||
IDD_PREFSCENE DIALOGEX 0, 0, 285, 160
|
||||
|
@ -1435,6 +1436,25 @@ IDC_ROLL CURSOR "res\\roll.cur"
|
|||
IDC_ROTX CURSOR "res\\rotx.cur"
|
||||
IDC_ROTY CURSOR "res\\roty.cur"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog Info
|
||||
//
|
||||
|
||||
IDD_PREFDETAIL DLGINIT
|
||||
BEGIN
|
||||
IDC_DETDLG_ANTIALIAS, 0x403, 4, 0
|
||||
0x664f, 0x0066,
|
||||
IDC_DETDLG_ANTIALIAS, 0x403, 3, 0
|
||||
0x7832, "\000"
|
||||
IDC_DETDLG_ANTIALIAS, 0x403, 3, 0
|
||||
0x7834, "\000"
|
||||
IDC_DETDLG_ANTIALIAS, 0x403, 3, 0
|
||||
0x7838, "\000"
|
||||
0
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
|
|
|
@ -120,7 +120,7 @@ void CPreferencesGeneral::OnOK()
|
|||
CPreferencesDetail::CPreferencesDetail() : CPropertyPage(CPreferencesDetail::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CPreferencesDetail)
|
||||
m_bAntialiasing = FALSE;
|
||||
m_nAntialiasing = 0;
|
||||
m_bEdges = FALSE;
|
||||
m_bLighting = FALSE;
|
||||
m_bSmooth = FALSE;
|
||||
|
@ -137,7 +137,7 @@ void CPreferencesDetail::DoDataExchange(CDataExchange* pDX)
|
|||
{
|
||||
CPropertyPage::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPreferencesDetail)
|
||||
DDX_Check(pDX, IDC_DETDLG_ANTIALIAS, m_bAntialiasing);
|
||||
DDX_CBIndex(pDX, IDC_DETDLG_ANTIALIAS, m_nAntialiasing);
|
||||
DDX_Check(pDX, IDC_DETDLG_EDGES, m_bEdges);
|
||||
DDX_Check(pDX, IDC_DETDLG_LIGHTING, m_bLighting);
|
||||
DDX_Check(pDX, IDC_DETDLG_SMOOTH, m_bSmooth);
|
||||
|
@ -154,25 +154,36 @@ BEGIN_MESSAGE_MAP(CPreferencesDetail, CPropertyPage)
|
|||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
void CPreferencesDetail::SetOptions(DWORD dwDetail, float fLine)
|
||||
void CPreferencesDetail::SetOptions(DWORD dwDetail, float LineWidth, int AASamples)
|
||||
{
|
||||
m_bAntialiasing = (dwDetail & LC_DET_ANTIALIAS) != 0;
|
||||
m_bEdges = (dwDetail & LC_DET_BRICKEDGES) != 0;
|
||||
m_bLighting = (dwDetail & LC_DET_LIGHTING) != 0;
|
||||
m_bSmooth = (dwDetail & LC_DET_SMOOTH) != 0;
|
||||
m_bFast = (dwDetail & LC_DET_FAST) != 0;
|
||||
m_fLineWidth = fLine;
|
||||
m_fLineWidth = LineWidth;
|
||||
switch (AASamples)
|
||||
{
|
||||
default:
|
||||
case 1: m_nAntialiasing = 0;
|
||||
break;
|
||||
case 2: m_nAntialiasing = 1;
|
||||
break;
|
||||
case 4: m_nAntialiasing = 2;
|
||||
break;
|
||||
case 8: m_nAntialiasing = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPreferencesDetail::GetOptions(DWORD* dwDetail, float* fLine)
|
||||
void CPreferencesDetail::GetOptions(DWORD* dwDetail, float* LineWidth, int* AASamples)
|
||||
{
|
||||
*dwDetail = 0;
|
||||
if (m_bAntialiasing) *dwDetail |= LC_DET_ANTIALIAS;
|
||||
if (m_bEdges) *dwDetail |= LC_DET_BRICKEDGES;
|
||||
if (m_bLighting) *dwDetail |= LC_DET_LIGHTING;
|
||||
if (m_bSmooth) *dwDetail |= LC_DET_SMOOTH;
|
||||
if (m_bFast) *dwDetail |= LC_DET_FAST;
|
||||
*fLine = m_fLineWidth;
|
||||
*LineWidth = m_fLineWidth;
|
||||
*AASamples = 1 << m_nAntialiasing;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -66,15 +66,15 @@ class CPreferencesDetail : public CPropertyPage
|
|||
|
||||
// Construction
|
||||
public:
|
||||
void SetOptions(DWORD dwDetail, float fLine);
|
||||
void GetOptions(DWORD* dwDetail, float* fLine);
|
||||
void SetOptions(DWORD dwDetail, float LineWidth, int AASamples);
|
||||
void GetOptions(DWORD* dwDetail, float* LineWidth, int* AASamples);
|
||||
CPreferencesDetail();
|
||||
~CPreferencesDetail();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPreferencesDetail)
|
||||
enum { IDD = IDD_PREFDETAIL };
|
||||
BOOL m_bAntialiasing;
|
||||
BOOL m_nAntialiasing;
|
||||
BOOL m_bEdges;
|
||||
BOOL m_bLighting;
|
||||
BOOL m_bSmooth;
|
||||
|
|
|
@ -99,13 +99,18 @@ void CPreferencesSheet::OnDefault()
|
|||
AfxGetApp()->WriteProfileInt("Default", "Mouse", j);
|
||||
AfxGetApp()->WriteProfileString("Default", "Projects", str);
|
||||
AfxGetApp()->WriteProfileString("Default", "User", st1);
|
||||
m_PageDetail.GetOptions(&l, &f);
|
||||
|
||||
int AASamples;
|
||||
m_PageDetail.GetOptions(&l, &f, &AASamples);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Detail", l);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Line", (int)(f*100));
|
||||
AfxGetApp()->WriteProfileInt("Default", "AASamples", AASamples);
|
||||
|
||||
m_PageDrawing.GetOptions(&l, &s1, &s2);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Snap", l);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Angle", s1);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Grid", s2);
|
||||
|
||||
m_PageScene.GetOptions(&l, &f, str, cr1, cr2, cr3, cr4, cr5);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Scene", l);
|
||||
AfxGetApp()->WriteProfileInt("Default", "Density", (int)(f*100));
|
||||
|
@ -115,6 +120,7 @@ void CPreferencesSheet::OnDefault()
|
|||
AfxGetApp()->WriteProfileInt("Default", "Ambient", RGB(cr3[0]*255, cr3[1]*255, cr3[2]*255));
|
||||
AfxGetApp()->WriteProfileInt("Default", "Gradient1", RGB(cr4[0]*255, cr4[1]*255, cr4[2]*255));
|
||||
AfxGetApp()->WriteProfileInt("Default", "Gradient2", RGB(cr5[0]*255, cr5[1]*255, cr5[2]*255));
|
||||
|
||||
m_PagePrint.GetOptions(st1, st2);
|
||||
AfxGetApp()->WriteProfileString("Default", "Header", st1);
|
||||
AfxGetApp()->WriteProfileString("Default", "Footer", st2);
|
||||
|
|
|
@ -1233,7 +1233,7 @@ bool SystemDoDialog(int nMode, void* param)
|
|||
LC_PREFERENCESDLG_OPTS* opts = (LC_PREFERENCESDLG_OPTS*)param;
|
||||
|
||||
ps.m_PageGeneral.SetOptions(opts->nSaveInterval, opts->nMouse, opts->strPath, opts->strUser);
|
||||
ps.m_PageDetail.SetOptions(opts->nDetail, opts->fLineWidth);
|
||||
ps.m_PageDetail.SetOptions(opts->nDetail, opts->fLineWidth, opts->AASamples);
|
||||
ps.m_PageDrawing.SetOptions(opts->nSnap, opts->nAngleSnap, opts->nGridSize);
|
||||
ps.m_PageScene.SetOptions(opts->nScene, opts->fDensity, opts->strBackground, opts->fBackground, opts->fFog, opts->fAmbient, opts->fGrad1, opts->fGrad2);
|
||||
ps.m_PagePrint.SetOptions(opts->strHeader, opts->strFooter);
|
||||
|
@ -1242,7 +1242,7 @@ bool SystemDoDialog(int nMode, void* param)
|
|||
if (ps.DoModal() == IDOK)
|
||||
{
|
||||
ps.m_PageGeneral.GetOptions(&opts->nSaveInterval, &opts->nMouse, opts->strPath, opts->strUser);
|
||||
ps.m_PageDetail.GetOptions(&opts->nDetail, &opts->fLineWidth);
|
||||
ps.m_PageDetail.GetOptions(&opts->nDetail, &opts->fLineWidth, &opts->AASamples);
|
||||
ps.m_PageDrawing.GetOptions(&opts->nSnap, &opts->nAngleSnap, &opts->nGridSize);
|
||||
ps.m_PageScene.GetOptions(&opts->nScene, &opts->fDensity, opts->strBackground, opts->fBackground, opts->fFog, opts->fAmbient, opts->fGrad1, opts->fGrad2);
|
||||
ps.m_PagePrint.GetOptions(opts->strHeader, opts->strFooter);
|
||||
|
@ -1252,6 +1252,12 @@ bool SystemDoDialog(int nMode, void* param)
|
|||
AfxGetApp()->WriteProfileInt("Default", "Mouse", opts->nMouse);
|
||||
AfxGetApp()->WriteProfileString("Default", "Projects", opts->strPath);
|
||||
|
||||
if (opts->AASamples != Sys_ProfileLoadInt("Default", "AASamples", 1))
|
||||
{
|
||||
AfxGetApp()->WriteProfileInt("Default", "AASamples", opts->AASamples);
|
||||
AfxMessageBox("Anti-aliasing changes will only take effect next time you start LeoCAD.", MB_OK);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "lc_global.h"
|
||||
#include "opengl.h"
|
||||
#include "glwindow.h"
|
||||
#include "system.h"
|
||||
#include "tools.h"
|
||||
#include "resource.h"
|
||||
|
||||
|
@ -342,8 +343,9 @@ bool GLWindow::CreateFromWindow(void* data)
|
|||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
|
||||
int PixelFormat = 0;
|
||||
int AASamples = Sys_ProfileLoadInt("Default", "AASamples", 1);
|
||||
|
||||
if (wglChoosePixelFormatARB)
|
||||
if (wglChoosePixelFormatARB && AASamples > 1)
|
||||
{
|
||||
// Choose a Pixel Format Descriptor (PFD) with multisampling support.
|
||||
int iAttributes[] =
|
||||
|
@ -356,7 +358,7 @@ bool GLWindow::CreateFromWindow(void* data)
|
|||
WGL_STENCIL_BITS_ARB, 0,
|
||||
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
|
||||
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
|
||||
WGL_SAMPLES_ARB, 4,
|
||||
WGL_SAMPLES_ARB, AASamples,
|
||||
0, 0
|
||||
};
|
||||
float fAttributes[] = {0,0};
|
||||
|
|
Loading…
Reference in a new issue