Click here to Skip to main content
15,868,088 members
Articles / Desktop Programming / MFC

50 OpenGL MFC Projects in One

Rate me:
Please Sign up or sign in to vote.
5.00/5 (25 votes)
10 May 2017CPOL19 min read 47.9K   6.3K   52   17
Former NeHe OpenGL Lessons adapted to MSVS-15 pro MFC in INICODE and the samples of the Joystick implementation

Image 1

Introduction

With the continued development of modern 3D technologies, sometimes it is worth refreshing your memory about some base points. And sometimes, some of the impressive 3D effects of the modern 3D graphic oriented systems may be achieved with the slender means of the base technologies treated as deprecated.

This article is to demonstrate some samples of the good old-fashioned 20-years old projects working in the modern MSVS-15 MFC and Windows-10 environment.

Background

The sample project provided based on the old 48 lessons' project of NeHe. Some three years ago, I've already done the job of the adaptation the lessons above to MSVS-10 pro MFC. And I've translated the codes "as it was" in MBCS coding one by one. As far as now the UNICODE coding is proposed to be used, the job seemed as not completely executed. And there is no need to develop the project particularly for every lesson. The flow chart scheme is common to all OpenGL projects, therefore, it is worth developing one common project for all the lessons in demo purposes.

And now, I have some time to present this solution for MSVS-15 pro MFC in UNICODE coding with some samples of the Joystick implementation and the samples of using my former CodeProject articles.

Before you start building the project provided, it is highly recommended to have a look at the demo presentation enclosed in order to get an idea of the output expected.

1. Demo Explanations

1.1. Executable Handling

The executable MFC_GL.exe in the MFC_GLdemo directory has been built with MSVS-2015 pro using the instruments of MSVS-2010. Therefore the MFC_GL.exe is valid even for Windows-XP. Just if you want to start in Windows-XP, please do not forget to insert mfc100.dll, mfc100u.dll, msvcp100.dll, msvcr100.dll files into the MFC_GLdemo directory (or into the ..windows\system32 directory).

The MFC_GL.exe may be started without any arguments. In this case, the presentation of the last former called lesson appeared.

The MFC_GL.exe XX may be started in the command line with the two-symbols argument as follows : 01-48, X4, X5. In this case, the presentation of the corresponding lesson appeared.

Here and elsewhere, XX means two-symbols string:

  • (01-48) - the order numbers of the lessons in the NeHe tutorial
  • (X4,X5) - the numbers of the lessons published by the author on the Russian NeHe site

Image 2

The controls of the MFC_GL.exe are as follows:

  • Menu File->Lesson... - calling the Select Lesson Dialog (also keyboard Ctrl+O)
  • Menu File->Play - play/stop current lesson presentation (also keyboard Ctrl+P)
  • Resent File - calling the Select Lesson Dialog with the list box line selected in the resent lesson called corresponding
  • Menu File->Exit - exit application (also keyboard Alt+F4 (exit immediately) or keyboard Esc (with the confirmation required) )
  • Menu View->Full Screen - install/demount current lesson full screen performance (also keyboard Ctrl+Enter)
  • Menu View->Language->Russian - adjusting Lessons' Titles in Russian
  • Menu View->Language->English - adjusting Lessons' Titles in English
  • Menu View->ToolBar - show/hide the toolbar (also keyboard Alt+T)
  • Menu View->Status Bar - show/hide the status bar (also keyboard Alt+S)
  • Menu View->Next Scene - next scene of the current lesson presentation if stopped (also keyboard Ctrl+N)
  • Menu View->Joystick Test - calling the Joystick Test Dialog if applicable (lessons 09, 10, 32, 40, X4, X5) (also keyboard Ctrl+J)
  • Menu Help->About... - calling the About Dialog (also keyboard Ctrl+A)
  • Menu Help->Help Dialog... - calling the Help Dialog (also keyboard F1)
  • Menu Help->Joystick Help.. - calling the Joystick Help Dialog if applicable (lessons 09, 10, 32, 40, X4, X5) (also keyboard Ctrl + Y)

Once MFC_GL.exe is started, you may select any other lesson demo to start from the list of the lessons of the dialog box appeared with the menu command File->Open... (or keyboard Ctrl + O).

Please note that the Recent file system is an alternative to the standard MS VS one and based on my CodeProject article "Your Own Resent File List(s)".

1.2. Lesson Select Dialog

Image 3

The Lesson Select Dialog to be called with the Menu File->Lesson... command (also keyboard Ctrl+O).

The controls of the Lesson Select Dialog are as follows:

  • List Box Control: presenting the list of the lessons' names available
  • Ok Button: starting the lesson selected in the List Box Control (also double click the left mouse button on the List Box Control line corresponding)
  • New Window Check Box: if selected, the new lesson presentation starting in the new window (current lesson remaining unchanged); otherwise new lesson starting in the same window as the current one instead
  • English Radio Button: adjusting Lessons' Titles in English
  • Russian Radio Button: adjusting Lessons' Titles in Russian
  • Cancel Button: just close the dialog

1.3. Help Using

Image 4

The Help Dialog to be called with the Menu Help->Help Dialog command (or keyboard F1). The most of keyboard and mouse commands remain the same as per original lessons corresponding from NeHe site.

The controls of the Help Dialog are as follows:

  • List Control: presenting the list of the keyboard and/or mouse commands for the current lesson presentation available
  • Ok Button: executing the command selected in the Control Column of the List Control (also double click the left mouse button on the List Control line corresponding)
  • Joystick Help Button: calling the Joystick Help Dialog if applicable (lessons 09, 10, 32, 40, X4, X5)

The Help Dialog is unmodal, therefore it is possible both to use the keyboard commands listed or to select the command from the List Control an press Ok button (or double click mouse left button).

1.4. About Dialog

With regards to the respected authors of the original code, the About Dialog (Menu Help->About...) contains the original NeHe's ReadMe texts:

Image 5

1.5. Joystick Using

The Joystick using is available in lessons 09, 10, 32, 40, X4, X5. You may adjust the Joystick yourself to any other lesson (or in some projects of your own) with the Joystick implementation instructions enclosed.

The Joystick functionality may be tested with the Menu View->Joystick Test command (or keyboard Ctrl+J or button 8 on the Joystick itself) with the Joystick Test Dialog (where applicable).

Image 6

The controls of the Joystick Test Dialog are as follows:

  • 1-12 Check Boxes: checking if the Joystick button corresponding is pressed
  • Unnumerated Check Boxes: checking if the Joystick Hatch button corresponding is pressed
  • Left Picture Control: presenting the Cross position coordinates for bending the Joystick handle port-starboard and forward-aft
  • Right Picture Control: presenting the Cross position coordinates for turning the Joystick handle port-starboard and the Joystick acceleration toggle forward-aft
  • On-Off Radio Buttons: presenting the conditions of the Joystick to be connected

While the Joystick Test Dialog is visible, all the Joystick commands are valid just for this dialog only and for the application itself, the Joystick commands are not available.

Please note that the Joystick Test Dialog is based on my CodeProject article "Joystick Win32 and MFC Projects", just Picture Control removed.

The help on the Joystick for the lessons affected to be obtained with Menu Help->Joystick Help Dialog command (or keyboard Ctrl+Y or Joystick help button in the Help dialog) with the Joystick Help dialog (where applicable).

Image 7

The Joystick Help Dialog is unmodal, therefore it is possible both to use the Joystick commands listed or to select the command from the list an press Ok button (or double click mouse left button at the line corresponding).

2. Important Building Notes

Before you start to build all the projects with the menu Project->Build Solution with the MFC_GLproj\MFC_GL\MFC_GLset.sln file, please take into consideration some important notes.

Solution configuration must be installed as Release and the platform to be X86.

The default coding property is UNICODE; nevertheless MBCS coding is also available, just change the property.

Please note that the solution MFC_GLproj\MFC_GL\MFC_GLset.sln consists of three similar projects that differ just by the degree of building complexity:

  1. MFC_GL0 - the simplest project which may be built by the people without any experience of MSVS coding; this project is without Joystick and Lessons 43 and 47;
  2. MFC_GL1 - the solution requires some Property Box installations before the building; this solution is with the Joystick but without the Lessons 43 and 47;
  3. MFC_GL- the complete solution requires some External Libraries installations before the building; the MFC_GL.exe result of this solution presented in MFC_GLdemo directory provided.

Even if you are working for the first time with MSVS, just appoint the MFC_GL0 project as StartUp project (right mouse button click -> menu Set as StartUp Project) and select menu Debug->Start without debugging and the program MFC_GL0.exe should start building and working.

2.1. Joystick Building Notes (Projects MFC_GL1 and MFC_GL)

The project provided has been developed with MSVS-2015 pro using the instruments of MSVS-2010. Therefore, the EXE files are valid even for Windows-XP.

If you do not need to run the application in Windows-XP, just change the instruments to MSVS-2015 and no problems with the Joystick procedures building will occur.

The problems may occur with using the instruments of MSVS-2010 with the Joystick implementation. The problem is that external library hid.lib is used.

Before you start to build the project MFC_GL1 with the instruments of MSVS-2010, you must ensure two things in the project concerned:

  • In the Project Property Box in Configuration Properties->VC++Directories->Include Directories, select Change command and set directory to ..\Windows Kits\8.1\Include\shared (just for #include <hidsdi.h> command to use)
  • In the Project Property Box in Configuration Properties->VC++Directories->Library Directories, select Change command and set directory to ..\Windows Kits\8.1\Lib\winv6.3\um\x86 (or you may insert the library hid.lib directly with the menu PROJECT->Add Existing Item from the directory ..\Windows Kits\8.1\Lib\winv6.3\um\x86\hid.lib).

2.2. Lessons 43 and 47 Building Notes (Project MFC_GL)

Lesson 43 requires the external library of freetype.lib which requires the installation of the Program Files\GnuWin32 directory (17.8 MB) from the http://gnuwin32.sourceforge.net/packages/freetype.htm link.

Before you start building the project MFC_GL with Lesson 43, you must ensure two things in the project concerned:

  • In the Project Property Box in Configuration Properties->VC++Directories->Include Directoriesselect Change command and set directory to ..\GnuWin32\include\freetype2
  • In the Project Property Box in Configuration Properties->VC++Directories->Library Directoriesselect Change command and set directory to ..\GnuWin32\lib

Lesson 47 requires the external libraries of cg.dll and cgGL.dll which require the installation of the Program Files\NVIDIA Corporation directory (596 MB) from https://developer.nvidia.com/cg-toolkit-download.

Before you start building the project MFC_GL with Lesson 47, you must ensure two things in the project concerned:

  • In the Project Property Box in Configuration Properties->VC++Directories->Include Directories, select Change command and set directory to ..\NVIDIA Corporation\Cg\include
  • in the Project Property Box in Configuration Properties->VC++Directories->Library Directories, select Change command and set directory to ..\NVIDIA Corporation\Cg\lib

3. Project Source, Data and Info Storage

The original projects of MS Studio .NET (Grant James, 2002) are located on the NeHe GameDev site, but not adopted to Microsoft Foundation Classes (MFC) and to the latest versions of MSVS. I’ve adopted all the codes of the lessons one by one and also integrated them in one common project MFC_GLproj\MFC_GL\MFC_GL.sln. While adaptation of the codes, I found a lot of conflicts occurred in projects modification from one version of MS Visual Studio to another. Finally, for demonstration purposes, I’ve developed the project in UNICODE coding in MFC MSVS-15 pro environment with the instruments of MSVS-10.

You may select in the Solution Explorer window any *.h or *.cpp file and you may look at and edit it. At first sight, it seemed that there are too many files enclosed but further consideration shows that everything is not too much complicated. The project consists of the common procedures and special procedures for every lesson implementation.

All three projects, MFC_GL0, MFC_GL1, MFC_GL have similar structure, just Properties Box installations differ. Therefore Source, Data and Info storage are almost the same.

3.1. MFC_GLproj\MFC_GL

Source codes in MFC_GLproj\MFC_GL\MFC_GL path have been created with the standard MFC Application Wizard:

  • MFC_GL.cpp - defines the standard class behaviors for the application; Command Line Param Handling -inserted by the author
  • MainFrm.cpp - implementation of the standard CMainFrame class; HideMenu and ShowMenu procedures - appended by the author
  • ChildView.cpp - implementation of the standard CChildView class; messages handling procedures created by the author using standard MFC Application Wizard procedures
  • MFC_GL.rc and resource.h - menu, dialog, accelerator resources created by the author using the standard Resource Wizard procedures

3.2. MFC_GLproj\NeHeDrawInit

Source XX_*DrawInit.cpp codes (XX in range 01-48) in the MFC_GLproj\NeHeDrawInit path have been borrowed from original NeHe site and modified by the author for UNICODE coding in MFC MSVS-15 pro environment. I've tried not to change these codes as far as possible.

X4_UFOGameDrawInit.cpp combined by the author from the original lessons 07, 11, 30, 32, 34 for demo purposes.

X5_BoxmanDrawInit.cpp developed by the author for demo purposes.

3.3. MFC_GLproj\NeHeProgs

Special source codes for the separate lessons in the MFC_GLproj\NeHeProgs\XX_Spec paths (XX in range 01-48)have been borrowed from original NeHe site and modified by the author for UNICODE coding in MFC MSVS-15 pro environment. I've tried not to change these codes as far as possible.

Special source codes for the lessons X4 and X5 in the MFC_GLproj\NeHeProgs\X4_Spec and in the MFC_GLproj\NeHeProgs\X5_Spec developed by the author.

3.4. MFC_GLproj\GlobUse

Source codes in MFC_GLproj\GlobUse path have been developed by the author based on the standard MFC Application Wizard technologies:

  • GlobMyProc.cpp, GLRoutine.cpp - compulsory to be used in the project
  • GlobTexture.cpp - to be used in GL Texture procedures (instead of former Glaux.lib library used in original projects)
  • DlgAbout.cpp, DlgHelp.cpp, DlgLesson.cpp, DlgTitle.cpp - appended for demo purposes only by the author and are not compulsory for the main project implementation
  • JoystickMFCDlg.cpp, JoystickMFCHelpDlg.cpp - appended for demo purposes by the author for Joystick use demonstration only and are not compulsory for the main projects implementation
  • GlobDrawGL.cpp - created for demo purposes only by the author for external links between the project and separate lesson and is not compulsory for the main project implementation
  • MFC_GL.rc and resource.h - menu, dialog, accelerator resources created by the author using the standard Resource Wizard procedures

3.5. MFC_GLproj\Data

Data files for the separate lessons in the MFC_GLproj\Data\XX_Data paths (XX in range 06-47) have been borrowed from the original NeHe site.

Data files for the lessons X4 and X5 in the MFC_GLproj\Data\X4_Data and in the MFC_GLproj\Data\X5_data created by the author.

3.6. MFC_GLproj\HelpTextt

Help texts for the separate lessons in the MFC_GLproj\HelpText\XX_GLhelp.txt and MFC_GLproj\HelpText\XX_JoystickHelp.txt files have been created by the author to be used in codeDlgHelp.cpp, JoystickMFCHelpDlg.cpp. in DlgHelp dialog and in DlgJoystickHelp dialog.

ReadMe texts for the separate lessons in the MFC_GLproj\HelpText\ReadMe\ReadMe_XX.txt and MFC_GLproj\HelpText\XX_JoystickHelp.txt files have been borrowed from the original NeHe site to be used in DlgAbout dialog.

4.Code Explanation

The control flow-chart of the standard OpenGL application with the steps numerated as per items of the sections accordingly.

4.1. Create GL Window

The procedure CreateGLwindow is common to all the lessons and located in GLRoutine.cpp file in the common GlobUse directory.

The procedure CreateGLWindow to be called by virtual procedure OnCreate:

C#
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	CreateGLWindow(this, 32);             //borrowed from NeHe site; 
                                          //located in GlobUse\GLRoutine.cpp
	_tgetcwd(m_rootDir, _MAX_PATH);       //root directory identification
	CreateListLessons();                  //list box of DlgLesson dialog content; 
                                          //located in GlobUse\GLRoutine.cpp
	m_bPlay = TRUE;                       //flag of autoplay
  	SetTimer(ID_TIMER_PLAY, 15, NULL);    //timer of the scene to change in 15 milliseconds
	return 0;
}

The CreateGLWindow procedure almost completely has been borrowed from the original NeHe lessons and as much as possible, I've tried not to change the authoring codes.

4.2. Init Application

Initialization procedure to be called by the procedure CChildView::InitChildView:

C#
void CChildView::InitChildView(void)
{
	m_bInitGL = FALSE;          //initialization flag
	m_pView = this;             //identification of the window 
                                //to be called in global procedures
	InitMRU();                  //initialization of the resent lessons list
	InitGLn(m_strNum);          //initialization of the OpenGL window
                                //(located in GlobUse\GlobDrawGL.cpp)
	//Main Frame Text:
	GetMainFrameGlob->SetWindowText( CString(AfxGetApp()->m_pszAppName) + 
                        _T(" : ") + (m_strLesson = GetLessonName(m_strNum)));
}

InitGLn initialization of the OpenGL window procedure (located in GlobUse\GlobDrawGL.cpp) refers to the initialization procedure InitGL_XX(GLvoid) of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These initialization procedures have been borrowed from the NeHe site. I've tried not to change these codes as far as possible.

The only big difference is that I've taken the liberty to exclude Glaux.lib library from all the lessons used for the texture initialization. Nevertheless, I hope the authors of the original codes will not complain. Sure, they could not expect from MS VS developers that Glaux.lib library to be excluded from 10th version onwards. And if it is still possible to include Glaux.lib in the MS VS 10th version, in the 11th version it is not working.

The procedures for the texture initialization instead of Glaux.lib are located in the Globuse\GlobTexture.cpp. The instructions for the texture initialization may be obtained from my former CodeProject articles "Texture Mapping in OpenGL using Class CImage" and "Masking Texture in OpenGL using Class CImage".

4.3. Resize GL Window

Procedure ResizeGLScene common to all the lessons to be called by virtual procedure OnSize:

C#
void CChildView::OnSize(UINT nType, int cx, int cy)
{
	CWnd::OnSize(nType, cx, cy);
	ReSizeGLScene(cx, cy);        //base borrowed from NeHe site; 
                                  //located in GlobUse\GLRoutine.cpp
	SetTitlePos();                //title of the lesson  in Main Frame and in Full Screen mode
}

In distinct from the NeHe original base some global variables inserted:

C#
GLfloat  fNearPlane = 0.1f, //Frustum Near Plane
         fFarPlane = 100.f, //Frustum Far Plane
         fViewAngle = 45.f, //Frustum View Angle
	     fAspect;           //Frustum Width/Height ratio
RECT m_viewRect;            //current View rect size in pixel

In some lessons (30,31,34,36,44,45,46,X4), the Frustum values set differ from default ones in the InitGL_XX procedure.

In lessons 21 and 24, the glOrtho presentation is used:

C#
if(m_strNum == _T("21")||m_strNum == _T("24"))
	 glOrtho(0.0f,width,height,0.0f,-1.0f,1.0f);    // Create Ortho widthxheight View 
                                                    // (0,0 At Top Left)
else	                                            // Calculate The Aspect Ratio Of The Window
	gluPerspective(fViewAngle,(GLfloat)width/(GLfloat)height,fNearPlane,fFarPlane);

4.4. Draw GL Scene

OpenGL drawing procedure to be called by virtual procedure OnPaint:

C#
void CChildView::OnPaint() 
{
	CPaintDC dc(this);               // device context for painting
	if (m_bInitGL)InitChildView();   //Initialization of the GL window if first call
	DrawGLSceneN();                  //Global drawing procedure
	// Do not call CWnd::OnPaint() for painting messages
}

DrawGLSceneN drawing of the OpenGL window procedure (located in GlobUse\GlobDrawGL.cpp) refers to the drawing procedure DrawGLScene_XX(GLvoid) of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These drawing procedures have been borrowed from the NeHe site. I've tried not to change these codes as far as possible.

4.5. Messages Handling

Keyboard procedures handling to be called by virtual procedures OnKeyDown and OnKeyUp:

C#
void CChildView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	ProcessKeyboardN(nChar);                 //Global procedure of nChar handling
	CWnd::OnKeyDown(nChar, nRepCnt, 1nFlags);
}
void CChildView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	VkKeyUpN(nChar, nRepCnt, nFlags);        //Global procedure of nChar handling
	CWnd::OnKeyUp(nChar, nRepCnt, nFlags);
}

ProcessKeyboardN and VkKeyUpN keyboard commands handling procedures (located in GlobUse\GlobDrawGL.cpp) refer to the keyboard procedure ProcessKeyboard_XX(int idKey) and VkKeyUp_XX of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These keyboards commands have been borrowed from the NeHe site. I've tried not to change these commands as far as possible. Just F1 command I've changed for Help performance and Ctrl+Enter command changed to FullScreen Mode handling.

Mouse procedures handling to be called by virtual procedures OnMouseMoveOnLButtonDown and OnRButtonDown:

C#
 void CChildView::OnMouseMove(UINT nFlags, CPoint point)
{
	mouse_x = point.x; mouse_y = point.y;  //global mouse position
	MouseMoveN(nFlags, point);             //Global procedure of Mouse Move handling  
	CWnd::OnMouseMove(nFlags, point);
}
void CChildView::OnLButtonDown(UINT nFlags, CPoint point)
{
	LButtonDownN(nFlags, point);           //Global procedure of Mouse Left Button handling    
	CWnd::OnLButtonDown(nFlags, point);
}
void CChildView::OnRButtonDown(UINT nFlags, CPoint point)
{
	RButtonDownN(nFlags, point);           //Global procedure of Mouse Right Button handling
	CWnd::OnRButtonDown(nFlags, point);
}

MouseMoveN, LButtonDownN and RButtonDownN mouse commands handling procedures (located in GlobUse\GlobDrawGL.cpp) refer to the mouse handling procedures MouseMove_XX, LButtonDown_XX and RButtonDown_XX of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These mouse commands have been borrowed from the NeHe site. I've tried not to change these commands as far as possible.

Timer procedure handling to be called by virtual procedure OnTimer:

C#
void CChildView::OnTimer(UINT_PTR nIDEvent)
{
	switch (nIDEvent)
	{
	case ID_TIMER_PLAY:
		if (!m_bPlay) return; //if not play mode do nothing
		UpdateGLScene();      //Global procedure for one step image change
		DrawGLSceneN();       //Global drawing procedure
		break;
	}
	CWnd::OnTimer(nIDEvent);
}

UpdateGLScene procedure for one step image change (located in GlobUse\GlobDrawGL.cpp) refers to the procedure Update_XX of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These update procedures have been borrowed from the NeHe site. I've tried not to change these procedures as far as possible.

4.6. Kill GL Window

If the new lesson in the Lesson Dialog is selected to start at the same window, the memory must be released and the OpenGL window to be closed. Also, before the application exit also the memory must be released and the OpenGL window to be closed:

C#
    void CChildView::OnAppExit()
{
	DeinitializeN();			//Clear memory
	KillGLWindow(this);			//Close OpenGL window
}

DeinitializeN procedure for clear memory (located in GlobUse\GlobDrawGL.cpp) refers to the procedure Deinitialize_XX of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These clear memory procedures have been borrowed from the NeHe site. I've tried not to change this procedure as far as possible.

The procedure KillGLwindow is common to all the lessons and located in GLRoutine.cpp file in the common GlobUse directory. The KillGLWindow procedure almost completely has been borrowed from the original NeHe lessons and as much as possible, I've tried not to change the authoring codes.

5. Joystick Implementation

Joystick handling is available in lessons 09, 10, 32, 40, X4, X5 in projects MFC_GL and MFC_GL1. In the project MFC_GL0, the Joystick functions are not available. Next two steps require to make MFC_GL0 working with the Joystick as in MFC_GL1:

  • Select menu Project->Add Existing Item... and insert GlobUse\JoystickMFCDlg.cpp and GlobUse\JoystickHelpDlg.cpp into Solution Explorer window
  • Open MFC_GL0\MFC_GL0\SetName0.cpp and put in comments (or just remove) the empty procedure void InitJoystickDlg(void){}.

And that's all (point 2.1 of this article conditions understood). Now the project should be working with the Joystick.

Joystick procedures handling to be called by virtual procedure CJoystickMFCDlg::OnRawInput.

HandleJoystickN procedure for Joystick Controls handling (located in GlobUse\GlobDrawGL.cpp) refers to the procedure HandleJoystick_XX of the current lesson located in the NeHeDrawInit\XX_*DrawInit.cpp. These procedures have been developed by the author for demo purposes. Lesson 40 Joystick handling, e.g.:

C#
    void HandleJoystick_40(int nx, int ny, int nz, int nzr, int nh, 
                           BOOL bButtonStates[], BOOL bButtonPrev[])
{
	ropeConnectionVel = Vector3D(-0.003f*nzr, 0.003f*nx, 0.003f*ny);
}

You may change these existing HandleJoystick_XX codes or create yourself as you like.

6. Exceptions (Lessons 43 and 47)

Lessons 43 and 47 require some External Libraries installations (point 2.2 of this article) and are not available in the projects MFC_GL0 and MFC_GL1.

The next two steps require to make them available in the project MFC_GL1 as in MFC_GL:

  • Select menu Project->Add Existing Item... and insert NeHeDrawInit\43_FreeTypeFontsDrawInit.cpp, NeHeDrawInit\47_CGVertexShaderDrawInit.cpp and NeheProgs\43_Spec\freetype.cpp into Solution Explorer window
  • Open MFC_GL0\MFC_GL0\SetName1.cpp and put in comments (or just remove) all the lines containing strings 43 and/or 47.

