私はゲーム エンジンを作成しており、単純な openGL ウィンドウの作成から始めています。Visual Studio 2013 を使用しており、エンジンは dll としてビルドされています。これは、openGL を初期化する dll のコードです。
bool AsGraphicsManager::Initialize(AsWindowCreateStruct pWindow)
{
//first create the error handler
glfwSetErrorCallback(error::glfw_error_callback);
//Initialize the library
if (!glfwInit())
return 0;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#ifdef _DEBUG
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif /* _DEBUG */
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 0);
glfwWindowHint(GLFW_STEREO, GL_TRUE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
glfwWindowHint(GLFW_DEPTH_BITS, 16);
mWindow = new AsWindow(pWindow);
//make the first window the current
glfwMakeContextCurrent(mWindow->mWindow);
//make sure to do this to enable new opengl
glewExperimental = GL_TRUE;
//now initialize glew
GLenum res = glewInit();
if (res != GLEW_OK)
{
printf("Error code: %s While Initializing Glew \n", glewGetErrorString(res));
return false;
}
//input handler
glfwSetKeyCallback(mWindow->mWindow, input::key_callback);
glfwSetScrollCallback(mWindow->mWindow, input::scroll_callback);
glfwSetMouseButtonCallback(mWindow->mWindow, input::mouse_callback);
glfwSetCursorPosCallback(mWindow->mWindow, input::mouse_position_callback);
//nothing went wrong
return true;
}
AsWindowCreateStruct は、次のように定義された構造体です。
struct ASGE_API AsWindowCreateStruct
{
GLushort mHeight;
GLushort mWidth;
GLushort mXPos;
GLushort mYPos;
std::string mWindowTitle;
bool mFullscrean;
AsWindowCreateStruct(GLushort pWindowHeight, GLushort pWindowWidth, GLushort pWindowXPosition, GLushort pWindowYPosition, std::string pWindowTitle, bool pIsFullscrean = false) :
mHeight(pWindowHeight), mWidth(pWindowWidth), mXPos(pWindowXPosition), mYPos(pWindowYPosition), mWindowTitle(pWindowTitle), mFullscrean(pIsFullscrean){}
};
これは、ウィンドウの作成に渡すいくつかのパラメーターとして機能するだけです。mWindow は AsWindow のオブジェクトです。このクラスの定義は重要ではありませんが、使用中のコンストラクターは次のように定義されています。
mHeight = pCreateStruct.mHeight;
mWidth = pCreateStruct.mWidth;
mXPos = pCreateStruct.mXPos;
mYPos = pCreateStruct.mYPos;
mWindowTitle = pCreateStruct.mWindowTitle;
mFullscrean = pCreateStruct.mFullscrean;
mWindow = 0;
//now create the window
if (mFullscrean)
{
mWindow = glfwCreateWindow(mHeight, mWidth, mWindowTitle.c_str(), glfwGetPrimaryMonitor(), nullptr);
if (!mWindow)
{
printf("Error initializing Window \n");
glfwTerminate();
}
}
else
{
mWindow = glfwCreateWindow(mHeight, mWidth, mWindowTitle.c_str(), nullptr, nullptr);
//this needs to happen before seting window position
if (!mWindow)
{
printf("Error initializing Window \n");
glfwTerminate();
}
else
{
//as long as it isn't fullscrean, change the position
glfwSetWindowPos(mWindow, mXPos, mYPos);
}
};
//make the window visible
glfwShowWindow(mWindow);
ここで、pCreateStruct は AsWindowCreateStruct のインスタンスです。
ここで、すべてのコードはさておき、問題は glfwCreateWindow() が常に 0 を返すことです。コンソールに「WGL: 適切なピクセル形式が見つかりませんでした」というエラーが表示されました。約 1 時間デバッグし、ファイル wgl_context.c の 357 行目で呼び出された関数 choosePixelFormat までトレースしました。関数の定義は wgl_context.c の 144 行目にあります。これはすべて GLFW 3.0.4 にあります。このような他の記事を見ましたが、役に立ちませんでした。NVidia GTX 650ti を使用しており、Nvidia の Geforce エクスペリエンスを使用してドライバーを最新の状態に保っています。Windowsはそれらをインストールしていません。ウェブサイトwww.glfw.orgにある GLFW の簡単なプログラムを実行してみましたが、問題なく動作します。これがDLLで実行されていることに関係していると確信していますが、どこから始めればよいかわかりません
さらに情報が必要な場合は、喜んでお知らせします。
編集:
問題は
glfwWindowHint(GL_STEREO, GL_TRUE);