4
4
#include < iostream>
5
5
#include < fstream>
6
6
#include < algorithm>
7
+ #include < sstream>
7
8
using namespace std ;
8
9
9
10
#include < stdlib.h>
@@ -23,9 +24,9 @@ GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path
23
24
std::string VertexShaderCode;
24
25
std::ifstream VertexShaderStream (vertex_file_path, std::ios::in);
25
26
if (VertexShaderStream.is_open ()){
26
- std::string Line = " " ;
27
- while ( getline (VertexShaderStream, Line))
28
- VertexShaderCode += " \n " + Line ;
27
+ std::stringstream sstr ;
28
+ sstr << VertexShaderStream. rdbuf ();
29
+ VertexShaderCode = sstr. str () ;
29
30
VertexShaderStream.close ();
30
31
}else {
31
32
printf (" Impossible to open %s. Are you in the right directory ? Don't forget to read the FAQ !\n " , vertex_file_path);
@@ -37,9 +38,9 @@ GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path
37
38
std::string FragmentShaderCode;
38
39
std::ifstream FragmentShaderStream (fragment_file_path, std::ios::in);
39
40
if (FragmentShaderStream.is_open ()){
40
- std::string Line = " " ;
41
- while ( getline (FragmentShaderStream, Line))
42
- FragmentShaderCode += " \n " + Line ;
41
+ std::stringstream sstr ;
42
+ sstr << FragmentShaderStream. rdbuf ();
43
+ FragmentShaderCode = sstr. str () ;
43
44
FragmentShaderStream.close ();
44
45
}
45
46
0 commit comments