Merge pull request #3141 from malortie/sample-simpletexturedogl-nullptr
Replaced NULL with nullptr for pointers in sample SimpleTexturedOpenGL.pull/3109/head
commit
3d95e75774
|
@ -66,7 +66,7 @@ GLfloat LightPosition[]= { 0.0f, 0.0f, 15.0f, 1.0f };
|
||||||
|
|
||||||
|
|
||||||
// the global Assimp scene object
|
// the global Assimp scene object
|
||||||
const aiScene* g_scene = NULL;
|
const aiScene* g_scene = nullptr;
|
||||||
GLuint scene_list = 0;
|
GLuint scene_list = 0;
|
||||||
aiVector3D scene_min, scene_max, scene_center;
|
aiVector3D scene_min, scene_max, scene_center;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ bool Import3DFromFile( const std::string& pFile)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox(NULL, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(nullptr, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
logInfo( importer.GetErrorString());
|
logInfo( importer.GetErrorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ void freeTextureIds()
|
||||||
if (textureIds)
|
if (textureIds)
|
||||||
{
|
{
|
||||||
delete[] textureIds;
|
delete[] textureIds;
|
||||||
textureIds = NULL;
|
textureIds = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
while (texFound == AI_SUCCESS)
|
while (texFound == AI_SUCCESS)
|
||||||
{
|
{
|
||||||
texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path);
|
texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path);
|
||||||
textureIdMap[path.data] = NULL; //fill map with textures, pointers still NULL yet
|
textureIdMap[path.data] = nullptr; //fill map with textures, pointers still NULL yet
|
||||||
texIndex++;
|
texIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Error occurred */
|
/* Error occurred */
|
||||||
MessageBox(NULL, UTFConverter("Couldn't load Image: " + fileloc).c_wstr(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(nullptr, UTFConverter("Couldn't load Image: " + fileloc).c_wstr(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Because we have already copied image data into texture data we can release memory used by image.
|
// Because we have already copied image data into texture data we can release memory used by image.
|
||||||
|
@ -447,7 +447,7 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd, float
|
||||||
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
|
apply_material(sc->mMaterials[mesh->mMaterialIndex]);
|
||||||
|
|
||||||
|
|
||||||
if(mesh->mNormals == NULL)
|
if(mesh->mNormals == nullptr)
|
||||||
{
|
{
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd, float
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mesh->mColors[0] != NULL)
|
if(mesh->mColors[0] != nullptr)
|
||||||
{
|
{
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
}
|
}
|
||||||
|
@ -482,9 +482,9 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd, float
|
||||||
for(i = 0; i < face->mNumIndices; i++) // go through all vertices in face
|
for(i = 0; i < face->mNumIndices; i++) // go through all vertices in face
|
||||||
{
|
{
|
||||||
int vertexIndex = face->mIndices[i]; // get group index for current index
|
int vertexIndex = face->mIndices[i]; // get group index for current index
|
||||||
if(mesh->mColors[0] != NULL)
|
if(mesh->mColors[0] != nullptr)
|
||||||
Color4f(&mesh->mColors[0][vertexIndex]);
|
Color4f(&mesh->mColors[0][vertexIndex]);
|
||||||
if(mesh->mNormals != NULL)
|
if(mesh->mNormals != nullptr)
|
||||||
|
|
||||||
if(mesh->HasTextureCoords(0)) //HasTextureCoords(texture_coordinates_set)
|
if(mesh->HasTextureCoords(0)) //HasTextureCoords(texture_coordinates_set)
|
||||||
{
|
{
|
||||||
|
@ -543,50 +543,50 @@ void KillGLWindow() // Properly Kill The Window
|
||||||
{
|
{
|
||||||
if (fullscreen) // Are We In Fullscreen Mode?
|
if (fullscreen) // Are We In Fullscreen Mode?
|
||||||
{
|
{
|
||||||
ChangeDisplaySettings(NULL, 0); // If So Switch Back To The Desktop
|
ChangeDisplaySettings(nullptr, 0); // If So Switch Back To The Desktop
|
||||||
ShowCursor(TRUE); // Show Mouse Pointer
|
ShowCursor(TRUE); // Show Mouse Pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hRC) // Do We Have A Rendering Context?
|
if (hRC) // Do We Have A Rendering Context?
|
||||||
{
|
{
|
||||||
if (!wglMakeCurrent(NULL, NULL)) // Are We Able To Release The DC And RC Contexts?
|
if (!wglMakeCurrent(nullptr, nullptr)) // Are We Able To Release The DC And RC Contexts?
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("Release Of DC And RC Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Release Of DC And RC Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("Release Rendering Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Release Rendering Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
hRC = NULL;
|
hRC = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hDC)
|
if (hDC)
|
||||||
{
|
{
|
||||||
if (!ReleaseDC(g_hWnd, hDC)) // Are We able to Release The DC?
|
if (!ReleaseDC(g_hWnd, hDC)) // Are We able to Release The DC?
|
||||||
MessageBox(NULL, TEXT("Release Device Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Release Device Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
hDC = NULL;
|
hDC = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_hWnd)
|
if (g_hWnd)
|
||||||
{
|
{
|
||||||
if (!DestroyWindow(g_hWnd)) // Are We Able To Destroy The Window
|
if (!DestroyWindow(g_hWnd)) // Are We Able To Destroy The Window
|
||||||
MessageBox(NULL, TEXT("Could Not Release hWnd."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Could Not Release hWnd."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
g_hWnd = NULL;
|
g_hWnd = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_hInstance)
|
if (g_hInstance)
|
||||||
{
|
{
|
||||||
if (!UnregisterClass(TEXT("OpenGL"), g_hInstance)) // Are We Able To Unregister Class
|
if (!UnregisterClass(TEXT("OpenGL"), g_hInstance)) // Are We Able To Unregister Class
|
||||||
MessageBox(NULL, TEXT("Could Not Unregister Class."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
MessageBox(nullptr, TEXT("Could Not Unregister Class."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
g_hInstance = NULL;
|
g_hInstance = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLboolean abortGLInit(const char* abortMessage)
|
GLboolean abortGLInit(const char* abortMessage)
|
||||||
{
|
{
|
||||||
KillGLWindow(); // Reset Display
|
KillGLWindow(); // Reset Display
|
||||||
MessageBox(NULL, UTFConverter(abortMessage).c_wstr(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(nullptr, UTFConverter(abortMessage).c_wstr(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
||||||
return FALSE; // quit and return False
|
return FALSE; // quit and return False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,21 +604,21 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
|
|
||||||
fullscreen = fullscreenflag;
|
fullscreen = fullscreenflag;
|
||||||
|
|
||||||
g_hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
|
g_hInstance = GetModuleHandle(nullptr); // Grab An Instance For Our Window
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Move, And Own DC For Window
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Move, And Own DC For Window
|
||||||
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc handles Messages
|
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc handles Messages
|
||||||
wc.cbClsExtra = 0; // No Extra Window Data
|
wc.cbClsExtra = 0; // No Extra Window Data
|
||||||
wc.cbWndExtra = 0; // No Extra Window Data
|
wc.cbWndExtra = 0; // No Extra Window Data
|
||||||
wc.hInstance = g_hInstance;
|
wc.hInstance = g_hInstance;
|
||||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
|
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); // Load The Default Icon
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load the default arrow
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW); // Load the default arrow
|
||||||
wc.hbrBackground= NULL; // No Background required for OpenGL
|
wc.hbrBackground= nullptr; // No Background required for OpenGL
|
||||||
wc.lpszMenuName = NULL; // No Menu
|
wc.lpszMenuName = nullptr; // No Menu
|
||||||
wc.lpszClassName= TEXT("OpenGL"); // Class Name
|
wc.lpszClassName= TEXT("OpenGL"); // Class Name
|
||||||
|
|
||||||
if (!RegisterClass(&wc))
|
if (!RegisterClass(&wc))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("Failed to register the window class"), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(nullptr, TEXT("Failed to register the window class"), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
return FALSE; //exit and return false
|
return FALSE; //exit and return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,14 +636,14 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
||||||
if (MessageBox(NULL,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
if (MessageBox(nullptr,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
||||||
{
|
{
|
||||||
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Popup Messagebox: Closing
|
//Popup Messagebox: Closing
|
||||||
MessageBox(NULL, TEXT("Program will close now."), TEXT("ERROR"), MB_OK|MB_ICONSTOP);
|
MessageBox(nullptr, TEXT("Program will close now."), TEXT("ERROR"), MB_OK|MB_ICONSTOP);
|
||||||
return FALSE; //exit, return false
|
return FALSE; //exit, return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,10 +672,10 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
0, 0, // Window Position
|
0, 0, // Window Position
|
||||||
WindowRect.right-WindowRect.left, // Calc adjusted Window Width
|
WindowRect.right-WindowRect.left, // Calc adjusted Window Width
|
||||||
WindowRect.bottom-WindowRect.top, // Calc adjustes Window Height
|
WindowRect.bottom-WindowRect.top, // Calc adjustes Window Height
|
||||||
NULL, // No Parent Window
|
nullptr, // No Parent Window
|
||||||
NULL, // No Menu
|
nullptr, // No Menu
|
||||||
g_hInstance, // Instance
|
g_hInstance, // Instance
|
||||||
NULL ))) // Don't pass anything To WM_CREATE
|
nullptr ))) // Don't pass anything To WM_CREATE
|
||||||
{
|
{
|
||||||
abortGLInit("Window Creation Error.");
|
abortGLInit("Window Creation Error.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -834,7 +834,7 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance
|
||||||
// Check the command line for an override file path.
|
// Check the command line for an override file path.
|
||||||
int argc;
|
int argc;
|
||||||
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||||
if (argv != NULL && argc > 1)
|
if (argv != nullptr && argc > 1)
|
||||||
{
|
{
|
||||||
std::wstring modelpathW(argv[1]);
|
std::wstring modelpathW(argv[1]);
|
||||||
modelpath = UTFConverter(modelpathW).str();
|
modelpath = UTFConverter(modelpathW).str();
|
||||||
|
@ -848,7 +848,7 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance
|
||||||
|
|
||||||
logInfo("=============== Post Import ====================");
|
logInfo("=============== Post Import ====================");
|
||||||
|
|
||||||
if (MessageBox(NULL, TEXT("Would You Like To Run In Fullscreen Mode?"), TEXT("Start Fullscreen?"), MB_YESNO|MB_ICONEXCLAMATION)==IDNO)
|
if (MessageBox(nullptr, TEXT("Would You Like To Run In Fullscreen Mode?"), TEXT("Start Fullscreen?"), MB_YESNO|MB_ICONEXCLAMATION)==IDNO)
|
||||||
{
|
{
|
||||||
fullscreen=FALSE;
|
fullscreen=FALSE;
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance
|
||||||
|
|
||||||
while(!done) // Game Loop
|
while(!done) // Game Loop
|
||||||
{
|
{
|
||||||
if (PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
|
if (PeekMessage(&msg, nullptr, 0,0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
if (msg.message==WM_QUIT)
|
if (msg.message==WM_QUIT)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue