1 /* 2 * Copyright 2009-2010 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione <jscipione@gmail.com> 7 * Alex Wilson <yourpalal2@gmail.com> 8 * Artur Wyszynski <harakash@gmail.com> 9 */ 10 11 12 #include "InfoView.h" 13 14 #include <Box.h> 15 #include <Catalog.h> 16 #include <ControlLook.h> 17 #include <GL/gl.h> 18 #include <GL/glu.h> 19 #include <GL/glut.h> 20 #include <GridLayoutBuilder.h> 21 #include <LayoutBuilder.h> 22 #include <Locale.h> 23 #include <Message.h> 24 #include <String.h> 25 #include <StringView.h> 26 27 28 #undef B_TRANSLATION_CONTEXT 29 #define B_TRANSLATION_CONTEXT "InfoView" 30 31 32 const BAlignment kLabelAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET); 33 const BAlignment kValueAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET); 34 35 36 InfoView::InfoView() 37 : 38 BGroupView(B_TRANSLATE("Information"), B_HORIZONTAL) 39 { 40 const char* glRenderer = (const char*)glGetString(GL_RENDERER); 41 if (glRenderer == NULL) 42 glRenderer = B_TRANSLATE("Unknown or missing OpenGL renderer."); 43 BStringView* rendererView = new BStringView(NULL, glRenderer); 44 rendererView->SetExplicitAlignment(kLabelAlignment); 45 rendererView->SetFont(be_bold_font); 46 47 const char* glVendor = (const char*)glGetString(GL_VENDOR); 48 if (glVendor == NULL) 49 glVendor = B_TRANSLATE("Unknown vendor"); 50 BStringView* vendorNameView = new BStringView(NULL, glVendor); 51 vendorNameView->SetExplicitAlignment(kLabelAlignment); 52 53 const char* glVersion = (const char*)glGetString(GL_VERSION); 54 if (glVersion == NULL) 55 glVersion = B_TRANSLATE("Unknown version"); 56 BStringView* glVersionView = new BStringView(NULL, glVersion); 57 glVersionView->SetExplicitAlignment(kLabelAlignment); 58 59 BString apiString("GLU "); 60 apiString << (const char*)gluGetString(GLU_VERSION); 61 apiString << ", GLUT "; 62 apiString << (int32)GLUT_API_VERSION; 63 BStringView* apiVersionView = new BStringView(NULL, apiString.String()); 64 apiVersionView->SetExplicitAlignment(kLabelAlignment); 65 66 BLayoutBuilder::Group<>(this) 67 .AddGroup(B_VERTICAL, 0) 68 .Add(rendererView) 69 .Add(vendorNameView) 70 .Add(glVersionView) 71 .Add(apiVersionView) 72 .End(); 73 } 74 75 76 InfoView::~InfoView() 77 { 78 } 79