* Update opengl preflet to fix regression from r38512
* Refactor code, especially layout-related, there were way too many views being created * Remove empty hook methods * Fix a bug which caused the convolution capabilities to be misrepresented as 0x0 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38514 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,230 +1,137 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
|
* Alex Wilson <[email protected]>
|
||||||
* Artur Wyszynski <[email protected]>
|
* Artur Wyszynski <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CapabilitiesView.h"
|
#include "CapabilitiesView.h"
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <GroupLayout.h>
|
#include <ControlLook.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <SpaceLayoutItem.h>
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "Capabilities"
|
#define B_TRANSLATE_CONTEXT "Capabilities"
|
||||||
|
|
||||||
|
|
||||||
void
|
const BAlignment kNameAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
|
||||||
AddStringView(BView* view, const char* viewName, const char* name,
|
const BAlignment kValueAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET);
|
||||||
const char* value, bool spacer)
|
|
||||||
{
|
|
||||||
if (!view)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BRect dummyRect(0, 0, 0, 0);
|
|
||||||
const float kSpacer = 5;
|
|
||||||
|
|
||||||
BString tempViewName(viewName);
|
|
||||||
BStringView *nameView = new BStringView(dummyRect, tempViewName.String(),
|
|
||||||
name, B_FOLLOW_NONE);
|
|
||||||
tempViewName.Append("Value");
|
|
||||||
BStringView *valueView = new BStringView(dummyRect, tempViewName.String(),
|
|
||||||
value, B_FOLLOW_NONE);
|
|
||||||
|
|
||||||
if (spacer) {
|
|
||||||
view->AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(nameView)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(valueView)
|
|
||||||
)
|
|
||||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(kSpacer))
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
view->AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(nameView)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(valueView)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CapabilitiesView::CapabilitiesView()
|
CapabilitiesView::CapabilitiesView()
|
||||||
: BView(B_TRANSLATE("Capabilities"), 0, NULL)
|
:
|
||||||
|
BGridView(B_TRANSLATE("Capabilities"))
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
_AddCapability(GL_AUX_BUFFERS, B_TRANSLATE("Auxiliary buffer(s):"));
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
|
||||||
|
|
||||||
const float kInset = 10;
|
_AddCapability(GL_MAX_MODELVIEW_STACK_DEPTH,
|
||||||
|
B_TRANSLATE("Model stack size:"));
|
||||||
|
|
||||||
int lights = 0;
|
_AddCapability(GL_MAX_PROJECTION_STACK_DEPTH,
|
||||||
int clippingPlanes = 0;
|
B_TRANSLATE("Projection stack size:"));
|
||||||
int modelStack = 0;
|
|
||||||
int projectionStack = 0;
|
|
||||||
int textureStack = 0;
|
|
||||||
int maxTex3d = 0;
|
|
||||||
int maxTex2d = 0;
|
|
||||||
int nameStack = 0;
|
|
||||||
int listStack = 0;
|
|
||||||
int maxPoly = 0;
|
|
||||||
int attribStack = 0;
|
|
||||||
int buffers = 0;
|
|
||||||
int convolutionWidth = 0;
|
|
||||||
int convolutionHeight = 0;
|
|
||||||
int maxIndex = 0;
|
|
||||||
int maxVertex = 0;
|
|
||||||
int textureUnits = 0;
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_LIGHTS, &lights);
|
_AddCapability(GL_MAX_TEXTURE_STACK_DEPTH,
|
||||||
glGetIntegerv(GL_MAX_CLIP_PLANES, &clippingPlanes);
|
B_TRANSLATE("Texture stack size:"));
|
||||||
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &modelStack);
|
|
||||||
glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &projectionStack);
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &textureStack);
|
|
||||||
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTex3d);
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTex2d);
|
|
||||||
glGetIntegerv(GL_MAX_NAME_STACK_DEPTH, &nameStack);
|
|
||||||
glGetIntegerv(GL_MAX_LIST_NESTING, &listStack);
|
|
||||||
glGetIntegerv(GL_MAX_EVAL_ORDER, &maxPoly);
|
|
||||||
glGetIntegerv(GL_MAX_ATTRIB_STACK_DEPTH, &attribStack);
|
|
||||||
glGetIntegerv(GL_AUX_BUFFERS, &buffers);
|
|
||||||
glGetIntegerv(GL_MAX_CONVOLUTION_WIDTH, &convolutionWidth);
|
|
||||||
glGetIntegerv(GL_MAX_CONVOLUTION_HEIGHT, &convolutionHeight);
|
|
||||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxIndex);
|
|
||||||
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &maxVertex);
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &textureUnits);
|
|
||||||
|
|
||||||
BString tempString;
|
_AddCapability(GL_MAX_NAME_STACK_DEPTH, B_TRANSLATE("Name stack size:"));
|
||||||
BView *rootView = new BView("root view", 0, NULL);
|
|
||||||
rootView->SetLayout(new BGroupLayout(B_VERTICAL));
|
|
||||||
|
|
||||||
tempString << (int32) buffers;
|
_AddCapability(GL_MAX_LIST_NESTING, B_TRANSLATE("List stack size:"));
|
||||||
AddStringView(rootView, "Buffers", B_TRANSLATE("Auxiliary buffer(s):"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_ATTRIB_STACK_DEPTH,
|
||||||
tempString << (int32) modelStack;
|
B_TRANSLATE("Attributes stack size:"));
|
||||||
AddStringView(rootView, "ModelStack", B_TRANSLATE("Model stack size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_TEXTURE_SIZE, B_TRANSLATE("Max. 2D texture size:"));
|
||||||
tempString << (int32) projectionStack;
|
|
||||||
AddStringView(rootView, "ProjectionStack",
|
|
||||||
B_TRANSLATE("Projection stack size:"), tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_3D_TEXTURE_SIZE,
|
||||||
tempString << (int32) textureStack;
|
B_TRANSLATE("Max. 3D texture size:"));
|
||||||
AddStringView(rootView, "TextureStack", B_TRANSLATE("Texture stack size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_TEXTURE_UNITS_ARB,
|
||||||
tempString << (int32) nameStack;
|
B_TRANSLATE("Max. texture units:"));
|
||||||
AddStringView(rootView, "NameStack", B_TRANSLATE("Name stack size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_LIGHTS, B_TRANSLATE("Max. lights:"));
|
||||||
tempString << (int32) listStack;
|
|
||||||
AddStringView(rootView, "ListStack", B_TRANSLATE("List stack size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_CLIP_PLANES, B_TRANSLATE("Max. clipping planes:"));
|
||||||
tempString << (int32) attribStack;
|
|
||||||
AddStringView(rootView, "AttribStack", B_TRANSLATE("Attributes stack size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_EVAL_ORDER,
|
||||||
tempString << (int32) maxTex3d;
|
B_TRANSLATE("Max. evaluators equation order:"));
|
||||||
AddStringView(rootView, "MaxTex3D", B_TRANSLATE("Max. 3D texture size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddConvolutionCapability();
|
||||||
tempString << (int32) maxTex2d;
|
|
||||||
AddStringView(rootView, "MaxTex2D", B_TRANSLATE("Max. 2D texture size:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_ELEMENTS_INDICES,
|
||||||
tempString << (int32) textureUnits;
|
B_TRANSLATE("Max. recommended index elements:"));
|
||||||
AddStringView(rootView, "MaxTexUnits", B_TRANSLATE("Max. texture units:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
_AddCapability(GL_MAX_ELEMENTS_VERTICES,
|
||||||
tempString << (int32) lights;
|
B_TRANSLATE("Max. recommended vertex elements:"));
|
||||||
AddStringView(rootView, "MaxLights", B_TRANSLATE("Max. lights:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
BGridLayout* layout = GridLayout();
|
||||||
tempString << (int32) clippingPlanes;
|
layout->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
AddStringView(rootView, "MaxClippingPlanes",
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||||
B_TRANSLATE("Max. clipping planes:"), tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, layout->CountRows(),
|
||||||
tempString << (int32) maxPoly;
|
layout->CountColumns(), 1);
|
||||||
AddStringView(rootView, "MaxPoly",
|
|
||||||
B_TRANSLATE("Max. evaluators equation order:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
float spacing = be_control_look->DefaultItemSpacing();
|
||||||
tempString << (int32) convolutionWidth << "x" << convolutionHeight;
|
layout->SetHorizontalSpacing(spacing / 2.0f);
|
||||||
AddStringView(rootView, "MaxConvultion", B_TRANSLATE("Max. convolution:"),
|
// divide by two to compensate for empty column 1
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
|
||||||
tempString << (int32) maxIndex;
|
|
||||||
AddStringView(rootView, "MaxIndex",
|
|
||||||
B_TRANSLATE("Max. recommended index elements:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
tempString.SetTo("");
|
|
||||||
tempString << (int32) maxVertex;
|
|
||||||
AddStringView(rootView, "MaxVertex",
|
|
||||||
B_TRANSLATE("Max. recommended vertex elements:"),
|
|
||||||
tempString.String(), true);
|
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
||||||
.Add(rootView)
|
|
||||||
.SetInsets(kInset, kInset, kInset, kInset)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CapabilitiesView::~CapabilitiesView()
|
CapabilitiesView::~CapabilitiesView()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CapabilitiesView::MessageReceived(BMessage* message)
|
CapabilitiesView::_AddCapability(GLenum capability, const char* name)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
int value = 0;
|
||||||
default:
|
glGetIntegerv(capability, &value);
|
||||||
BView::MessageReceived(message);
|
_AddCapabilityView(name, BString() << (int32)value);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CapabilitiesView::AttachedToWindow()
|
CapabilitiesView::_AddCapabilityView(const char* name, const char* value)
|
||||||
{
|
{
|
||||||
|
BStringView *nameView = new BStringView(NULL, name);
|
||||||
|
nameView->SetExplicitAlignment(kNameAlignment);
|
||||||
|
|
||||||
|
BStringView *valueView = new BStringView(NULL, value);
|
||||||
|
valueView->SetExplicitAlignment(kValueAlignment);
|
||||||
|
|
||||||
|
// Add the items at the bottom of our grid with a column inbetween
|
||||||
|
int32 row = GridLayout()->CountRows();
|
||||||
|
BLayoutBuilder::Grid<>(this)
|
||||||
|
.Add(nameView, 0, row)
|
||||||
|
.Add(valueView, 2, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CapabilitiesView::DetachedFromWindow()
|
CapabilitiesView::_AddConvolutionCapability()
|
||||||
{
|
{
|
||||||
|
int width = 0;
|
||||||
|
glGetConvolutionParameteriv(GL_CONVOLUTION_2D,
|
||||||
|
GL_MAX_CONVOLUTION_WIDTH, &width);
|
||||||
|
|
||||||
|
int height = 0;
|
||||||
|
glGetConvolutionParameteriv(GL_CONVOLUTION_2D,
|
||||||
|
GL_MAX_CONVOLUTION_HEIGHT, &height);
|
||||||
|
|
||||||
|
BString convolution;
|
||||||
|
convolution << (int32) width << 'x' << (int32) height;
|
||||||
|
_AddCapabilityView(B_TRANSLATE("Max. convolution:"), convolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
|
* Alex Wilson <[email protected]>
|
||||||
* Artur Wyszynski <[email protected]>
|
* Artur Wyszynski <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CAPABILITIES_VIEW_H
|
#ifndef CAPABILITIES_VIEW_H
|
||||||
#define CAPABILITIES_VIEW_H
|
#define CAPABILITIES_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <GridView.h>
|
||||||
|
|
||||||
class CapabilitiesView : public BView {
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
|
||||||
|
class CapabilitiesView : public BGridView {
|
||||||
public:
|
public:
|
||||||
CapabilitiesView();
|
CapabilitiesView();
|
||||||
virtual ~CapabilitiesView();
|
virtual ~CapabilitiesView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
private:
|
||||||
virtual void AttachedToWindow();
|
void _AddCapability(GLenum capability, const char* name);
|
||||||
virtual void DetachedFromWindow();
|
void _AddCapabilityView(const char* name, const char* value);
|
||||||
|
void _AddConvolutionCapability();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CAPABILITIES_VIEW_H */
|
#endif /* CAPABILITIES_VIEW_H */
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
|
* Alex Wilson <[email protected]>
|
||||||
* Artur Wyszynski <[email protected]>
|
* Artur Wyszynski <[email protected]>
|
||||||
*/
|
*/
|
||||||
#include "ExtensionsView.h"
|
#include "ExtensionsView.h"
|
||||||
@@ -24,56 +25,27 @@
|
|||||||
|
|
||||||
|
|
||||||
ExtensionsView::ExtensionsView()
|
ExtensionsView::ExtensionsView()
|
||||||
: BView(B_TRANSLATE("Extensions"), 0, NULL)
|
:
|
||||||
|
BGroupView(B_TRANSLATE("Extensions"), B_VERTICAL)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
|
||||||
|
|
||||||
const float kInset = 10;
|
|
||||||
|
|
||||||
ExtensionsList *extList = new ExtensionsList();
|
ExtensionsList *extList = new ExtensionsList();
|
||||||
|
|
||||||
_AddExtensionsList(extList, (char*) glGetString(GL_EXTENSIONS));
|
_AddExtensionsList(extList, (char*) glGetString(GL_EXTENSIONS));
|
||||||
_AddExtensionsList(extList, (char*) gluGetString(GLU_EXTENSIONS));
|
_AddExtensionsList(extList, (char*) gluGetString(GLU_EXTENSIONS));
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
AddChild(extList);
|
||||||
.Add(extList)
|
GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
.SetInsets(kInset, kInset, kInset, kInset)
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtensionsView::~ExtensionsView()
|
ExtensionsView::~ExtensionsView()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ExtensionsView::MessageReceived(BMessage* message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
default:
|
|
||||||
BView::MessageReceived(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ExtensionsView::AttachedToWindow()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ExtensionsView::DetachedFromWindow()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// #pragma mark
|
// #pragma mark
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ExtensionsView::_AddExtensionsList(ExtensionsList *extList, char* stringList)
|
ExtensionsView::_AddExtensionsList(ExtensionsList *extList, char* stringList)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,19 +9,15 @@
|
|||||||
#ifndef EXTENSIONS_VIEW_H
|
#ifndef EXTENSIONS_VIEW_H
|
||||||
#define EXTENSIONS_VIEW_H
|
#define EXTENSIONS_VIEW_H
|
||||||
|
|
||||||
#include <View.h>
|
#include <GroupView.h>
|
||||||
|
|
||||||
class ExtensionsList;
|
class ExtensionsList;
|
||||||
|
|
||||||
class ExtensionsView : public BView {
|
class ExtensionsView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
ExtensionsView();
|
ExtensionsView();
|
||||||
virtual ~ExtensionsView();
|
virtual ~ExtensionsView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void DetachedFromWindow();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _AddExtensionsList(ExtensionsList *extList, char* stringList);
|
void _AddExtensionsList(ExtensionsList *extList, char* stringList);
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
|
* Alex Wilson <[email protected]>
|
||||||
* Artur Wyszynski <[email protected]>
|
* Artur Wyszynski <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "InfoView.h"
|
#include "InfoView.h"
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <GroupLayout.h>
|
#include <ControlLook.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <SpaceLayoutItem.h>
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
@@ -25,73 +25,35 @@
|
|||||||
#define B_TRANSLATE_CONTEXT "InfoView"
|
#define B_TRANSLATE_CONTEXT "InfoView"
|
||||||
|
|
||||||
|
|
||||||
|
const BAlignment kLabelAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
|
||||||
|
const BAlignment kValueAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET);
|
||||||
|
|
||||||
|
|
||||||
InfoView::InfoView()
|
InfoView::InfoView()
|
||||||
: BView(B_TRANSLATE("Information"), 0, NULL)
|
:
|
||||||
|
BGridView(B_TRANSLATE("Information"))
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
_AddString(B_TRANSLATE("OpenGL version:"),
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
(const char*)glGetString(GL_VERSION));
|
||||||
|
_AddString(B_TRANSLATE("Vendor name:"),
|
||||||
|
(const char*)glGetString(GL_VENDOR));
|
||||||
|
_AddString(B_TRANSLATE("Renderer name:"),
|
||||||
|
(const char*)glGetString(GL_RENDERER));
|
||||||
|
_AddString(B_TRANSLATE("GLU version:"),
|
||||||
|
(const char*)gluGetString(GLU_VERSION));
|
||||||
|
_AddString(B_TRANSLATE("GLUT API version:"),
|
||||||
|
BString() << (int32)GLUT_API_VERSION);
|
||||||
|
|
||||||
BRect dummyRect(0, 0, 0, 0);
|
BGridLayout* layout = GridLayout();
|
||||||
|
layout->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||||
|
|
||||||
BStringView *version = new BStringView(dummyRect, "Version",
|
layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, layout->CountRows(),
|
||||||
B_TRANSLATE("OpenGL version:"), B_FOLLOW_NONE);
|
layout->CountColumns(), 1);
|
||||||
BStringView *versionValue = new BStringView(dummyRect, "VersionVal",
|
|
||||||
(const char*)glGetString(GL_VERSION), B_FOLLOW_NONE);
|
|
||||||
BStringView *vendor = new BStringView(dummyRect, "Vendor",
|
|
||||||
B_TRANSLATE("Vendor name:"), B_FOLLOW_NONE);
|
|
||||||
BStringView *vendorValue = new BStringView(dummyRect, "VendorVal",
|
|
||||||
(const char*)glGetString(GL_VENDOR), B_FOLLOW_NONE);
|
|
||||||
BStringView *renderer = new BStringView(dummyRect, "Renderer",
|
|
||||||
B_TRANSLATE("Renderer name:"), B_FOLLOW_NONE);
|
|
||||||
BStringView *rendererValue = new BStringView(dummyRect, "RendererVal",
|
|
||||||
(const char*)glGetString(GL_RENDERER), B_FOLLOW_NONE);
|
|
||||||
BStringView *gluVersion = new BStringView(dummyRect, "GLUVersion",
|
|
||||||
B_TRANSLATE("GLU version:"), B_FOLLOW_NONE);
|
|
||||||
BStringView *gluVersionValue = new BStringView(dummyRect, "GLUVersionVal",
|
|
||||||
(const char*)gluGetString(GLU_VERSION), B_FOLLOW_NONE);
|
|
||||||
BStringView *glutVersion = new BStringView(dummyRect, "GLUTVersion",
|
|
||||||
B_TRANSLATE("GLUT API version:"), B_FOLLOW_NONE);
|
|
||||||
BString glutApiVer;
|
|
||||||
glutApiVer << (int32)GLUT_API_VERSION;
|
|
||||||
BStringView *glutVersionValue = new BStringView(dummyRect, "GLUTVersionVal",
|
|
||||||
glutApiVer.String(), B_FOLLOW_NONE);
|
|
||||||
|
|
||||||
const float kInset = 10;
|
float spacing = be_control_look->DefaultItemSpacing();
|
||||||
const float kSpacer = 5;
|
layout->SetHorizontalSpacing(spacing / 2.0f);
|
||||||
|
// divide by two to compensate for empty column 1
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(version)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(versionValue)
|
|
||||||
)
|
|
||||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(kSpacer))
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(vendor)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(vendorValue)
|
|
||||||
)
|
|
||||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(kSpacer))
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(renderer)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(rendererValue)
|
|
||||||
)
|
|
||||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(kSpacer))
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(gluVersion)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(gluVersionValue)
|
|
||||||
)
|
|
||||||
.Add(BSpaceLayoutItem::CreateVerticalStrut(kSpacer))
|
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
|
||||||
.Add(glutVersion)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.Add(glutVersionValue)
|
|
||||||
)
|
|
||||||
.Add(BSpaceLayoutItem::CreateGlue())
|
|
||||||
.SetInsets(kInset, kInset, kInset, kInset)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,24 +64,16 @@ InfoView::~InfoView()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoView::MessageReceived(BMessage* message)
|
InfoView::_AddString(const char* label, const char* value)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
BView* labelView = new BStringView(NULL, label);
|
||||||
default:
|
labelView->SetExplicitAlignment(kLabelAlignment);
|
||||||
BView::MessageReceived(message);
|
|
||||||
}
|
BView* valueView = new BStringView(NULL, value);
|
||||||
}
|
valueView->SetExplicitAlignment(kValueAlignment);
|
||||||
|
|
||||||
|
int32 rows = GridLayout()->CountRows();
|
||||||
void
|
BLayoutBuilder::Grid<>(this)
|
||||||
InfoView::AttachedToWindow()
|
.Add(labelView, 0, rows)
|
||||||
{
|
.Add(valueView, 2, rows);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
InfoView::DetachedFromWindow()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,16 +10,15 @@
|
|||||||
#define INFO_VIEW_H
|
#define INFO_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <GridView.h>
|
||||||
|
|
||||||
class InfoView : public BView {
|
class InfoView : public BGridView {
|
||||||
public:
|
public:
|
||||||
InfoView();
|
InfoView();
|
||||||
virtual ~InfoView();
|
virtual ~InfoView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
private:
|
||||||
virtual void AttachedToWindow();
|
void _AddString(const char* label, const char* value);
|
||||||
virtual void DetachedFromWindow();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* INFO_VIEW_H */
|
#endif /* INFO_VIEW_H */
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
|
|
||||||
|
|
||||||
LogoView::LogoView(const BRect& frame)
|
LogoView::LogoView()
|
||||||
: BView(frame, "LogoView", B_FOLLOW_ALL, B_WILL_DRAW
|
:
|
||||||
| B_FULL_UPDATE_ON_RESIZE),
|
BView("LogoView", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE, NULL),
|
||||||
fLogo(NULL)
|
fLogo(NULL)
|
||||||
{
|
{
|
||||||
SetViewColor(255, 255, 255);
|
SetViewColor(255, 255, 255);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
class LogoView : public BView {
|
class LogoView : public BView {
|
||||||
public:
|
public:
|
||||||
LogoView(const BRect& frame);
|
LogoView();
|
||||||
virtual ~LogoView();
|
virtual ~LogoView();
|
||||||
|
|
||||||
virtual void Draw(BRect update);
|
virtual void Draw(BRect update);
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
|
* Alex Wilson <[email protected]>
|
||||||
* Artur Wyszynski <[email protected]>
|
* Artur Wyszynski <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "OpenGLView.h"
|
#include "OpenGLView.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <GroupLayout.h>
|
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GLView.h>
|
||||||
#include <GroupLayout.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <TabView.h>
|
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
|
#include <TabView.h>
|
||||||
|
|
||||||
#include "CapabilitiesView.h"
|
#include "CapabilitiesView.h"
|
||||||
#include "ExtensionsView.h"
|
#include "ExtensionsView.h"
|
||||||
#include "InfoView.h"
|
#include "InfoView.h"
|
||||||
@@ -21,43 +23,34 @@
|
|||||||
|
|
||||||
|
|
||||||
OpenGLView::OpenGLView()
|
OpenGLView::OpenGLView()
|
||||||
: BView("OpenGLView", 0, NULL)
|
:
|
||||||
|
BGroupView("OpenGLView", B_VERTICAL)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
|
||||||
|
|
||||||
const float kInset = 10;
|
BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
|
||||||
BRect dummy(0, 0, 2, 2);
|
|
||||||
|
|
||||||
fGLView = new BGLView(dummy, "gl info", B_FOLLOW_NONE, 0,
|
|
||||||
BGL_RGB | BGL_DOUBLE);
|
BGL_RGB | BGL_DOUBLE);
|
||||||
fGLView->Hide();
|
glView->Hide();
|
||||||
AddChild(fGLView);
|
AddChild(glView);
|
||||||
|
|
||||||
fGLView->LockGL();
|
glView->LockGL();
|
||||||
|
|
||||||
LogoView *logoView = new LogoView(dummy);
|
LogoView *logoView = new LogoView();
|
||||||
|
|
||||||
BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
|
BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
|
||||||
|
tabView->AddTab(new InfoView());
|
||||||
|
tabView->AddTab(new CapabilitiesView());
|
||||||
|
tabView->AddTab(new ExtensionsView());
|
||||||
|
|
||||||
InfoView *infoView = new InfoView();
|
glView->UnlockGL();
|
||||||
tabView->AddTab(infoView);
|
|
||||||
|
|
||||||
CapabilitiesView *capabilitiesView = new CapabilitiesView();
|
GroupLayout()->SetSpacing(0);
|
||||||
tabView->AddTab(capabilitiesView);
|
BLayoutBuilder::Group<>(this)
|
||||||
|
.SetInsets(0, 0, 0, 0)
|
||||||
ExtensionsView *extensionsView = new ExtensionsView();
|
|
||||||
tabView->AddTab(extensionsView);
|
|
||||||
|
|
||||||
fGLView->UnlockGL();
|
|
||||||
|
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
|
||||||
.Add(logoView)
|
.Add(logoView)
|
||||||
.Add(BGroupLayoutBuilder(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.Add(tabView)
|
.Add(tabView)
|
||||||
.SetInsets(kInset, kInset, kInset, kInset)
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
)
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,26 +58,3 @@ OpenGLView::~OpenGLView()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
OpenGLView::MessageReceived(BMessage* message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
default:
|
|
||||||
BView::MessageReceived(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
OpenGLView::AttachedToWindow()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
OpenGLView::DetachedFromWindow()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Haiku Inc. All rights reserved.
|
* Copyright 2009-2010 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
|
* Alex Wilson <[email protected]>
|
||||||
* Artur Wyszynski <[email protected]>
|
* Artur Wyszynski <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,20 +11,12 @@
|
|||||||
#define OPENGL_VIEW_H
|
#define OPENGL_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <GLView.h>
|
#include <GroupView.h>
|
||||||
#include <View.h>
|
|
||||||
|
|
||||||
class OpenGLView : public BView {
|
class OpenGLView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
OpenGLView();
|
OpenGLView();
|
||||||
virtual ~OpenGLView();
|
virtual ~OpenGLView();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
virtual void DetachedFromWindow();
|
|
||||||
|
|
||||||
private:
|
|
||||||
BGLView* fGLView;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* OPENGL_VIEW_H */
|
#endif /* OPENGL_VIEW_H */
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "OpenGLWindow.h"
|
#include "OpenGLWindow.h"
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include "OpenGLView.h"
|
#include "OpenGLView.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user