"SDL_SetVideoMode":找不到标识符
'SDL_SetVideoMode': identifier not found
SDL-lib有问题。我使用的是VS2012 Ultimate,而我实际上使用的是本教程:http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php设置所有内容,我一步一步做了几次,但我仍然有问题,这是我的代码,非常简单:
#include <iostream>
#include <SDL.h>
SDL_Surface * ekran = NULL;
int main (int argc, char *args [] )
{
SDL_Init( SDL_INIT_EVERYTHING );
ekran = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
SDL_Flip( ekran );
SDL_Delay( 2000 );
SDL_Quit();
return 0;
}
我有这样的错误:
error C3861: 'SDL_SetVideoMode': identifier not found
error C3861: 'SDL_Flip': identifier not found
下面是如何在SDL2中替换SDL_SetVideoMode()的示例。为了进行比较,对初始化SDL的旧方法进行了注释,并将其与新方法一起保留。基本上,SDL2创建一个带有标题的窗口,然后创建一个附加到它的曲面,而SDL1单独创建一个曲面,然后调用窗口管理器为其命名。
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "SDL video init failed: %sn", SDL_GetError());
return 1;
}
// SDL_Surface *screenSurface = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE);
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
window = SDL_CreateWindow("Sphere Rendering",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (window == NULL) {
fprintf(stderr, "Window could not be created: %sn", SDL_GetError());
return 1;
}
screenSurface = SDL_GetWindowSurface(window);
if (!screenSurface) {
fprintf(stderr, "Screen surface could not be created: %sn", SDL_GetError());
SDL_Quit();
return 1;
}
// SDL_WM_SetCaption("Sphere Rendering", NULL);
再次查看该教程页面。您的代码与它不匹配(例如SDL_SetVideoMode()已不存在)。您的代码使用SDL1.2,(更新的)教程使用SDL2.0。您是否使用该页面的旧缓存版本?
相关文章:
- 设置 Visual Studio for MPI: 找不到标识符错误
- 找不到标识符合并
- 从子类访问模板类成员时出现"找不到标识符"错误
- OpenCV 3 错误"CV_FOURCC":找不到标识符
- im调用函数时找不到标识符?
- clock_gettime:在 Windows 10 的 Visual Studio 中找不到标识符
- 英特尔 TBB - "初始化关键部分 Ex":找不到标识符编译器错误
- 找不到标识符.C3861
- 在void tryagain()上找不到标识符
- 在C 类中找不到标识符
- 找不到标识符,尝试在 C++ 中显示数组值
- 我遇到:错误2错误C3861:"fx":找不到标识符
- OpenGL - 'glTexSubImage3D':找不到标识符
- "GetProcessIdOfThread":找不到标识符
- 错误 C3861:"strcpy_y":找不到标识符
- "printf":找不到标识符
- 错误 C3861:"initNode":找不到标识符
- 在抽象类中找不到C++标识符
- 错误 C3861:"getGaborKernel":找不到标识符
- 错误 C3861:"对齐":找不到标识符