v2: Remove redundant 'core' in GLSL version statement. Signed-off-by: Fabian Bieler <fabianbie...@fastmail.fm> Reviewed-by: Brian Paul <bri...@vmware.com> Reviewed-by: Ian Romanick <ian.d.roman...@intel.com> --- src/glsl/gsraytrace.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/glsl/gsraytrace.cpp b/src/glsl/gsraytrace.cpp index 6df6543..44f2674 100644 --- a/src/glsl/gsraytrace.cpp +++ b/src/glsl/gsraytrace.cpp @@ -408,6 +408,7 @@ static const char* fsSource = "uniform vec4 backgroundColor; \n" "uniform int emitNoMore; \n" " \n" +"out vec4 frag_color; \n" " \n" "//-----------------------------------------------------------------------\n" " \n" @@ -493,7 +494,7 @@ static const char* fsSource = " Isec eyeHit = isec;\n" " if (eyeHit.idx == -1)\n" " {\n" -" gl_FragColor = vec4(backgroundColor.rgb, 0.0);\n" +" frag_color = vec4(backgroundColor.rgb, 0.0);\n" " return;\n" " }\n" " vec3 eyeHitPosition = eyeRay.orig + eyeRay.dir * eyeHit.t;\n" @@ -503,7 +504,7 @@ static const char* fsSource = " vec3 L = normalize(lightVec); \n" " float NdotL = max(dot(N, L), 0.0); \n" " vec3 diffuse = idx2color(eyeHit.idx); // material color of the visible point\n" -" gl_FragColor = vec4(diffuse * NdotL, 1.0); \n" +" frag_color = vec4(diffuse * NdotL, 1.0); \n" " return; \n" " } \n" "#ifdef SHADOWS \n" @@ -514,7 +515,7 @@ static const char* fsSource = " { \n" " discard; \n" " } \n" -" gl_FragColor = vec4(-1,-1,-1, 0.0); \n" +" frag_color = vec4(-1,-1,-1, 0.0); \n" " return; \n" " } \n" "#endif \n" @@ -534,7 +535,7 @@ static const char* fsSource = " vec3 L = normalize(lightVec); \n" " float NdotL = max(dot(N, L), 0.0); \n" " vec3 diffuse = idx2color(reflHit.idx); \n" -" gl_FragColor = vec4(diffuse * NdotL * 0.25, 1.0); // material color of the visible point\n" +" frag_color = vec4(diffuse * NdotL * 0.25, 1.0); // material color of the visible point\n" " return; \n" " } \n" "#endif \n" @@ -608,6 +609,8 @@ Draw(void) dir_idxAttribLoc = glGetAttribLocation(program, "dir_idx"); uv_stateAttribLoc = glGetAttribLocation(program, "uv_state"); + glBindFragDataLocation(program, 0, "frag_color"); + ////printf("%d\n", i); //gs.fpwQuery->beginQuery(); //gs.pgQuery->beginQuery(); @@ -755,10 +758,6 @@ Reshape(int width, int height) WinWidth = width; WinHeight = height; glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); { size_t nElem = WinWidth*WinHeight*nRayGens; @@ -911,6 +910,10 @@ Init(void) glGenBuffers(1, &dst); glGenBuffers(1, &eyeRaysAsPoints); + GLuint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + printf("\nESC = exit demo\nleft mouse + drag = rotate camera\n\n"); } @@ -920,9 +923,24 @@ main(int argc, char *argv[]) { glutInitWindowSize(WinWidth, WinHeight); glutInit(&argc, argv); + +#ifdef HAVE_FREEGLUT + glutInitContextVersion(3, 2); + glutInitContextProfile(GLUT_CORE_PROFILE); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); +#elif defined __APPLE__ + glutInitDisplayMode(GLUT_3_2_CORE_PROFILE | GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); +#else + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); +#endif Win = glutCreateWindow(argv[0]); + + // glewInit requires glewExperimentel set to true for core profiles. + // Depending on the glew version it also generates GL_INVALID_ENUM. + glewExperimental = GL_TRUE; glewInit(); + glGetError(); + glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); -- 1.8.3.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev