Click here to Skip to main content
13,193,551 members (50,061 online)
Click here to Skip to main content
Add your own
alternative version

Stats

5.3K views
559 downloads
19 bookmarked
Posted 8 Jun 2017

50 OpenGL Win32 Projects in One

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

Download source - 5.1 MB

Download demo - 5.5 MB

Introduction

This article is the continuation of the article last month published with the almost the same name just with one key word replacement. But it is a replacement of fundamental importance. The replacement MFC to Win32 comprehends the great changes in codes. And a lot of people prefer Win32 codes.

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

Background

The sample project provided is based on the old 48 lessons' project of NeHe. Three years ago I've already done the job of adapting the lessons above to MSVS-10 pro Win32. And I've translated the codes "as it was" in MBCS coding one by one. Currently the UNICODE coding is proposed to be used the job seemed 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 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 Win32 in UNICODE coding with the some samples of the Joystick implementation and the samples of using my former CodeProject 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 WIN_GL.exe in the WIN_GLdemo directory has been built with MSVS-2015 pro using the the instruments of MSVS-2010. Therefore, the WIN_GL.exe is valid even for Windows-XP. Distinct from the previous article, demo performance special *.dll files are not required.

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

The WIN_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.

The controls of the WIN_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 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 Ctrl+T);
  • Menu View->Status Bar - show/hide the status bar(also keyboard Ctrl+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 WIN_GL.exe started you may select any other lesson demo to start from the list of the lessons of the dialog box that appears 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)." Currently the present project the special class ClassWinResent has been developed for the Win32 platform.

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 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 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 Box Controls: 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 Box Controls(also double click the left mouse button on the List box 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 and press the 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 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;
  • 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 CodeProject article "Joystick Win32 and Win32 Projects," just with 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 WIN_GLproj\WIN_GLproj\WIN_GLproj.sln file pls take in 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 WIN_GLproj\WIN_GLproj\WIN_GLproj.sln consist or three similiar projects differ just by the degree of building complexity:

  1. WIN_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. WIN_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. WIN_GL- the complete solution requires some External Libruaries installations before the building; the WIN_GL.exe result of this solution presented in WIN_GLdemo directory provided.

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

2.1. Joystick Building Notes (projects WIN_GL1 and WIN_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 longer 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.

Problems may occur using 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 WIN_GL1 with the instruments of MSVS-2010 you must ensure three 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
  • in the Project Property Box in Linker->Input->Additional Dependicies select Change command and install hid.lib (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 WIN_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 WIN_GL with the Lesson 43 you must ensure four 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
  • in the Project Property Box in Linker->Input->Additional Dependicies select Change command and install freetype.lib.
  • in the root directory of the application the FreeType6.dll and zlib.dll files to be inserted.

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 WIN_GL with the Lesson 47 you must ensure three 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
  • in the root directory of the application the Cg.dll and CgGL.dll files to be inserted.

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 the modern Win32 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 WIN_GLproj\WIN_GL\WIN_GL.sln. While adaptating the code 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 Win32 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 glance 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 WIN_GL0, WIN_GL1, WIN_GL have similiar structure just Properties Box installations differ. Therefore Source, Data and Info storage are almost the same.

3.1. WIN_GLproj\WIN_GL\WIN_GL

Source codes in WIN_GLproj\WIN_GL\WIN_GL path have been created with the standard Win32 Application Wizard:

  • WIN_GL.cpp - defines the standard Win32 procedures for the application; HanldleCmdLine, InitGLWindow procedures and WndGLProc modification -inserted by the author;
3.2. WIN_GLproj\NeHeDrawInit

Source XX_*DrawInit.cpp codes (XX in range 01-48) in the WIN_GLproj\NeHeDrawInit path have been borrowed from original NeHe site and modified by the author for UNICODE coding in Win32 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.

Just a few changes have been done in XX_*DrawInit.cpp codes from previous article due to the plarfom change from MFC to Win32.

3.3. WIN_GLproj\NeHeProgs

Special source codes for the separate lessons in the WIN_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 Win32 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 WIN_GLproj\NeHeProgs\X4_Spec and in the WIN_GLproj\NeHeProgs\X5_Spec developed by the author.

Just a few changes have been done in Special source codes files from previous article due to the plarfom change from MFC to Win32;

3.4. WIN_GLproj\GlobUse

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

  • 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;
  • JoystickWin32Dlg.cpp, JoystickHelpDlg.cpp, ClassWinResent - 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;

Just a few changes has been made in GlobDrawGL.cpp from previous article due to the plarfom change from MFC to Win32; all the other files have been developed new for Win32 platform(nothing special just routine).

3.5. WIN_GLproj\Data

Data files for the separate lessons in the WIN_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 WIN_GLproj\Data\X4_Data and in the WIN_GLproj\Data\X5_data created by the author.

Nothing changed in Data Files from the previuos article.

3.6. WIN_GLproj\HelpTextt

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

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

Nothing changed in ReadMe texts from the previuos article.

3.7. WIN_GLproj

Resouce files WIN_GLproj path have been created borrowed from the previous article with a few changes regarding the name of the application:

  • WIN_GL.rc and resource.h - menu, dialog, accelerator resources created by the author using the standard Resource Wizard procedures;

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. Windows initialization in Win32 platform

The standard MFC Application Wizard provides both CMainFrame and CChildWindow windows. The standard Win32 Application Wizard provides just one window template.

Therefore, the InitGLWindow procedure has been inserted by the author into the standard Initinstance procedure:

 BOOL InitGLWindow(void)                           //initialization of the Child GL Window
{
	_tgetcwd(m_rootDir, _MAX_PATH);          //Get root path of the application 
	SummaryListLessons();                    //Create List of Lessons available
	InitClassUseResent();			 //Initialization of the MRU lessons handling	
	InitMRU(m_hMainWnd);                     //Search for resently called lessons  

	while (hTool == NULL)			 //Tool Bar and Status bar initialization 
		CreateToolBar(m_hMainWnd);
		ShowToolStatus();

	RECT rect;
	GetWindowRect(m_hMainWnd, &rect);       //Initial sizes od the Main Frame
	m_boxWidth = rect.right - rect.left;
	m_boxHeight = rect.bottom - rect.top;

	//Create Child window handle m_hGLwnd:
	if (!CreateChildWindow(_T(""), m_boxWidth, m_boxHeight, m_bits, fullscreen))
		return FALSE;

	//GL window creation(borrowed from NeHe samples);
	if (!CreateGLWindow(m_bits, m_boxWidth, m_boxHeight))
		return FALSE;                  // Quit If Window Was Not Created

	return TRUE;
}

In MFC platform the procedures of adjusting of the Main Frame , Child window, Tool Bar, Status Bar are embedded in building process.

In Win32 platform special procedures required for adjusting of the Main Frame , Child window, Tool Bar, Status Bar with the WM_SIZE message in the WndProc :

case WM_SIZE:
	WndGLProc(hWnd, message, wParam, lParam);
	AdjustChildToRect();         //Adjusting Child GL window sizes to the Main Frame
	break;
4.2. 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 while initialization procedure InitGLWindow. 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.3. Init Application

Initialization procedure to be called in the procedure CreateGLWindow:

if (!InitGL())                    // Initialize Our Newly Created GL Window
{
	KillGLWindow();	          // Reset The Display
	MessageBox(NULL, _T("Initialization Failed."), _T("ERROR"),MB_OK|MB_ICONEXCLAMATION);
	exit(0);
}

InitGL 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 the Glaux.lib library from all the lessons used for the texture initialization. Nevertheless, I hope the authors of the original code will not complain. Surely they could not expect MS VS developers that the 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.4. Resize GL Window

Procedure ResizeGLScene common to all the lessons to be called with the WM_SIZE message in the WndGLProc :

case WM_SIZE:                                            // Resize The OpenGL Window
{
	ReSizeGLScene(LOWORD(lParam), HIWORD(lParam));  // LoWord=Width, HiWord=Height
	return 0;                                       // Jump Back
}

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
int m_boxWidth = 800;       //GL winow width 
int m_boxHeight = 600;      //GL window height

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_bOrtho)
	 glOrtho(0.0f,width,height,0.0f,-1.0f,1.0f);	// Create Ortho (0,0 At Top Left)
else                                            	// Calculate The Aspect Ratio Of The Window
	gluPerspective(fViewAngle,(GLfloat)width/(GLfloat)height,fNearPlane,fFarPlane);
4.5. Draw GL Scene

OpenGL drawing procedure to be called with the WM_PAINT message in the WndGLProc :

case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(m_hGLwnd, &ps);
	    DrawGLScene();
        EndPaint(m_hGLwnd, &ps);
    }
    break;

DrawGLScene 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 NeHeDrawInit\XX_*DrawInit.cpp. These drawing procedures have been borrowed from the NeHe site. I've tried not to change these codes as much as possible.

4.6. Messages Handling

Keyboard procedures handling to be called with the WM_KEYDOWN and WM_KEYUP messages in the WndGLProc :

case WM_KEYDOWN:                            // Is A Key Being Held Down?
{
		HandleKeyboard(int(wParam));        //Key code handling
		return 0;                           // Jump Back
}
case WM_KEYUP:                              // Has A Key Been Released?
	{
		ProcessKeyUpN(int(wParam));
		return 0;                   // Jump Back
	}

ProcessKeyboard 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 keyboard 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 Mouse procedures handling to be called with the WM_MOUSEMOVE, WM_LBUTTONDOWN and WM_RBUTTONDOWN messages in the WndGLProc :

case WM_MOUSEMOVE:
{
	POINT point = { LOWORD(lParam), HIWORD(lParam) };
	mouse_x = point.x;
	mouse_y = point.y;
	isClicked = (LOWORD(wParam) & MK_LBUTTON) ? true : false;
	isRClicked = (LOWORD(wParam) & MK_RBUTTON) ? true : false;
	MouseMoveN(LOWORD(wParam), point);
}
break;
case WM_LBUTTONDOWN:
{
	POINT point = { LOWORD(lParam), HIWORD(lParam) };
	mouse_x = point.x;
	mouse_y = point.y;
	LButtonDown(mouse_x, mouse_y);
	isClicked = TRUE;
}
break;
case WM_RBUTTONDOWN: isRClicked = TRUE; break;

MouseMoveN, LButtonDown mouse commands handling procedures (located in GlobUse\GlobDrawGL.cpp) refer to the mouse handling procedures MouseMove_XX, LButtonDown_XX of the current lesson located in 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 with the WM_TIMER message in the WndGLProc :

case WM_TIMER:
if (m_bPlay)
switch (LOWORD(wParam))
{
case ID_TIMER:
		::UpdateScene();
		DrawGLScene();
		break;
}
break;

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

4.7. 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:

case ID_APP_EXIT:
    Deinitialize();
    KillGLWindow();
    DestroyWindow(hWnd);
break;

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 much as possible.

The procedure KillGLwindow is common to all the lessons and located in the 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 WIN_GL and WIN_GL1. In the project WIN_GL0 the Joystick functions are not available. Next two steps require to make WIN_GL0 working with the Joystick as in WIN_GL1:

  • select menu Project->Add Existing Item... and insert GlobUse\JoystickWin32Dlg.cpp and GlobUse\JoystickHelpDlg.cpp into Solution Explorer window;
  • open WIN_GL0\WIN_GL0\SetName.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 with the WM_INPUT message in the JoystickWin32Dlg.cpp.

HandleJoystickN procedure for Joystick Controls handling (located in GlobUse\GlobDrawGL.cpp) refers to the procedure HandleJoystick_XX of the current lesson located in 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 WIN_GL0 and WIN_GL1.

Next two steps require to make them available in the project WIN_GL1 as in WIN_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 WIN_GL1\WIN_GL1\SetName.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 these projects, rename it with the project of my former CodeProject 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 Win32 MSVS 2015 and their instructions are still valid just with a very few corrections.

The advantages of the Win32 projects over MFC projects of the previous article:

  • less sizes of the applications;
  • faster work of the progs;
  • Windows XP applications do not require special *.dll files;
  • the codes of Win32 platform almost compatible with the Mobile applications codes.

The advantage of the MFC projects of the previous article over the present Win32 projects is that dialogs, messages and tools handling are less labor-consuming.

History

The precursor of this article has been published on the CodeProject in 2014: "Concentration of all The Lessons in Common Win32 Project." After that I have published some five or six articles on CodeProject and most of them also became the precursors to the present article.

I think that the present article and codes are more euphemistical for the progs development.

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

 
QuestionDont I feel silly Pin
dekaya12-Jun-17 19:34
memberdekaya12-Jun-17 19:34 
QuestionWhere is the older article you reference Pin
dekaya12-Jun-17 19:32
memberdekaya12-Jun-17 19:32 

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
Web03 | 2.8.171018.2 | Last Updated 9 Jun 2017
Article Copyright 2017 by Petrov Vladimir
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid