sdl

How to get the color of a specific pixel from SDL_Surface?

折月煮酒 提交于 2021-01-05 07:25:24
问题 I'm trying to get the RGB/RGBA color of pixels from a SDL_Surface. I've found this code on the internet but it returns strange numbers (67372036 for a pixel that is 0 red, 0 green, 255 blue) Uint32 get_pixel32(SDL_Surface *surface, int x, int y) { Uint32 *pixels = (Uint32 *)surface->pixels; return pixels[(y * surface->w) + x]; } This it the code I've been using: Uint32 data = get_pixel32(gSurface, 0, 0); printf("%i", data); I'm not sure if my pixels have a 32bit format but other pictures didn

How to get the color of a specific pixel from SDL_Surface?

元气小坏坏 提交于 2021-01-05 07:24:06
问题 I'm trying to get the RGB/RGBA color of pixels from a SDL_Surface. I've found this code on the internet but it returns strange numbers (67372036 for a pixel that is 0 red, 0 green, 255 blue) Uint32 get_pixel32(SDL_Surface *surface, int x, int y) { Uint32 *pixels = (Uint32 *)surface->pixels; return pixels[(y * surface->w) + x]; } This it the code I've been using: Uint32 data = get_pixel32(gSurface, 0, 0); printf("%i", data); I'm not sure if my pixels have a 32bit format but other pictures didn

在Code::Blocks中使用SDL

为君一笑 提交于 2021-01-04 10:15:03
1首先你需要下载SDL头文件和二进制文件。 你可以在SDL的官方网站上找到它们 向下滚动到Development Libraries部分 下载Mingw32开发包。 打开gz压缩包,里面应该有个tar压缩包。 打开tar压缩包 ,里面应该有一个文件夹。 将这个文件夹拷贝到你喜欢的任意地方。 在本教程中,我把它放在C:\根目录 2启动Code:Blocks,然后进入设置菜单里的编译器和调试器。 3单击搜索目录选项卡中的编译器选项卡,单击添加: 然后将你解压出来的SDL目录中的“include”文件夹加入列表中。 4然后在连接器选项卡下面添加SDL目录中的“lib”文件夹: 5现在你需要将SDL目录中“bin”文件夹下的SDL.dll拷贝到你将要建立工程的地方。在编译程序时,你需要将SDL.dll和编译生成的exe放在同一个目录中。 另外,你也可以将SDL.dll拷贝到 “C:\WINDOWS\SYSTEM32”目录下,这样虽然SDL.dll与你的SDL程序不在同一个目录下,但程序仍能找到它。当然,如果你在使用64位的Windows系统,你就得把dll放于“C:\Windows\SysWOW64”目录中。 可是,这样处理存在一个问题:如果你有多个使用不同版本SDL库的应用程序,这会导致版本冲突。如果你将SDL 1.2.8放于System32中,而应用程序使用的是1.2.13

在Visual Studio.NET 2010 Express中使用SDL扩展库

