Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GLInfo.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Small app to display GL infos
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <Application.h>
  5. #include <Window.h>
  6. #include <OutlineListView.h>
  7. #include <ScrollView.h>
  8. #include <GLView.h>
  9. #include <String.h>
  10. #include <GL/gl.h>
  11. #include <GL/glu.h>
  12. #define GLUT_INFO 1
  13. #ifdef GLUT_INFO
  14. #include <GL/glut.h>
  15. #endif
  16. class GLInfoWindow : public BWindow
  17. {
  18. public:
  19. GLInfoWindow(BRect frame);
  20. virtual bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return true; }
  21. private:
  22. BGLView *gl;
  23. BOutlineListView *list;
  24. BScrollView *scroller;
  25. };
  26. class GLInfoApp : public BApplication
  27. {
  28. public:
  29. GLInfoApp();
  30. private:
  31. GLInfoWindow *window;
  32. };
  33. GLInfoApp::GLInfoApp()
  34. : BApplication("application/x-vnd.OBOS-GLInfo")
  35. {
  36. window = new GLInfoWindow(BRect(50, 50, 350, 350));
  37. }
  38. GLInfoWindow::GLInfoWindow(BRect frame)
  39. : BWindow(frame, "OpenGL Info", B_TITLED_WINDOW, 0)
  40. {
  41. BRect r = Bounds();
  42. char *s;
  43. BString l;
  44. // Add a outline list view
  45. r.right -= B_V_SCROLL_BAR_WIDTH;
  46. list = new BOutlineListView(r, "GLInfoList", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES);
  47. scroller = new BScrollView("GLInfoListScroller", list, B_FOLLOW_ALL_SIDES,
  48. B_WILL_DRAW | B_FRAME_EVENTS, false, true);
  49. gl = new BGLView(r, "opengl", B_FOLLOW_ALL_SIDES, 0, BGL_RGB | BGL_DOUBLE);
  50. gl->Hide();
  51. AddChild(gl);
  52. AddChild(scroller);
  53. Show();
  54. LockLooper();
  55. // gl->LockGL();
  56. list->AddItem(new BStringItem("OpenGL", 0));
  57. s = (char *) glGetString(GL_VENDOR);
  58. if (s) {
  59. l = ""; l << "Vendor Name: " << s;
  60. list->AddItem(new BStringItem(l.String(), 1));
  61. }
  62. s = (char *) glGetString(GL_VERSION);
  63. if (s) {
  64. l = ""; l << "Version: " << s;
  65. list->AddItem(new BStringItem(l.String(), 1));
  66. }
  67. s = (char *) glGetString(GL_RENDERER);
  68. if (s) {
  69. l = ""; l << "Renderer Name: " << s;
  70. list->AddItem(new BStringItem(l.String(), 1));
  71. }
  72. s = (char *) glGetString(GL_EXTENSIONS);
  73. if (s) {
  74. list->AddItem(new BStringItem("Extensions", 1));
  75. while (*s) {
  76. char extname[255];
  77. int n = strcspn(s, " ");
  78. strncpy(extname, s, n);
  79. extname[n] = 0;
  80. list->AddItem(new BStringItem(extname, 2));
  81. if (! s[n])
  82. break;
  83. s += (n + 1); // next !
  84. }
  85. }
  86. list->AddItem(new BStringItem("GLU", 0));
  87. s = (char *) gluGetString(GLU_VERSION);
  88. if (s) {
  89. l = ""; l << "Version: " << s;
  90. list->AddItem(new BStringItem(l.String(), 1));
  91. }
  92. s = (char *) gluGetString(GLU_EXTENSIONS);
  93. if (s) {
  94. list->AddItem(new BStringItem("Extensions", 1));
  95. while (*s) {
  96. char extname[255];
  97. int n = strcspn(s, " ");
  98. strncpy(extname, s, n);
  99. extname[n] = 0;
  100. list->AddItem(new BStringItem(extname, 2));
  101. if (! s[n])
  102. break;
  103. s += (n + 1); // next !
  104. }
  105. }
  106. #ifdef GLUT_INFO
  107. list->AddItem(new BStringItem("GLUT", 0));
  108. l = "API version: "; l << GLUT_API_VERSION;
  109. list->AddItem(new BStringItem(l.String(), 1));
  110. #endif
  111. // gl->UnlockGL();
  112. UnlockLooper();
  113. }
  114. int main(int argc, char *argv[])
  115. {
  116. GLInfoApp *app = new GLInfoApp;
  117. app->Run();
  118. delete app;
  119. return 0;
  120. }