Skip to content
This repository was archived by the owner on Dec 12, 2020. It is now read-only.

Commit 6ead84c

Browse files
fixed setup app to include GLEW_LIB_DIR
1 parent a32a0fd commit 6ead84c

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

System Setup/System Setup/SystemSetup.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ int main()
3232
std::cout << std::endl << "Now For GLEW 2.1.0 include directory..." << std::endl;
3333
std::string glew_inc_dir = GetPathToFile("\\GL\\glew.h");
3434

35+
std::cout << std::endl << "Now For GLEW 2.1.0 library directory..." << std::endl;
36+
std::string glew_lib_dir = GetPathToFile("\\Debug\\glew32d.lib");
37+
3538
std::cout << std::endl << "Continuing with GLFW 3.2.1 include directory..." << std::endl;
3639
std::string glfw_inc_dir = GetPathToFile("\\GLFW\\glfw3.h");
3740

3841
std::cout << std::endl << "Continuing with GLFW 3.2.1 library directory..." << std::endl;
3942
std::string glfw_lib_dir = GetPathToFile("\\Debug\\glfw3.lib");
4043

4144
std::cout << "Creating batch file...";
42-
if (!CreateScript(glm_inc_dir, glew_inc_dir, glfw_inc_dir, glfw_lib_dir))
45+
if (!CreateScript(glm_inc_dir, glew_inc_dir, glew_lib_dir, glfw_inc_dir, glfw_lib_dir))
4346
{
4447
std::cout << " FAILED!" << std::endl;
4548
return -1;
@@ -51,7 +54,9 @@ int main()
5154
std::cout << "FAILED to execute script!" << std::endl;
5255
return -1;
5356
}
54-
std::cout << "Successfully setup enviroment variables!" << std::endl << " To use them you must logout and back in." << std::endl;
57+
58+
std::cout << "Successfully setup enviroment variables!" << std::endl << " To use them you must logout and back in." << std::endl << "Press 'enter' to exit." << std::endl;
59+
std::getline(std::cin, std::string());
5560

5661
return 0;
5762
}
@@ -172,23 +177,23 @@ BOOL TryToOpenFile(const std::string& full_path)
172177

173178
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb540534(v=vs.85).aspx
174179
// https://stackoverflow.com/a/21606502/8480874
175-
BOOL CreateScript(const std::string& glm_inc_dir, const std::string& glew_inc_dir, const std::string& glfw_inc_dir, const std::string& glfw_lib_dir)
180+
BOOL CreateScript(const std::string& glm_inc_dir, const std::string& glew_inc_dir, const std::string& glew_lib_dir, const std::string& glfw_inc_dir, const std::string& glfw_lib_dir)
176181
{
177182
HANDLE hFile;
178183

179-
std::string script = "@ECHO OFF\n\n:: Setting Env Vars For COMP371\nsetx GLM_INC_DIR " + glm_inc_dir + " /m\nsetx GLEW_INC_DIR " + glew_inc_dir + " /m\nsetx GLFW_INC_DIR " + glfw_inc_dir + " /m\nsetx GLFW_LIB_DIR " + glfw_lib_dir + " /m\n";
184+
std::string script = "@ECHO OFF\n\n:: Setting Env Vars For COMP371\nsetx GLM_INC_DIR " + glm_inc_dir + " /m\nsetx GLEW_INC_DIR " + glew_inc_dir + " /m\nsetx GLFW_INC_DIR " + glfw_inc_dir + " /m\nsetx GLFW_LIB_DIR " + glfw_lib_dir + " /m\nsetx GLEW_LIB_DIR " + glew_lib_dir + " /m\n";
180185

181186
DWORD dwBytesToWrite = (DWORD)strlen(script.c_str());
182187
DWORD dwBytesWritten = 0;
183188
BOOL bErrorFlag = FALSE;
184189

185-
hFile = CreateFile(L"setup.bat", // name of the write
186-
GENERIC_WRITE, // open for writing
187-
0, // do not share
188-
NULL, // default security
189-
CREATE_NEW, // create new file only
190-
FILE_ATTRIBUTE_NORMAL, // normal file
191-
NULL); // no attr. template
190+
hFile = CreateFile(L"setup.bat", // name of the write
191+
GENERIC_WRITE, // open for writing
192+
0, // do not share
193+
NULL, // default security
194+
CREATE_ALWAYS, // create new file only
195+
FILE_ATTRIBUTE_NORMAL, // normal file
196+
NULL); // no attr. template
192197

193198
if (hFile == INVALID_HANDLE_VALUE)
194199
{
@@ -198,12 +203,11 @@ BOOL CreateScript(const std::string& glm_inc_dir, const std::string& glew_inc_di
198203

199204
printf("Writing %d bytes to %s.\n", dwBytesToWrite, "setup.bat");
200205

201-
bErrorFlag = WriteFile(
202-
hFile, // open file handle
203-
script.c_str(), // start of data to write
204-
dwBytesToWrite, // number of bytes to write
205-
&dwBytesWritten, // number of bytes that were written
206-
NULL); // no overlapped structure
206+
bErrorFlag = WriteFile(hFile, // open file handle
207+
script.c_str(), // start of data to write
208+
dwBytesToWrite, // number of bytes to write
209+
&dwBytesWritten, // number of bytes that were written
210+
NULL); // no overlapped structure
207211

208212
if (FALSE == bErrorFlag)
209213
{
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
22

3-
const uint16_t GetUserInput(const uint16_t & lower, const uint16_t & upper);
43
BOOL IsElevated();
54
std::string BrowseFolder(std::string saved_path);
65
static int BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
76
std::string GetPathToFile(const std::string & file_path);
87
BOOL TryToOpenFile(const std::string & full_path);
9-
BOOL CreateScript(const std::string& glm_inc_dir, const std::string& glew_inc_dir, const std::string& glfw_inc_dir, const std::string& glfw_lib_dir);
8+
BOOL CreateScript(const std::string& glm_inc_dir, const std::string& glew_inc_dir, const std::string& glew_lib_dir, const std::string& glfw_inc_dir, const std::string& glfw_lib_dir);
109
BOOL ExecuteScript();

0 commit comments

Comments
 (0)