簡體   English   中英

C ++ SDL紋理錯誤Microsoft Visual Studio 2013

[英]C++ SDL texture Error Microsoft Visual Studio 2013

我正在嘗試運行此代碼,但它一直給我一個錯誤。 我將SDL2_image.lib復制到debug文件夾中,但沒有成功。 我處於編程的開端,因此請耐心等待。

錯誤:錯誤1錯誤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()聲明的標頭:

#include <SDL/SDL_image.h>

它是SDL的獨立擴展庫,除了包含該標頭之外,您還需要將該庫與項目鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM