在我的机器上,当我调用 wglCreateContextAttribsARB() 请求 2.0 上下文时,我得到了 2.1.2。
这似乎足以纠正,所以我并不担心。然而,在 friend 的机器上调用相同的代码会给出 4.4 上下文。这有意义吗,还是我应该在某处寻找错误?代码如下。 GKGLLoader 和 GKGLContext 模块是我自己写的,你看他们的用法大概就能明白他们是怎么工作的,我就不说了发布他们的源文件(除非有人认为它可能相关)。
#include <GraphicsKit/GKGLLoader.h>
#include <GraphicsKit/GKGLContext.h>
static
LRESULT CALLBACK DemoWindowProc(
HWND win, UINT msg, WPARAM wparam, LPARAM lparam)
{
if( msg == WM_CLOSE )
{
PostQuitMessage(0);
return 0;
}
return DefWindowProc(win, msg, wparam, lparam);
}
ATOM
RegisterDemoWindowClass(void)
{
WNDCLASSEX cls;
cls.cbSize = sizeof(cls);
cls.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
cls.lpfnWndProc = DemoWindowProc;
cls.cbClsExtra = 0;
cls.cbWndExtra = 0;
cls.hInstance = GetCurrentProcess();
cls.hIcon = NULL;
cls.hCursor = LoadCursor(NULL, IDC_ARROW);
cls.hbrBackground = GetStockObject(BLACK_BRUSH);
cls.lpszMenuName = NULL;
cls.lpszClassName = L"GraphicsDemo";
cls.hIconSm = NULL;
return RegisterClassEx(&cls);
}
HWND
CreateDemoWindow(void)
{
HWND win;
win = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_OVERLAPPEDWINDOW,
L"GraphicsDemo",
L"GraphicsDemo",
WS_TILEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 500,
NULL, NULL, GetCurrentProcess(), NULL
);
return win;
}
BOOL
ChooseDemoPixelFormat(HWND win, int* formatID)
{
unsigned numFormats;
int attribList[] =
{
WGL_DRAW_TO_WINDOW_ARB, TRUE,
WGL_SUPPORT_OPENGL_ARB, TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_DOUBLE_BUFFER_ARB, TRUE,
WGL_SWAP_METHOD_ARB, WGL_SWAP_EXCHANGE_ARB,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
WGL_COLOR_BITS_ARB, 24,
WGL_RED_BITS_ARB, 8,
WGL_GREEN_BITS_ARB, 8,
WGL_BLUE_BITS_ARB, 8,
WGL_ALPHA_BITS_ARB, 8,
0, 0
};
if(wglChoosePixelFormatARB(
GetDC(win), attribList, NULL, 1, formatID, &numFormats))
{
if( numFormats == 0 )
{
_cprintf(
"wglChoosePixelFormatARB() returned no "
"formats [GetLastError(): (0x%X)]\n",
(unsigned)GetLastError());
SetLastError(ERROR_NOT_SUPPORTED);
return FALSE;
}
return TRUE;
}
return FALSE;
}
HGLRC
CreateDemoContext(HWND win)
{
int attribList[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
WGL_CONTEXT_MINOR_VERSION_ARB, 0,
0
};
return wglCreateContextAttribsARB(GetDC(win), NULL, attribList);
}
int
APIENTRY
WinMain(
HINSTANCE instance,
HINSTANCE prevInstance,
LPSTR cmdline,
int showCmd)
{
GKGLContext* dummyCtx;
GKGLLoader* loader;
MSG msg;
GKGLContext* ctx;
HWND win;
HGLRC glrc;
PIXELFORMATDESCRIPTOR pfd;
int formatID;
AllocConsole();
if( ! RegisterDemoWindowClass() )
{
MessageBox(
NULL, L"RegisterDemoWindowClass() failed", L"ERROR", MB_OK);
return 0;
}
win = CreateDemoWindow();
if( win == NULL )
{
MessageBox(
NULL, L"CreateDemoWindow() failed", L"ERROR", MB_OK);
return 0;
}
dummyCtx = GKGLContextNewDummy();
if( dummyCtx == NULL )
{
MessageBox(NULL, L"GKGLDummyWindow() failed", L"ERROR", MB_OK);
return 0;
}
loader = GKGLLoaderNew();
GKGLSetContext(dummyCtx);
#define GKGLProc(major, minor, name, ret, params, paramNames) dummyCtx->name = (void*)GKGLLoaderProcAddress(loader, # name, major, minor);
#define GKGLVoidProc(major, minor, name, ret, params, paramNames) dummyCtx->name = (void*)GKGLLoaderProcAddress(loader, # name, major, minor);
#include <GraphicsKit/GKGLProcs.h>
#include <GraphicsKit/GKWGLProcs.h>
#undef GKGLProc
#undef GKGLVoidProc
if( ! ChooseDemoPixelFormat(win, &formatID) )
{
MessageBox(
NULL, L"ChooseDemoPixelFormat() failed", L"ERROR", MB_OK);
return 0;
}
if( ! SetPixelFormat(GetDC(win), formatID, &pfd) )
{
MessageBox(
NULL, L"SetPixelFormat() failed", L"ERROR", MB_OK);
return 0;
}
glrc = CreateDemoContext(win);
if( glrc == NULL )
{
MessageBox(
NULL, L"CreateDemoContext() failed", L"ERROR", MB_OK);
return 0;
}
GKGLSetContext(NULL);
wglDeleteContext(dummyCtx->glrc);
DestroyWindow(dummyCtx->win);
ctx = GKGLContextNew(win, glrc);
GKGLSetContext(ctx);
#define GKGLProc(major, minor, name, ret, params, paramNames) ctx->name = (void*)GKGLLoaderProcAddress(loader, # name, major, minor);
#define GKGLVoidProc(major, minor, name, ret, params, paramNames) ctx->name = (void*)GKGLLoaderProcAddress(loader, # name, major, minor);
#include <GraphicsKit/GKGLProcs.h>
#include <GraphicsKit/GKWGLProcs.h>
#undef GKGLProc
#undef GKGLVoidProc
_cprintf("OpenGL Vendor: %s\n", glGetString(GL_VENDOR));
_cprintf("OpenGL Renderer: %s\n", glGetString(GL_RENDERER));
_cprintf("OpenGL Version: %s\n", glGetString(GL_VERSION));
_cprintf("OpenGL Shading Language: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
ShowWindow(win, showCmd);
while( TRUE )
{
if( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )
{
if( msg.message == WM_QUIT )
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
glClearColor(0, 1, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
SwapBuffers(GetDC(win));
}
return msg.wParam;
}
最佳答案
这完全符合规范,只要 4.4 上下文是兼容性配置文件。来自WGL_ARB_create_context extension spec :
If a version less than or equal to 3.0 is requested, the context returned may implement any of the following versions:
- Any version no less than that requested and no greater than 3.0.
- Version 3.1, if the GL_ARB_compatibility extension is also implemented.
- The compatibility profile of version 3.2 or greater.
关于c - 当我要求 2.0 时,wglCreateContextAttribsARB() 给了我 4.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25251829/
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭10年前。问题1)我想知道rubyonrails是否有功能类似于primefaces的gem。我问的原因是如果您使用primefaces(http://www.primefaces.org/showcase-labs/ui/home.jsf),开发人员无需担心javascript或jquery的东西。据我所知,JSF是一个规范,基于规范的各种可用实现,prim
我的项目布局如下:-Project-css-import.scss-_sass/main.scssimport.scss的内容是:------@import"main.scss";我期望发生的是将main.scss导入到import.scss中,然后,import.scss将在生成的_site/目录中编译为import.css。相反,我收到以下错误Conversionerror:Therewasanerrorconverting'css/import.scss'.jekyll2.0.3|Error:InvalidCSSafter"-":expectednumberorfunction,
我想在AmazonOpsWorks上使用Ruby2.0,所以我正在尝试以下操作:选择自定义Recipe并将它们设置到我的forkhttps://github.com/aws/opsworks-cookbooks在此处更新所有版本号https://github.com/aws/opsworks-cookbooks/blob/master/ruby/attributes/ruby.rb到2.0值。虽然这似乎没有任何效果。自定义说明书是否会覆盖其内置的说明书?OpsWorks是否使用Recipe中的Ruby配方来进行基本的Ruby设置?同样的问题也适用于Nginx-我可以通过更改Recipe
我正在尝试将Ruby1.9.3应用程序升级到2.0,除了一个小问题外,一切似乎都很顺利。我写了一个模块,我将其包含在我的模型中以覆盖activerecorddestroy。它将现有的destroy方法别名为destroy!,然后覆盖destroy以更改记录上的deleted_at时间戳。仅当我升级到ruby2.0时,destroy!不再破坏记录,但其行为就像我的新覆盖方法一样。知道为什么会这样吗?下面是更相关的代码部分。完整要点here.defself.included(base)base.class_evaldoalias_method:destroy!,:destroyalia
如果我在ruby中有一个接受命名参数的方法...defsmoosh(first:nil,second:nil)first+secondend如果键匹配,将散列传递给该方法的最简单方法是什么:params={first:'peanut',second:'butter'}smoosh(params)以上会产生参数错误。更新:这似乎是Sinatra参数工作方式的问题。当我这样做时:get'a_sinatra_route'dohash=params.clonehash.symbolize_keys!smoosh(hash)end它工作正常。仅自行传递参数时,它不起作用。(即使您可以使用符号
在ruby2.0.0/247或head上试过这个:require'objspace'ObjectSpace.trace_object_allocations->undefinedmethod`trace_object_allocations'forObjectSpace:Module文档说它应该可以工作http://www.ruby-doc.org/stdlib-2.0/libdoc/objspace/rdoc/ObjectSpace.html知道我错过了什么吗? 最佳答案 对于更高的ruby版本,您仍然可能会遇到如下错误:
所以从Rails4.1.x开始,似乎有一种推荐的方法是在应用程序文件夹下使用rails。而不是传统的:railsserverRails官方指南推荐使用bin/railsserver看起来bin/rails正在引用带有附加内容的rails。与rails相比,使用bin/rails的额外好处是什么?第二个问题是——我习惯于使用railsserver、railsconsole等,而不是bin/railsserver、bin/railsconsole。如果不使用bin/rails,我会丢失任何东西吗(比如误加载一些库等)?谢谢。 最佳答案
我正在学习RubyKoans中的练习在about_proxy_object_project.rb中有这段代码:classProxydefinitialize(target_object)@object=target_objectend#Thismethodwasaddedbymedefmethod_missing(method_name,*args,&block)@object.sendmethod_nameendend这样调用:deftest_tv_methods_still_perform_their_functiontv=Proxy.new(Television.new)#Tel
为什么RubyEnumerator默认情况下不像Enumerator::Lazy那样?有没有人想要使用非惰性Enumerator的情况?已编辑:下面是对向后兼容性答案的评论,解释了为什么我还不相信:假设我们已将这些“重大”更改添加到Ruby2.0.0,这是一个主要版本,您将在进行切换之前彻底测试您的代码(特别是如果您要生产),不是吗?编辑#2我怀疑它与效率有关(如果有任何问题请告诉我),所以我做了以下基准测试:(当然有些地方惰性更好。这可能是为了证明为什么Ruby不是一直在使用lazy?)require'fruity'require'prime'comparedolazy{g=Prim
更详细地说,我有一个模块Narf,它为一系列类提供基本功能。具体来说,我想影响所有继承Enumerable的类。所以我在Enumerable中includeNarf。Array是默认包含Enumerable的类。然而,它不受Narf延迟包含在模块中的影响。有趣的是,在包含之后定义的类从Enumerable获取Narf。示例:#ThismoduleprovidesessentialfeaturesmoduleNarfdefnarf?puts"(from#{self.class})ZORT!"endend#IwantallEnumerablestobeabletoNarfmoduleEnu