Advertisement
Guest User

Untitled

a guest
Oct 19th, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "GL/glew.h"
  3. #include "GL/glut.h"
  4. #include <vector>
  5.  
  6. void printCompileError(GLuint obj){
  7. GLint logLength = 0;
  8. glGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
  9. if(logLength){
  10. std::vector<GLcharARB> errorLog(logLength,0);
  11. glGetInfoLogARB(obj, logLength,0,&errorLog[0]);
  12. fprintf(stderr, &errorLog[0]);
  13. }
  14. }
  15.  
  16. int main(int argc, char** argv) {
  17. glutInit(&argc, argv);
  18. glutCreateWindow("gltestcase");
  19.  
  20. GLenum glew_status = glewInit();
  21. if (glew_status != GLEW_OK) {
  22. fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
  23. return EXIT_FAILURE;
  24. }
  25.  
  26. if (!GLEW_EXT_geometry_shader4) {
  27. fprintf(stderr, "EXT_geometry_shader4 not supported");
  28. return EXIT_FAILURE;
  29. }
  30.  
  31. fprintf(stdout, "vendor: %s\n", glGetString(GL_VENDOR));
  32. fprintf(stdout, "version: %s\n", glGetString(GL_VERSION));
  33.  
  34. GLint compile_ok = GL_FALSE;
  35. GLuint program = glCreateProgram();
  36. GLuint gs = glCreateShader(GL_GEOMETRY_SHADER);
  37.  
  38. //GL_ARB_geometry_sheder problem
  39. const char* gs_source =
  40. "#version 130\n"
  41. "#extension GL_ARB_geometry_shader4 : require\n"
  42. "in float something[];"
  43. "void f(int i){something[i];}"
  44. "void main(){}";
  45.  
  46. glShaderSource(gs, 1, &gs_source, NULL);
  47. glCompileShader(gs);
  48. glGetShaderiv(gs, GL_COMPILE_STATUS, &compile_ok);
  49. if (0 == compile_ok) {
  50. printCompileError(gs);
  51. } else {
  52. fprintf(stdout, "gs: ok\n");
  53. }
  54.  
  55. //sampler array problem
  56. const char* fs_source =
  57. "#version 130\n"
  58. "uniform sampler2D samp[2];"
  59. "void f(int i){ textureSize(samp[i], 0); }"
  60. "void main(){}";
  61.  
  62. GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
  63. glShaderSource(fs, 1, &fs_source, NULL);
  64. glCompileShader(fs);
  65. glGetShaderiv(fs, GL_COMPILE_STATUS, &compile_ok);
  66. if (0 == compile_ok) {
  67. printCompileError(fs);
  68. } else {
  69. fprintf(stdout, "fs: ok\n");
  70. }
  71.  
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement