Click here to Skip to main content
13,249,087 members (39,143 online)
Click here to Skip to main content
Add your own
alternative version

Stats

9.5K views
1K downloads
26 bookmarked
Posted 9 May 2017

50 OpenGL MFC Projects in One

, 10 May 2017
Rate this:
Please Sign up or sign in to vote.
Former NeHe OpenGL Lessons adapted to MSVS-15 pro MFC in INICODE and the samples of the Joystick implementation

Introduction

With the continued development of modern 3D technologies, sometimes it is worth refreshing your memory about some base points. And sometimes some the impressive 3D effects of the mordern 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 seamed as not completely executed. And there is no need to develop the project paticularly for every lesson. The flow chart scheme is common to all OpenGL projects, therefore, it is worth to develop 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 the some samples of the Joystick implementation and the samples of using my former Code Project articles.

Before you start bulding the project provided it is highly recommended to have a look to 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 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 pls 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 lesson corresponding 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 publicated by the author on the Russian NeHe site.

The controls of the MFC_GL.exe 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 immediatly) 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).

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

1.2. Lesson Select Dialog

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

The controls of the Lesson Select Dialog 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 leesson 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

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

The controls of the Help Dialog as follows:

  • List Control:presenting the list of the keyboard and/or mouse commands for the current lesson presentation available;
  • Ok Button: excuting 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 the regards to the respected authors of the original code, the About Dialog (Menu Help->About...) contains the original NeHe's ReadMe texts:

 

1.5.Joystick Using.

The Joystick using is available in the 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 inctructions 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).

 

The controls of the Joystick Test Dialog 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;
  • Lelt Picture Control: presenting the Cross position coordinates for bending the Joystick handle port-starboard and foarward-aft;
  • Right Picture Control: presenting the Cross position coordinates for turning the Joystick handle port-starboard and the Joystick acceleration toggle foarward-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 Code Project 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).

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 also available just change the property.

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

  1. MFC_GL0 - the simpliest 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 Libruaries installations before the building; the MFC_GL.exe result of this solution presented in MFC_GLdemo directory provided.

Even if you are first time working with MSVS just appoint the MFC_GL0 project as SatrtUp 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 the instruments of MSVS-2010. Therefore, the exe files are valid even for Windows-XP.

If you no need to run the application in Windows-XP just change the instruments to MSVS-2015 and no problems with the Joystick procedures building to be occurred.

The problems may be occurred with the using the the instruments of MSVS-2010 with the Joistick implementation. The problem is that external libruary hid.lib 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->Libruary Directories select Change command and set directory to ..\Windows Kits\8.1\Lib\winv6.3\um\x86 (or you may insert the libruary 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)

The lesson 43 requires the external libruary 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 to build the project MFC_GL with the Lesson 43 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 ..\GnuWin32\include\freetype2
  • in the Project Property Box in Configuration Properties->VC++Directories->Libruary Directories select Change command and set directory to ..\GnuWin32\lib

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

Before you start to build the project MFC_GL with the 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->Libruary 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 in demonstration purpose 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 the 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 pocedures and special procedures for every lesson implementation.

All three projects MFC_GL0, MFC_GL1, MFC_GL have similiar 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 combied by the author from the original lessons 07, 11, 30, 32, 34 in Demo purposes.

X5_BoxmanDrawInit.cpp developed by the author in 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 libruary used in original projects);
  • DlgAbout.cpp, DlgHelp.cpp, DlgLesson.cpp, DlgTitle.cpp - appended in demo purposes only by the author and are not compulsory for the main project implementstion;
  • JoystickMFCDlg.cpp, JoystickMFCHelpDlg.cpp - appended in demo purposes by the author for Joystick use demonstration only and are not compulsory for the main projects implementstion;
  • GlobDrawGL.cpp - created in 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.Codes explanations.

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

 

4.1. Greate 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:

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:

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 took 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 Code Project 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:

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:

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 the lessons 21 and 24 the glOrtho presentation used:

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:

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:

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 perfomance and Ctrl+Enter command changed to FullScreen Mode handling .

Mouse procedures handling to be called by virtual procedures OnMouseMove ,OnLButtonDown and OnRButtonDown:

 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:

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:

    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 available in the 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 to 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 in Demo purposes. Lesson 40 Joystick handling e.g.:

    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 Libruaries installations(point 2.2 of this article) and are not available in the projects MFC_GL0 and MFC_GL1.

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 the 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 possibilites have been illustrated in the present project with the 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 Code Project article "MFC Project from Existing Code in One Click" and combine and improve the codes as you like ( your references to my codes 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 Acknowlegements

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 there 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 Code Project is the best platform for that. Some times worth to come back and have a look how it was in the begining 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". Unfortunatly the GameDev community are cynical about MFC and a lot of GameDev people feel something like panic with the words MFC(somebody called it even as a disgust).

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

The job to be continued.

License

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

Share

About the Author

Petrov Vladimir
Russian Federation Russian Federation
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionModern OpenGL? Pin
ITISAG20-May-17 3:59
memberITISAG20-May-17 3:59 
AnswerRe: Modern OpenGL? Pin
Petrov Vladimir21-May-17 1:35
memberPetrov Vladimir21-May-17 1:35 
GeneralRe: Modern OpenGL? Pin
ITISAG21-May-17 3:49
memberITISAG21-May-17 3:49 
GeneralRe: Modern OpenGL? Pin
Petrov Vladimir22-May-17 5:54
memberPetrov Vladimir22-May-17 5:54 
QuestionSizes of Additional Downloads Pin
Rick York11-May-17 7:03
memberRick York11-May-17 7:03 
AnswerRe: Sizes of Additional Downloads Pin
Petrov Vladimir11-May-17 14:33
memberPetrov Vladimir11-May-17 14:33 
GeneralMy vote of 5 Pin
FabricePresident10-May-17 23:44
memberFabricePresident10-May-17 23:44 
BugDownload link not working Pin
Bryian Tan9-May-17 14:43
professionalBryian Tan9-May-17 14:43 
GeneralRe: Download link not working Pin
Petrov Vladimir10-May-17 21:32
memberPetrov Vladimir10-May-17 21:32 
Question*rar not there: maybe *zip? Pin
Member 96773859-May-17 10:54
memberMember 96773859-May-17 10:54 
AnswerRe: *rar not there: maybe *zip? Pin
Petrov Vladimir10-May-17 21:34
memberPetrov Vladimir10-May-17 21:34 
PraiseRe: *rar not there: maybe *zip? Pin
Bryian Tan11-May-17 3:52
professionalBryian Tan11-May-17 3: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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171114.1 | Last Updated 11 May 2017
Article Copyright 2017 by Petrov Vladimir
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid