代码正确的 SDL 错误
Errors with SDL with correct code
这不是紧急问题,但我只是在与 SDL 取得联系时想知道一些事情。
所以,我开始阅读 this tutorial 并实现了以下代码片段:
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Delay(2000);
SDL_Quit();
在教程中,据说控制台 window 应该在 2 秒后打开和关闭。我正在使用 eclipse,而 运行 没有任何反应。这似乎是问题中的 , but in contrast I am using Linux. And the other thing is, that I can run it from the console and it happens nothing too. After that, I read the other tutorial 问题,并插入以下行以创建 window:
SDL_Window *window = 0;
window = SDL_CreateWindow("Hello World!",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_SHOWN);
这对我的问题没有任何改变,没有显示 window,但是如果我将 SDL_Init()
的输出写入控制台,它 returns '0'(成功)同时运行 来自 eclipse 和 '-1'(一些错误代码),而 运行 来自终端。我从 optirun(eclipse 和终端中的最终程序)开始。
在那之后,我只是尝试实现教程的其余部分,并使用 SDL 等创建了一个 OpenGL window。我没有改变任何其他东西,但它适用于 eclipse 和终端内,现在显示 window。
有没有人知道为什么这现在有效以及为什么 eclipse 和终端之间存在差异?
没有任何反应是什么意思?
如果你在 运行 程序时甚至没有得到控制台 window 那么你应该请求它,即在 VS 上它将是 Linker->SubSystem->Console.
And the other thing is, that I can run it from the console and it happens nothing too.
你期望会发生什么?控制台 window 已经打开,所以程序应该在 2 秒内什么都不做然后退出。
while running from eclipse and '-1' .. Has anybody an idea why this works now and why there was the difference between eclipse and the terminal?
调用 SDL_GetError() 并找出你自己! :)
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
printf("SDL_Init failed: %s\n", SDL_GetError());
}
这不是紧急问题,但我只是在与 SDL 取得联系时想知道一些事情。
所以,我开始阅读 this tutorial 并实现了以下代码片段:
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Delay(2000);
SDL_Quit();
在教程中,据说控制台 window 应该在 2 秒后打开和关闭。我正在使用 eclipse,而 运行 没有任何反应。这似乎是问题中的
SDL_Window *window = 0;
window = SDL_CreateWindow("Hello World!",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640, 480,
SDL_WINDOW_SHOWN);
这对我的问题没有任何改变,没有显示 window,但是如果我将 SDL_Init()
的输出写入控制台,它 returns '0'(成功)同时运行 来自 eclipse 和 '-1'(一些错误代码),而 运行 来自终端。我从 optirun(eclipse 和终端中的最终程序)开始。
在那之后,我只是尝试实现教程的其余部分,并使用 SDL 等创建了一个 OpenGL window。我没有改变任何其他东西,但它适用于 eclipse 和终端内,现在显示 window。
有没有人知道为什么这现在有效以及为什么 eclipse 和终端之间存在差异?
没有任何反应是什么意思? 如果你在 运行 程序时甚至没有得到控制台 window 那么你应该请求它,即在 VS 上它将是 Linker->SubSystem->Console.
And the other thing is, that I can run it from the console and it happens nothing too.
你期望会发生什么?控制台 window 已经打开,所以程序应该在 2 秒内什么都不做然后退出。
while running from eclipse and '-1' .. Has anybody an idea why this works now and why there was the difference between eclipse and the terminal?
调用 SDL_GetError() 并找出你自己! :)
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
printf("SDL_Init failed: %s\n", SDL_GetError());
}