Skip to content

Commit

Permalink
Add support for v300es (special vertex shader)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugues Evrard committed May 20, 2017
1 parent f92746f commit 5d091b1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions get_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ const char* vertex_shader_wo_version =
"attribute vec2 vert2d;\n"
"void main(void) {\n"
" gl_Position = vec4(vert2d, 0.0, 1.0);\n"
"}";
"}\n";

const char* vertex_shader_v300es =
"in vec3 aVertexPosition;\n"
"void main(void) {\n"
" gl_Position = vec4(aVertexPosition, 1.0);\n"
"}\n";

bool readFile(const std::string& fileName, std::string& contentsOut) {
std::ifstream ifs(fileName.c_str());
Expand Down Expand Up @@ -436,7 +441,13 @@ int main(int argc, char* argv[]) {
} else {
std::cerr << "Warning: Could not find #version string of fragment shader." << std::endl;
}
ss << vertex_shader_wo_version;
// the vertex shader is different for versio 300 es
i = fragContents.find("300");
if (i != std::string::npos) {
ss << vertex_shader_v300es;
} else {
ss << vertex_shader_wo_version;
}
vertexContents = ss.str();
} else {
if(!readFile(vertex_shader, vertexContents)) {
Expand Down

0 comments on commit 5d091b1

Please sign in to comment.