C++ SDL 纹理错误 Microsoft Visual Studio 2013
C++ SDL texture Error Microsoft Visual Studio 2013
我正在尝试 运行 这段代码,但它一直给我一个错误。
我在调试文件夹中复制了 SDL2_image.lib 但没有用。
我正处于编程的开始,所以请耐心等待。
错误:
错误 1 error C3861: 'IMG_LoadTexture': 找不到标识符
错误 2 IntelliSense:标识符 "IMG_LoadTexture" 未定义
#include<SDL/SDL.h>
#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
bool quit = false;
//*Initializing Window;
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = NULL;
window = SDL_CreateWindow("Game Test", 100, 100, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
//*If game Crushes;
if (window == NULL)
{
cout << "The game window is not working";
}
//*Creating Update Function
SDL_Renderer* render = NULL;
render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
SDL_Event* mainEvent = new SDL_Event();
//*End Update Function
//*Adding Textures;
SDL_Texture* grass_image = NULL;
grass_image = IMG_LoadTexture(render, "grass.bmp");
//*Creating a Sprite;
SDL_Rect grass_rect;
grass_rect.x = 10;
grass_rect.y = 50;
grass_rect.w = 250;
grass_rect.h = 250;
//*Content Of the Window;
while (!quit && mainEvent->type!=SDL_QUIT)
{
SDL_PollEvent(mainEvent);
SDL_RenderClear(render);
SDL_RenderCopy(render, grass_image, NULL, &grass_rect);
SDL_RenderPresent(render);
}
//*End Window Content
//*Memory Cleaning
SDL_DestroyWindow(window);
SDL_DestroyRenderer(render);
delete mainEvent;
//*End Memory Cleaning
return 0;
}
您未包含包含 IMG_LoadTexture()
声明的 header:
#include <SDL/SDL_image.h>
它是一个单独的 SDL 扩展库,除了 header 之外,您还需要 link 该库与您的项目一起使用。
我正在尝试 运行 这段代码,但它一直给我一个错误。 我在调试文件夹中复制了 SDL2_image.lib 但没有用。 我正处于编程的开始,所以请耐心等待。
错误:
错误 1 error C3861: 'IMG_LoadTexture': 找不到标识符
错误 2 IntelliSense:标识符 "IMG_LoadTexture" 未定义
#include<SDL/SDL.h>
#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
bool quit = false;
//*Initializing Window;
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = NULL;
window = SDL_CreateWindow("Game Test", 100, 100, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
//*If game Crushes;
if (window == NULL)
{
cout << "The game window is not working";
}
//*Creating Update Function
SDL_Renderer* render = NULL;
render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
SDL_Event* mainEvent = new SDL_Event();
//*End Update Function
//*Adding Textures;
SDL_Texture* grass_image = NULL;
grass_image = IMG_LoadTexture(render, "grass.bmp");
//*Creating a Sprite;
SDL_Rect grass_rect;
grass_rect.x = 10;
grass_rect.y = 50;
grass_rect.w = 250;
grass_rect.h = 250;
//*Content Of the Window;
while (!quit && mainEvent->type!=SDL_QUIT)
{
SDL_PollEvent(mainEvent);
SDL_RenderClear(render);
SDL_RenderCopy(render, grass_image, NULL, &grass_rect);
SDL_RenderPresent(render);
}
//*End Window Content
//*Memory Cleaning
SDL_DestroyWindow(window);
SDL_DestroyRenderer(render);
delete mainEvent;
//*End Memory Cleaning
return 0;
}
您未包含包含 IMG_LoadTexture()
声明的 header:
#include <SDL/SDL_image.h>
它是一个单独的 SDL 扩展库,除了 header 之外,您还需要 link 该库与您的项目一起使用。