拥有回忆 提交于 2021-01-04 09:27:43
“在本节课中,你将学会安装SDL_image扩展库。如果你掌握了安装这一个扩展库的方法,那么你将能够安装所有的扩展库。 1向下滚动到Binary部分,下载Windows开发包。 每个扩展库都有3个必备的部分: 1.头文件(*.h) 2.静态库文件(*.lib) 3.动态库文件(*.dll) 无论你在安装哪个扩展库,它们的安装方法都几乎一模一样。打开zip压缩包,里面应该有一个文件夹。打开这个文件夹,里面应该包含两个子文件夹。 2首先,打开 include 子文件夹,你会看到一个头文件。将这个头文件解压出来,并把它与你在第一课中从SDL目录中解压出来的其它头文件放到同一个文件夹中。例如,我将 SDL 1.2.12 解压到" C:\ ",那么我会将头文件“ SDL_image.h ” (或者是“ SDL_ttf.h ”、 “ SDL_mixer.h ”)放到“ C:\SDL-1.2.12\include\SDL\ ”。3下面,将压缩包中的 lib 子文件夹中的 lib 文件 解压到你的 SDL 的 lib文件夹 中。在我的例子中,那就是“ C:\SDL-1.2.12\lib\ ”。4现在将压缩包中所有的dll解压出来,并将它们与你的exe放到同一个文件夹中。 和前面的一样,你可以把它们拷贝到“C:\WINDOWS\SYSTEM32”下 (对于64位Windows系统,那就是“C:

'“SDL.h” no such file or directory found' when compiling

混江龙づ霸主 提交于 2020-12-27 08:19:25
问题 Here's a piece of my current Makefile: CFLAGS = -O2 -Wall -pedantic -std=gnu++11 `sdl-config --cflags --libs` -lSDL_mixer I have libsdl installed properly, SDL.h is in /usr/include/sdl where it belongs, but it just won't compile. I also have the line #include "SDL.h" in my .h files, but still no go. Anyone knows why? 回答1: If the header file is /usr/include/sdl/SDL.h and your code has: #include "SDL.h" You need to either fix your code: #include "sdl/SDL.h" Or tell the preprocessor where to

How to use SDL with gcc?

↘锁芯ラ 提交于 2020-12-27 07:16:37
问题 I download SDL source at 'https://www.libsdl.org' I use cmake and get library. libSDL2.a libSDL2main.a libSDL2-2.0.so libSDL2-2.0.so.0 libSDL2-2.0.so.0.4.0 I write main.c to test SDL. #include <SDL.h> int main() { SDL_Init(SDL_INIT_VIDEO); SDL_Quit(); return 0; } I make lib directory. I move *.a file and include directory. vim main.c mkdir lib mv libSDL2.a libSDL2main.a ./lib mv /home/gakgu/다운로드/SDL2-2.0.4/include ./ Then try compile. gcc -W -Wall -o main main.c -Iinclude -Llib -lSDL2

How to use SDL with gcc?

安稳与你 提交于 2020-12-27 07:15:55
问题 I download SDL source at 'https://www.libsdl.org' I use cmake and get library. libSDL2.a libSDL2main.a libSDL2-2.0.so libSDL2-2.0.so.0 libSDL2-2.0.so.0.4.0 I write main.c to test SDL. #include <SDL.h> int main() { SDL_Init(SDL_INIT_VIDEO); SDL_Quit(); return 0; } I make lib directory. I move *.a file and include directory. vim main.c mkdir lib mv libSDL2.a libSDL2main.a ./lib mv /home/gakgu/다운로드/SDL2-2.0.4/include ./ Then try compile. gcc -W -Wall -o main main.c -Iinclude -Llib -lSDL2

How to use SDL with gcc?

社会主义新天地 提交于 2020-12-27 07:15:07
问题 I download SDL source at 'https://www.libsdl.org' I use cmake and get library. libSDL2.a libSDL2main.a libSDL2-2.0.so libSDL2-2.0.so.0 libSDL2-2.0.so.0.4.0 I write main.c to test SDL. #include <SDL.h> int main() { SDL_Init(SDL_INIT_VIDEO); SDL_Quit(); return 0; } I make lib directory. I move *.a file and include directory. vim main.c mkdir lib mv libSDL2.a libSDL2main.a ./lib mv /home/gakgu/다운로드/SDL2-2.0.4/include ./ Then try compile. gcc -W -Wall -o main main.c -Iinclude -Llib -lSDL2

How to use SDL with gcc?

只愿长相守 提交于 2020-12-27 07:14:07
问题 I download SDL source at 'https://www.libsdl.org' I use cmake and get library. libSDL2.a libSDL2main.a libSDL2-2.0.so libSDL2-2.0.so.0 libSDL2-2.0.so.0.4.0 I write main.c to test SDL. #include <SDL.h> int main() { SDL_Init(SDL_INIT_VIDEO); SDL_Quit(); return 0; } I make lib directory. I move *.a file and include directory. vim main.c mkdir lib mv libSDL2.a libSDL2main.a ./lib mv /home/gakgu/다운로드/SDL2-2.0.4/include ./ Then try compile. gcc -W -Wall -o main main.c -Iinclude -Llib -lSDL2

How to use SDL with gcc?

只谈情不闲聊 提交于 2020-12-27 07:13:58
问题 I download SDL source at 'https://www.libsdl.org' I use cmake and get library. libSDL2.a libSDL2main.a libSDL2-2.0.so libSDL2-2.0.so.0 libSDL2-2.0.so.0.4.0 I write main.c to test SDL. #include <SDL.h> int main() { SDL_Init(SDL_INIT_VIDEO); SDL_Quit(); return 0; } I make lib directory. I move *.a file and include directory. vim main.c mkdir lib mv libSDL2.a libSDL2main.a ./lib mv /home/gakgu/다운로드/SDL2-2.0.4/include ./ Then try compile. gcc -W -Wall -o main main.c -Iinclude -Llib -lSDL2