Closed Suceru closed 4 years ago
Hi @Suceru! Sorry for the late reply. Could you try this method and see if it works for you? I will add it to the README if it's simple enough to follow.
Hi @Suceru! Sorry for the late reply. Could you try this method and see if it works for you? I will add it to the README if it's simple enough to follow. @veeableful I'm not familiar with mingw, i downloaded
SDL2_gfx.dll
and put it in the\bin
directory likeSDL_image
. Then copy all the.h
files to thex86_64-w64-mingw32\include\SDL2
folder, and change the file name and header file to 2 (eg:like SDL2_gfxPrimitives.h). When usinggo run C:\Users\fidax\go\src\github.com\veandco\go-sdl2\.go-sdl2-examples\examples\gfx
command, it promptsld.exe: cannot find -lSDL2_gfx
copy to
change the file names
In CMD run
go run gfx.go
Hi @Suceru, have you tried to put it inside lib
as well?
@veeableful
Sorry, when I did this, I didn't know what I should do next.
I have put SDL2_gfx.dll
in \lib
, Run ... .
# github.com/veandco/go-sdl2/gfx
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:91:90: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_pixelColor
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:103:86: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_pixelRGBA
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:113:81: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_hlineColor
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:126:92: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_hlineRGBA
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:136:81: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_vlineColor
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:149:92: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_vlineRGBA
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:160:91: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_rectangleColor
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:174:102: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_rectangleRGBA
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:186:104: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_roundedRectangleColor
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:201:115: cannot use _cgo0 (type *_Ctype_struct_SDL_Renderer) as type *_Ctype_struct_SDL_Surface in argument to _Cfunc_roundedRectangleRGBA
go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:201:115: too many errors
Hmm that's strange.. are you using sdl.Surface
instead of sdl.Renderer
with gfx
functions?
@veeableful I am directly running the code for the example.
go\src\github.com\veandco\go-sdl2.go-sdl2-examples\examples\gfx\gfx.go
That's what he originally wrote. So, I don't known
Hi @Suceru, I see that you are using sdl.Surface
(at least from what I can tell in the screenshot above) and the example doesn't have sdl.Surface
. Are you using the latest go-sdl2
?
Yes, go-sdl2
is the latest version. There is no SDL_surface
code in the examples, only SDL_renderer
.
The location of this error
message comes from the file SDL_gfx.go
. # github.com/veandco/go-sdl2/gfx go\src\github.com\veandco\go-sdl2\gfx\sdl_gfx.go:91:90: cannot use _cgo0 (type _Ctype_struct_SDL_Renderer) as type _Ctype_struct_SDL_Surface in argument to _Cfunc_pixelColor
My other SDL2 configurations can be used normally, but sdl_gfx
does not know how to install. I put the sdl_gfx.dll
in the link you posted earlier into the \ bin
and \ lib
folders (I don't know if it is correct). In addition, copy the .h file in the downloaded sdl_gfx
archive to the\included\sdl2
folder and then#include <SDL/SDL.h>
inside changed to #include <SDL2/SDL.h>
When the#include <SDL2 / SDL.h>
error is not prompted, show the SDL_surface cannot be used
. My intuition is that only go-sdl_gfx
is correct, there should be problems in the setting part ofmingw
Hmm that's weird... Could you post the definition of pixelColor
in the SDL2_gfxPrimitives.h
file? It should be in the include
directory. The one I have looks like this:
SDL2_GFXPRIMITIVES_SCOPE int pixelColor(SDL_Renderer * renderer, Sint16 x, Sint16 y, Uint32 color);
@veeableful Oh, thank you guys, I have configured.
First of all, I mistakenly regarded the gfx of SDL
as the gfx of SDL2
(I saw two versions 1.0.4
and 2.0.25
on the website, I didn't pay much attention to 2.0.25
as the latest version of SDL2). Then I copied the .h and .c files
of SDL2-gfx
to the \include\SDL2 of mingw
folder and it worked fine.
The correct is:
The err is:
put .h and .c to \SDL2
put SDL_gfx.dll to \bin and \lib
(If this are missing , will be errs:1. exit status 3221225781
and 2. ```
/x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2_gfx
collect2.exe: error: ld returned 1 exit status
<img width="582" alt="SDL2_gfx-dll" src="https://user-images.githubusercontent.com/20983345/72696786-81527300-3b78-11ea-9dd4-a72021db1537.PNG">
@veeableful It turns out that the method you proposed earlier is correct, as long as you download the .dll file and .h and .c files
, you can use it.
oh, thank you!!!
No problem @Suceru! Glad I could help 😃
Mingw is currently installed, its directory is in
D:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64
, the SDL_image and ttf are installed to copy the entireSDL2_image-devel-2.0.5-mingw.tar.gz\SDL2_image-devel-2.0.5-mingw.tar\SDL2_image-2.0.5\x86_64-w64-mingw32
folder toD:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\x86_64-w64-mingw32
But SDL_gfx is different from SDL_ttf, it does not have the x86_64-w64-mingw32 folder, I do not understand how to install SDL_gfx-2.0.26.tar.gz to Windows 10 .