And that's all (point 2.2 of this article conditions understood). Now Lessons 43 and 47 are available in the project.

7. Your Own Applications Development Using the Project Provided

The set of lessons provided represents the exciting opportunities for the development of some effective presentations of the applications. These possibilities have been illustrated in the present project with lessons X4 UFOGame (combined by the author from the original lessons 07, 11, 30, 32, 34) and X5 Boxman (demonstrates the possibility to create the performance just with the drawing entities managed by the primitive text files).

You may pick up all this project, rename it with the project of my former CodeProject article "MFC Project from Existing Code in One Click" and combine and improve the code as you like (your references to my code, if any, should be highly appreciated).

Present three projects of the solution provided have been developed one from another just by renaming with the technology above.

Points of Interest and Acknowledgements

The projects above have been developed with the great help of the editor of the Russian site of NeHe Sergey Anisimov whom I thank very much for his kind assistance.

Also, many thanks to the respected authors of the original codes and their perfect instructions in the lessons articles on NeHe site.

They have done their job more than twenty years ago and their programs are still alive in the modern environment of Windows 10 and MFC MSVS 2015. Besides, all these enormous modern graphical systems have been originated from these primitive but effective technologies. And who knows, may be they may be renewed in some alternative graphical systems to be developed and CodeProject is the best platform for that. Sometimes, it is  worth coming back and having a look at how it was in the beginning and may be it was some other way of program development.

History

First, my article on that subject has been published on the GameDev in 2013: "Concentration of all The Lessons in Common Library GLSummary in MFC". Unfortunately, the GameDev community are cynical about MFC and a lot of GameDev people feel something like panic with the words MFC (somebody even called it as a disgust).

After that, I have published some four or five articles on CodeProject and most of them became the precursors to the present article.

The job to be continued.

History

  • 11th May, 2017: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionthis is a great project Pin
Southmountain6-Mar-21 9:14
Southmountain6-Mar-21 9:14 
QuestionCan't download any of the demo Pin
dekaya13-Jun-19 1:45
dekaya13-Jun-19 1:45 
QuestionQuestion About FreeType6.dll Pin
Rick York4-Apr-19 12:11
mveRick York4-Apr-19 12:11 
Questionhow to get vc 2010 work Pin
zeng_liwen14-Jan-19 19:37
zeng_liwen14-Jan-19 19:37 
AnswerRe: how to get vc 2010 work Pin
Petrov Vladimir18-Jan-19 14:44
Petrov Vladimir18-Jan-19 14:44 
QuestionModern OpenGL? Pin
ITISAG20-May-17 2:59
ITISAG20-May-17 2:59 
AnswerRe: Modern OpenGL? Pin
Petrov Vladimir21-May-17 0:35
Petrov Vladimir21-May-17 0:35 
GeneralRe: Modern OpenGL? Pin
ITISAG21-May-17 2:49
ITISAG21-May-17 2:49 
GeneralRe: Modern OpenGL? Pin
Petrov Vladimir22-May-17 4:54
Petrov Vladimir22-May-17 4:54 
QuestionSizes of Additional Downloads Pin
Rick York11-May-17 6:03
mveRick York11-May-17 6:03 
AnswerRe: Sizes of Additional Downloads Pin
Petrov Vladimir11-May-17 13:33
Petrov Vladimir11-May-17 13:33 
GeneralMy vote of 5 Pin
FabricePresident10-May-17 22:44
FabricePresident10-May-17 22:44 
5/5
BugDownload link not working Pin
Bryian Tan9-May-17 13:43
professionalBryian Tan9-May-17 13:43 
GeneralRe: Download link not working Pin
Petrov Vladimir10-May-17 20:32
Petrov Vladimir10-May-17 20:32 
Question*rar not there: maybe *zip? Pin
Member 96773859-May-17 9:54
Member 96773859-May-17 9:54 
AnswerRe: *rar not there: maybe *zip? Pin
Petrov Vladimir10-May-17 20:34
Petrov Vladimir10-May-17 20:34 
PraiseRe: *rar not there: maybe *zip? Pin
Bryian Tan11-May-17 2:52
professionalBryian Tan11-May-17 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.