如何将 SDL2_gfxPrimitives 添加到我的 visual studio 2019?
How to add SDL2_gfxPrimitives to my visual studio 2019?
我正在尝试使用 SDL2 在 visual studio 2019 年创建一个图形项目。
我使用本教程设法将它与我的 visual studio 连接起来:
https://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvc2019/index.php
我想要圆圈、直线、矩形等作为我的输出,因此需要 SDL_gfx。问题是我无法将它与我的项目联系起来。我从这里下载它:
https://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/
有人可以帮我把它和我的 visual studio 连接起来吗?
这是我发现的一个简单示例:
#include <SDL.h>
#include <SDL2_gfxPrimitives.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
SDL_Log("SDl cant start %s", SDL_GetError());
exit(1);
}
SDL_Window *window = SDL_CreateWindow("SDL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 440, 360, 0);
if (window == NULL) {
SDL_Log("Window cant be generated %s", SDL_GetError());
exit(1);
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
if (renderer == NULL) {
SDL_Log("Renderer cannot be generated %s", SDL_GetError());
exit(1);
}
SDL_RenderClear(renderer);
int x, y, r;
r = 50;
x = 100;
y = 100;
circleRGBA(renderer, x, y, r, 255, 0, 0, 255);
circleRGBA(renderer, x + r, y, r, 0, 255, 0, 255);
circleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 255);
x = 280;
y = 100;
aacircleRGBA(renderer, x, y, r, 255, 0, 0, 255);
aacircleRGBA(renderer, x + r, y, r, 0, 255, 0, 255);
aacircleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 255);
x = 100;
y = 280;
filledCircleRGBA(renderer, x, y, r, 255, 0, 0, 255);
filledCircleRGBA(renderer, x + r, y, r, 0, 255, 0, 255);
filledCircleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 255);
x = 280;
y = 280;
filledCircleRGBA(renderer, x, y, r, 255, 0, 0, 96);
filledCircleRGBA(renderer, x + r, y, r, 0, 255, 0, 96);
filledCircleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 96);
stringRGBA(renderer, 110, 350, "Press the x to exit", 255, 255, 255, 255);
SDL_RenderPresent(renderer);
SDL_Event ev;
while (SDL_WaitEvent(&ev) && ev.type != SDL_QUIT) {
/* SDL_RenderPresent(renderer); - in case of MacOS Mojave */
}
SDL_Quit();
return 0;
}
据我所知,您应该 link SDL 库和 SDL2_gfx 库到您的项目。
首先,您应该找到您下载的文件。并遵循以下步骤:
1、Additional Include Directories中添加头文件的路径(属性 - >c/c++ -> General -> Additional Include Directories)
2,将.lib文件的路径添加到Additional Library Directories(属性 -> linker -> General -> Additional Library Directories)
3、Additional Dependencies(属性 -> linker -> input -> Additional Dependencies)
添加.lib文件名及其扩展名
我正在尝试使用 SDL2 在 visual studio 2019 年创建一个图形项目。 我使用本教程设法将它与我的 visual studio 连接起来: https://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvc2019/index.php
我想要圆圈、直线、矩形等作为我的输出,因此需要 SDL_gfx。问题是我无法将它与我的项目联系起来。我从这里下载它: https://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/
有人可以帮我把它和我的 visual studio 连接起来吗?
这是我发现的一个简单示例:
#include <SDL.h>
#include <SDL2_gfxPrimitives.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
SDL_Log("SDl cant start %s", SDL_GetError());
exit(1);
}
SDL_Window *window = SDL_CreateWindow("SDL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 440, 360, 0);
if (window == NULL) {
SDL_Log("Window cant be generated %s", SDL_GetError());
exit(1);
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
if (renderer == NULL) {
SDL_Log("Renderer cannot be generated %s", SDL_GetError());
exit(1);
}
SDL_RenderClear(renderer);
int x, y, r;
r = 50;
x = 100;
y = 100;
circleRGBA(renderer, x, y, r, 255, 0, 0, 255);
circleRGBA(renderer, x + r, y, r, 0, 255, 0, 255);
circleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 255);
x = 280;
y = 100;
aacircleRGBA(renderer, x, y, r, 255, 0, 0, 255);
aacircleRGBA(renderer, x + r, y, r, 0, 255, 0, 255);
aacircleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 255);
x = 100;
y = 280;
filledCircleRGBA(renderer, x, y, r, 255, 0, 0, 255);
filledCircleRGBA(renderer, x + r, y, r, 0, 255, 0, 255);
filledCircleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 255);
x = 280;
y = 280;
filledCircleRGBA(renderer, x, y, r, 255, 0, 0, 96);
filledCircleRGBA(renderer, x + r, y, r, 0, 255, 0, 96);
filledCircleRGBA(renderer, x + r * cos(3.1415 / 3), y - r * sin(3.1415 / 3), r, 0, 0, 255, 96);
stringRGBA(renderer, 110, 350, "Press the x to exit", 255, 255, 255, 255);
SDL_RenderPresent(renderer);
SDL_Event ev;
while (SDL_WaitEvent(&ev) && ev.type != SDL_QUIT) {
/* SDL_RenderPresent(renderer); - in case of MacOS Mojave */
}
SDL_Quit();
return 0;
}
据我所知,您应该 link SDL 库和 SDL2_gfx 库到您的项目。
首先,您应该找到您下载的文件。并遵循以下步骤:
1、Additional Include Directories中添加头文件的路径(属性 - >c/c++ -> General -> Additional Include Directories)
2,将.lib文件的路径添加到Additional Library Directories(属性 -> linker -> General -> Additional Library Directories)
3、Additional Dependencies(属性 -> linker -> input -> Additional Dependencies)
添加.lib文件名及其扩展名