diff --git a/test/core/test_std_cout_new.cpp b/test/core/test_std_cout_new.cpp deleted file mode 100644 index b475a82476e0f..0000000000000 --- a/test/core/test_std_cout_new.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Emscripten Authors. All rights reserved. -// Emscripten is available under two separate licenses, the MIT license and the -// University of Illinois/NCSA Open Source License. Both these licenses can be -// found in the LICENSE file. - -#include - -struct NodeInfo { // structure that we want to transmit to our shaders - float x; - float y; - float s; - float c; -}; -const int nbNodes = 100; -NodeInfo* data = new NodeInfo[nbNodes]; // our data that will be transmitted - // using float texture. - -template -void printText(const char (&text)[i]) { - std::cout << text << std::endl; -} - -int main() { - printText("some string constant"); - return 0; -} diff --git a/test/float_tex.cpp b/test/float_tex.c similarity index 80% rename from test/float_tex.cpp rename to test/float_tex.c index 6c14f5168cf3a..d493afc5f4fd0 100644 --- a/test/float_tex.cpp +++ b/test/float_tex.c @@ -3,16 +3,15 @@ // University of Illinois/NCSA Open Source License. Both these licenses can be // found in the LICENSE file. +#include +#include +#include + #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES -#include -#include -#include -#include -extern "C" { #include #include -} + static const char vertex_shader[] = "#ifdef GL_ES\n" "precision lowp float;\n" @@ -29,6 +28,7 @@ static const char vertex_shader[] = " gl_PointSize = v.z;\n" " color = vec4(0.5 + v.w/2., 0.5 + 0.5 * v.w/2., 0.5, 1);\n" "}\n"; + static const char fragment_shader[] = "#ifdef GL_ES\n" "precision lowp float;\n" @@ -44,26 +44,29 @@ static const char fragment_shader[] = "}\n" "if ( dst > 0.5) discard;\n" "}"; -struct NodeInfo { //structure that we want to transmit to our shaders + +typedef struct NodeInfo { //structure that we want to transmit to our shaders float x; float y; float s; float c; -}; +} NodeInfo; + GLuint nodeTexture; //texture id used to bind GLuint nodeSamplerLocation; //shader sampler address GLuint indicesAttributeLocation; //shader attribute address GLuint indicesVBO; //Vertex Buffer Object Id; -const int nbNodes = 512; -NodeInfo * data = new NodeInfo[nbNodes]; //our data that will be transmitted using float texture. +#define NUM_NODES 512 +NodeInfo data[NUM_NODES]; //our data that will be transmitted using float texture. double alpha = 0; //use to make a simple funny effect; + // static void updateFloatTexture() { int count = 0; - for (float x=0; x < nbNodes; ++x ) { - data[count].x = 0.2*pow(cos(alpha), 3) + (sin(alpha)*3. + 3.5) * x/nbNodes * cos(alpha + x/nbNodes * 16. * M_PI); - data[count].y = 0.2*pow(sin(alpha), 3) + (sin(alpha)*3. + 3.5) * x/nbNodes * sin(alpha + x/nbNodes * 16. * M_PI); - data[count].s = (16. + 16. * cos(alpha + x/nbNodes * 32. * M_PI)) + 8.;// * fmod(x/nbNodes + alpha, 1.) + 5.; - data[count].c = 0.5 + 0.5 * sin(alpha + x/nbNodes * 32. * M_PI); + for (float x=0; x < NUM_NODES; ++x ) { + data[count].x = 0.2*pow(cos(alpha), 3) + (sin(alpha)*3. + 3.5) * x/NUM_NODES * cos(alpha + x/NUM_NODES * 16. * M_PI); + data[count].y = 0.2*pow(sin(alpha), 3) + (sin(alpha)*3. + 3.5) * x/NUM_NODES * sin(alpha + x/NUM_NODES * 16. * M_PI); + data[count].s = (16. + 16. * cos(alpha + x/NUM_NODES * 32. * M_PI)) + 8.;// * fmod(x/NUM_NODES + alpha, 1.) + 5.; + data[count].c = 0.5 + 0.5 * sin(alpha + x/NUM_NODES * 32. * M_PI); ++count; } glBindTexture(GL_TEXTURE_2D, nodeTexture); @@ -73,12 +76,13 @@ static void updateFloatTexture() { // In desktop GL, we can also use sized internal formats. const GLenum internalFormat = GL_RGBA32F; #endif - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, nbNodes, 1, 0, GL_RGBA, GL_FLOAT, data); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, NUM_NODES, 1, 0, GL_RGBA, GL_FLOAT, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); alpha -= 0.001; } + static void glut_draw_callback(void) { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); @@ -93,9 +97,10 @@ static void glut_draw_callback(void) { glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, indicesVBO); glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); - glDrawArrays(GL_POINTS, 0, nbNodes); + glDrawArrays(GL_POINTS, 0, NUM_NODES); glutSwapBuffers(); } + GLuint createShader(const char source[], int type) { GLint status; char msg[512]; @@ -105,11 +110,12 @@ GLuint createShader(const char source[], int type) { glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { glGetShaderInfoLog(shader, sizeof msg, NULL, msg); - std::cout << "Shader info: \"" << msg << "\"" << std::endl; + printf("Shader info: \"%s\"\n", msg); } assert(status == GL_TRUE); return shader; } + static void gl_init(void) { GLuint program = glCreateProgram(); glAttachShader(program, createShader(vertex_shader , GL_VERTEX_SHADER)); @@ -120,13 +126,13 @@ static void gl_init(void) { glGetProgramiv(program, GL_LINK_STATUS, &status); if (status == GL_FALSE) { glGetProgramInfoLog(program, sizeof msg, NULL, msg); - std::cout << "info: \"" << msg << "\"" << std::endl; + printf("info: \"%s\"\n", msg); } assert(status == GL_TRUE); glUseProgram(program); - std::vector elements(nbNodes); + float elements[NUM_NODES]; int count = 0; - for (float x=0; x < nbNodes; ++x ) { + for (float x=0; x < NUM_NODES; ++x ) { elements[count] = count; ++count; } @@ -135,9 +141,9 @@ static void gl_init(void) { /* Store the vertices in a vertex buffer object (VBO) */ glGenBuffers(1, &indicesVBO); glBindBuffer(GL_ARRAY_BUFFER, indicesVBO); - glBufferData(GL_ARRAY_BUFFER, elements.size() * sizeof(float), &elements[0], GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, NUM_NODES * sizeof(float), &elements[0], GL_STATIC_DRAW); /* Get the locations of the uniforms so we can access them */ - nodeSamplerLocation = glGetUniformLocation(program, "nodeInfo"); + nodeSamplerLocation = glGetUniformLocation(program, "nodeInfo"); glBindAttribLocation(program, 0, "indices"); #ifndef __EMSCRIPTEN__ // GLES2 & WebGL do not have these, only pre 3.0 desktop GL and compatibility mode GL3.0+ GL do. //Enable glPoint size in shader, always enable in Open Gl ES 2. @@ -145,16 +151,15 @@ static void gl_init(void) { glEnable(GL_POINT_SPRITE); #endif } + int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(640, 480); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("Simple FLOAT Texture Test"); /* Set up glut callback functions */ - glutDisplayFunc(glut_draw_callback ); + glutDisplayFunc(glut_draw_callback); gl_init(); glutMainLoop(); return 0; } - - diff --git a/test/gl_subdata.cpp b/test/gl_subdata.c similarity index 77% rename from test/gl_subdata.cpp rename to test/gl_subdata.c index 7719382d86bd2..184891e7ec531 100644 --- a/test/gl_subdata.cpp +++ b/test/gl_subdata.c @@ -3,15 +3,15 @@ // University of Illinois/NCSA Open Source License. Both these licenses can be // found in the LICENSE file. +#include +#include +#include + #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES -#include -#include -#include -extern "C" { #include #include -} + static const char vertex_shader[] = "#ifdef GL_ES\n" "precision lowp float;\n" @@ -28,6 +28,7 @@ static const char vertex_shader[] = " gl_PointSize = v.z;\n" " color = vec4(0.5 + v.w/2., 0.5 + 0.5 * v.w/2., 0.5, 1);\n" "}\n"; + static const char fragment_shader[] = "#ifdef GL_ES\n" "precision lowp float;\n" @@ -43,26 +44,29 @@ static const char fragment_shader[] = "}\n" "if ( dst > 0.5) discard;\n" "}"; -struct NodeInfo { //structure that we want to transmit to our shaders + +typedef struct NodeInfo { //structure that we want to transmit to our shaders float x; float y; float s; float c; -}; +} NodeInfo; + GLuint nodeTexture; //texture id used to bind GLuint nodeSamplerLocation; //shader sampler address GLuint indicesAttributeLocation; //shader attribute address GLuint indicesVBO; //Vertex Buffer Object Id; -const int nbNodes = 512; -NodeInfo data[nbNodes]; //our data that will be transmitted using float texture. +#define NUM_NODES 512 +NodeInfo data[NUM_NODES]; //our data that will be transmitted using float texture. double alpha = 0; //use to make a simple funny effect; + static void updateFloatTexture() { int count = 0; - for (float x=0; x < nbNodes; ++x ) { - data[count].x = 0.2*pow(cos(alpha), 3) + (sin(alpha)*3. + 3.5) * x/nbNodes * cos(alpha + x/nbNodes * 16. * M_PI); - data[count].y = 0.2*pow(sin(alpha), 3) + (sin(alpha)*3. + 3.5) * x/nbNodes * sin(alpha + x/nbNodes * 16. * M_PI); - data[count].s = (16. + 16. * cos(alpha + x/nbNodes * 32. * M_PI)) + 8.;// * fmod(x/nbNodes + alpha, 1.) + 5.; - data[count].c = 0.5 + 0.5 * sin(alpha + x/nbNodes * 32. * M_PI); + for (float x=0; x < NUM_NODES; ++x ) { + data[count].x = 0.2*pow(cos(alpha), 3) + (sin(alpha)*3. + 3.5) * x/NUM_NODES * cos(alpha + x/NUM_NODES * 16. * M_PI); + data[count].y = 0.2*pow(sin(alpha), 3) + (sin(alpha)*3. + 3.5) * x/NUM_NODES * sin(alpha + x/NUM_NODES * 16. * M_PI); + data[count].s = (16. + 16. * cos(alpha + x/NUM_NODES * 32. * M_PI)) + 8.;// * fmod(x/NUM_NODES + alpha, 1.) + 5.; + data[count].c = 0.5 + 0.5 * sin(alpha + x/NUM_NODES * 32. * M_PI); ++count; } glBindTexture(GL_TEXTURE_2D, nodeTexture); @@ -72,12 +76,13 @@ static void updateFloatTexture() { // In desktop GL, we can also use sized internal formats. const GLenum internalFormat = GL_RGBA32F; #endif - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, nbNodes, 1, 0, GL_RGBA, GL_FLOAT, data); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, NUM_NODES, 1, 0, GL_RGBA, GL_FLOAT, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); alpha -= 0.001; } + static void glut_draw_callback(void) { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); @@ -92,18 +97,20 @@ static void glut_draw_callback(void) { glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, indicesVBO); glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); - glDrawArrays(GL_POINTS, 0, nbNodes); + glDrawArrays(GL_POINTS, 0, NUM_NODES); glutSwapBuffers(); } -GLuint createShader(const char source[], int type) { + +GLuint createShader(const char* source, int type) { char msg[512]; GLuint shader = glCreateShader(type); - glShaderSource(shader, 1, (const GLchar**)(&source), NULL); + glShaderSource(shader, 1, &source, NULL); glCompileShader(shader); glGetShaderInfoLog(shader, sizeof msg, NULL, msg); - std::cout << "Shader info: " << msg << std::endl; + printf("Shader info: %s\n", msg); return shader; } + static void gl_init(void) { GLuint program = glCreateProgram(); glAttachShader(program, createShader(vertex_shader , GL_VERTEX_SHADER)); @@ -111,11 +118,11 @@ static void gl_init(void) { glLinkProgram(program); char msg[512]; glGetProgramInfoLog(program, sizeof msg, NULL, msg); - std::cout << "info: " << msg << std::endl; + printf("info: %s\n", msg); glUseProgram(program); - std::vector elements(nbNodes); + float elements[NUM_NODES]; int count = 0; - for (float x=0; x < nbNodes; ++x ) { + for (float x=0; x < NUM_NODES; ++x ) { elements[count] = count; ++count; } @@ -124,14 +131,14 @@ static void gl_init(void) { /* Store the vertices in a vertex buffer object (VBO) */ glGenBuffers(1, &indicesVBO); glBindBuffer(GL_ARRAY_BUFFER, indicesVBO); - float zeroes[nbNodes]; + float zeroes[NUM_NODES]; memset(zeroes, 0, sizeof(zeroes)); - glBufferData(GL_ARRAY_BUFFER, elements.size() * sizeof(float), zeroes, GL_STATIC_DRAW); - for (int x = 0; x < nbNodes; x++) { + glBufferData(GL_ARRAY_BUFFER, NUM_NODES * sizeof(float), zeroes, GL_STATIC_DRAW); + for (int x = 0; x < NUM_NODES; x++) { glBufferSubData(GL_ARRAY_BUFFER, x * sizeof(float), sizeof(float), &elements[x]); } /* Get the locations of the uniforms so we can access them */ - nodeSamplerLocation = glGetUniformLocation(program, "nodeInfo"); + nodeSamplerLocation = glGetUniformLocation(program, "nodeInfo"); glBindAttribLocation(program, 0, "indices"); #ifndef __EMSCRIPTEN__ // GLES2 & WebGL do not have these, only pre 3.0 desktop GL and compatibility mode GL3.0+ GL do. //Enable glPoint size in shader, always enable in Open Gl ES 2. @@ -139,13 +146,14 @@ static void gl_init(void) { glEnable(GL_POINT_SPRITE); #endif } + int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(640, 480); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow("Simple FLOAT Texture Test"); + int w = glutCreateWindow("Simple FLOAT Texture Test"); /* Set up glut callback functions */ - glutDisplayFunc(glut_draw_callback ); + glutDisplayFunc(glut_draw_callback); gl_init(); glutMainLoop(); return 0; diff --git a/test/test_browser.py b/test/test_browser.py index d297aab653486..961273c4e05af 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -2320,11 +2320,11 @@ def test_tex_nonbyte(self): @requires_graphics_hardware def test_float_tex(self): - self.btest('float_tex.cpp', reference='float_tex.png', args=['-lGL', '-lglut']) + self.btest('float_tex.c', reference='float_tex.png', args=['-lGL', '-lglut']) @requires_graphics_hardware def test_subdata(self): - self.btest('gl_subdata.cpp', reference='float_tex.png', args=['-lGL', '-lglut']) + self.btest('gl_subdata.c', reference='float_tex.png', args=['-lGL', '-lglut']) @requires_graphics_hardware def test_perspective(self): diff --git a/test/test_core.py b/test/test_core.py index 1dd31b8966199..b696cb6a97148 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -5703,9 +5703,6 @@ def test_direct_string_constant_usage(self): self.set_setting('EXIT_RUNTIME') self.do_core_test('test_direct_string_constant_usage.cpp') - def test_std_cout_new(self): - self.do_core_test('test_std_cout_new.cpp') - def test_std_function_incomplete_return(self): self.do_core_test('test_std_function_incomplete_return.cpp')