本文整理汇总了C++中ContextFormat类的典型用法代码示例。如果您正苦于以下问题:C++ ContextFormat类的具体用法?C++ ContextFormat怎么用?C++ ContextFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContextFormat类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int /*argc*/, char * /*argv*/[])
{
info() << "Usage:";
info() << "\t" << "ESC" << "\t\t" << "Close example";
info() << "\t" << "ALT + Enter" << "\t" << "Toggle fullscreen";
info() << "\t" << "F11" << "\t\t" << "Toggle fullscreen";
info() << "\t" << "F10" << "\t\t" << "Toggle vertical sync";
info() << "\t" << "F5" << "\t\t" << "Reload shaders";
info() << "\t" << "Space" << "\t\t" << "Reset camera";
info() << "\t" << "Left Mouse" << "\t" << "Pan scene";
info() << "\t" << "Right Mouse" << "\t" << "Rotate scene";
info() << "\t" << "Mouse Wheel" << "\t" << "Zoom scene";
ContextFormat format;
format.setVersion(3, 1);
format.setForwardCompatible(true);
Window::init();
Window window;
window.setEventHandler(new EventHandler());
if (!window.create(format, "Bindless Texture Example"))
return 1;
window.show();
return MainLoop::run();
}
示例2: variations
/** This example shows how to create multiple windows with each having its own
OpenGL context. Further, the events of all windows are handled within a
single event handler. This allows, e.g., reuse of painting functionality
with minor, windows specific variations (e.g., different views).
*/
int main(int /*argc*/, char * /*argv*/[])
{
info() << "Usage:";
info() << "\t" << "ESC" << "\t\t" << "Close example";
info() << "\t" << "ALT + Enter" << "\t" << "Toggle fullscreen";
info() << "\t" << "F11" << "\t\t" << "Toggle fullscreen";
info() << "\t" << "F10" << "\t\t" << "Toggle vertical sync";
ContextFormat format;
format.setVersion(3, 1);
format.setForwardCompatible(true);
Window::init();
Window windows[8];
for (int i = 0; i < 8; ++i)
{
windows[i].setEventHandler(new EventHandler());
if (!windows[i].create(format, "Multiple Contexts Example", 320, 240))
return 1;
windows[i].setQuitOnDestroy(i == 0 || rand() % 4 == 0);
windows[i].show();
}
return MainLoop::run();
}
示例3: main
/** This example shows ... .
*/
int main(int /*argc*/, char* /*argv*/[])
{
ContextFormat format;
format.setVersion(3, 0);
format.setDepthBufferSize(16);
Window window;
window.setEventHandler(new EventHandler());
window.create(format, "Camera Path Example");
window.context()->setSwapInterval(Context::VerticalSyncronization);
window.show();
return MainLoop::run();
}
示例4: main
/**
* @brief This example shows how to set up a sparse texture and then map/unmap pages using the ARB_sparse_texture extension.
*
* See http://www.opengl.org/registry/specs/ARB/sparse_texture.txt
*/
int main(int /*argc*/, char * /*argv*/[])
{
globjects::info() << "Usage:";
globjects::info() << "\t" << "ESC" << "\t\t" << "Close example";
globjects::info() << "\t" << "ALT + Enter" << "\t" << "Toggle fullscreen";
globjects::info() << "\t" << "F11" << "\t\t" << "Toggle fullscreen";
ContextFormat format;
format.setVersion(3, 0);
Window window;
window.setEventHandler(new EventHandler());
if (!window.create(format, "Sparse Texture Example"))
return 1;
window.context()->setSwapInterval(Context::VerticalSyncronization);
window.show();
return MainLoop::run();
}
示例5: main
int main(int /*argc*/, char * /*argv*/[])
{
info() << "Usage:";
info() << "\t" << "ESC" << "\t\t" << "Close example";
info() << "\t" << "ALT + Enter" << "\t" << "Toggle fullscreen";
info() << "\t" << "F11" << "\t\t" << "Toggle fullscreen";
info() << "\t" << "F10" << "\t\t" << "Toggle vertical sync";
ContextFormat format;
format.setVersion(3, 0);
Window::init();
Window window;
window.setEventHandler(new EventHandler());
if (!window.create(format, "OpenGL States Example"))
return 1;
window.show();
return MainLoop::run();
}
示例6: verifyVersionAndProfile
bool ContextFormat::verifyVersionAndProfile(const ContextFormat & requested, const ContextFormat & created)
{
const bool sameProfiles(requested.profile() == created.profile());
if (!sameProfiles)
{
warning() << "Profile mismatch for the current context: "
<< profileString(requested.profile()) << " requested, "
<< profileString(created.profile()) << " created.";
}
if (requested.version() != created.version())
{
warning() << "Version mismatch for the current context: "
<< requested.version().toString() << " requested, "
<< created.version().toString() << " created.";
if (requested.profile() == Profile::Core)
return false;
}
return sameProfiles;
}
示例7: CreatePBufferOffscreenContext
static already_AddRefed<GLContextWGL>
CreatePBufferOffscreenContext(const gfxIntSize& aSize,
const ContextFormat& aFormat)
{
#define A1(_a,_x) do { _a.AppendElement(_x); } while(0)
#define A2(_a,_x,_y) do { _a.AppendElement(_x); _a.AppendElement(_y); } while(0)
nsTArray<int> attrs;
A2(attrs, LOCAL_WGL_SUPPORT_OPENGL_ARB, LOCAL_GL_TRUE);
A2(attrs, LOCAL_WGL_DRAW_TO_PBUFFER_ARB, LOCAL_GL_TRUE);
A2(attrs, LOCAL_WGL_DOUBLE_BUFFER_ARB, LOCAL_GL_FALSE);
A2(attrs, LOCAL_WGL_ACCELERATION_ARB, LOCAL_WGL_FULL_ACCELERATION_ARB);
A2(attrs, LOCAL_WGL_COLOR_BITS_ARB, aFormat.colorBits());
A2(attrs, LOCAL_WGL_RED_BITS_ARB, aFormat.red);
A2(attrs, LOCAL_WGL_GREEN_BITS_ARB, aFormat.green);
A2(attrs, LOCAL_WGL_BLUE_BITS_ARB, aFormat.blue);
A2(attrs, LOCAL_WGL_ALPHA_BITS_ARB, aFormat.alpha);
A2(attrs, LOCAL_WGL_DEPTH_BITS_ARB, aFormat.depth);
A2(attrs, LOCAL_WGL_STENCIL_BITS_ARB, aFormat.stencil);
if (aFormat.alpha > 0) {
A2(attrs, LOCAL_WGL_BIND_TO_TEXTURE_RGBA_ARB, LOCAL_GL_TRUE);
} else {
A2(attrs, LOCAL_WGL_BIND_TO_TEXTURE_RGB_ARB, LOCAL_GL_TRUE);
}
A2(attrs, LOCAL_WGL_DOUBLE_BUFFER_ARB, LOCAL_GL_FALSE);
A2(attrs, LOCAL_WGL_STEREO_ARB, LOCAL_GL_FALSE);
A1(attrs, 0);
nsTArray<int> pbattrs;
A2(pbattrs, LOCAL_WGL_TEXTURE_TARGET_ARB, LOCAL_WGL_TEXTURE_2D_ARB);
if (aFormat.alpha > 0) {
A2(pbattrs, LOCAL_WGL_TEXTURE_FORMAT_ARB, LOCAL_WGL_TEXTURE_RGBA_ARB);
} else {
A2(pbattrs, LOCAL_WGL_TEXTURE_FORMAT_ARB, LOCAL_WGL_TEXTURE_RGB_ARB);
}
A1(pbattrs, 0);
UINT numFormats = 256;
int formats[256];
if (!sWGLLibrary.fChoosePixelFormat(gSharedWindowDC,
attrs.Elements(), NULL,
numFormats, formats, &numFormats)
|| numFormats == 0)
{
return nsnull;
}
// XXX add back the priority choosing code here
int chosenFormat = formats[0];
if (!IsValidSizeForFormat(gSharedWindowDC, chosenFormat, aSize))
return nsnull;
HANDLE pbuffer = sWGLLibrary.fCreatePbuffer(gSharedWindowDC, chosenFormat,
aSize.width, aSize.height,
pbattrs.Elements());
if (!pbuffer) {
return nsnull;
}
HDC pbdc = sWGLLibrary.fGetPbufferDC(pbuffer);
NS_ASSERTION(pbdc, "expected a dc");
HGLRC context;
if (sWGLLibrary.HasRobustness()) {
int attribs[] = {
LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
NULL
};
context = sWGLLibrary.fCreateContextAttribs(pbdc, nsnull, attribs);
} else {
context = sWGLLibrary.fCreateContext(pbdc);
}
if (!context) {
sWGLLibrary.fDestroyPbuffer(pbuffer);
return false;
}
nsRefPtr<GLContextWGL> glContext = new GLContextWGL(aFormat,
nsnull,
pbuffer,
pbdc,
context,
chosenFormat);
return glContext.forget();
}
示例8: verifyPixelFormat
bool ContextFormat::verifyPixelFormat(
const ContextFormat & requested
, const ContextFormat & created)
{
std::vector<std::string> issues;
const bool sameSwapBehaviors(requested.swapBehavior() == created.swapBehavior());
if (!sameSwapBehaviors)
{
warning() << "Swap behavior mismatch for the current context: "
<< swapBehaviorString(requested.swapBehavior()) << " requested, "
<< swapBehaviorString(created.swapBehavior()) << " created.";
}
if (requested.depthBufferSize())
{
if (!created.depthBufferSize())
issues.push_back("- Depth Buffer requested, but none created.");
else
verifyBufferSize(requested.depthBufferSize(), created.depthBufferSize()
, "- Depth Buffer", issues);
}
verifyBufferSize(requested.redBufferSize(), created.redBufferSize()
, "- Red Buffer", issues);
verifyBufferSize(requested.greenBufferSize(), created.greenBufferSize()
, "- Green Buffer", issues);
verifyBufferSize(requested.blueBufferSize(), created.blueBufferSize()
, "- Blue Buffer", issues);
verifyBufferSize(requested.alphaBufferSize(), created.alphaBufferSize()
, "- Alpha Buffer", issues);
if (requested.stencilBufferSize())
{
if (!created.stencilBufferSize())
issues.push_back("- Stencil Buffer requested, but none created.");
else
verifyBufferSize(requested.stencilBufferSize(), created.stencilBufferSize()
, "- Stencil Buffer", issues);
}
if (requested.stereo() && !created.stereo())
issues.push_back("- Stereo Buffering requested, but not initialized.");
if (requested.samples())
{
if (!created.samples())
issues.push_back("- Sample Buffers requested, but none initialized.");
else
verifyBufferSize(requested.samples(), created.samples(), "- Samples ", issues);
}
if (issues.empty())
return true;
warning() << "Pixelformat mismatch for the current context:";
for (const std::string & issue : issues)
warning() << issue;
return false;
}