Giter VIP home page Giter VIP logo

go-sfml's People

Contributors

teh-cmc avatar telroshan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-sfml's Issues

graphics.SfRenderWindow_drawText should accept a nil parameter for RenderStates

This would be more consistent with the underlying CSFML behavior, which allows you to pass in NULL for the third parameter. It's quite cumbersome to figure out how to create a default RenderStates struct that would cause the text to appear. I haven't been able to figure it out, and all of the tutorials on the SFML website simply don't use RenderStates. Example:

package main

import (
	"runtime"
	"gopkg.in/teh-cmc/go-sfml.v24/graphics"
	"gopkg.in/teh-cmc/go-sfml.v24/window"
	"gopkg.in/teh-cmc/go-sfml.v24/system"
)

func init() {
	runtime.LockOSThread()
}

func main() {
	videoMode := window.NewSfVideoMode()
	defer window.DeleteSfVideoMode(videoMode)

	videoMode.SetWidth(800)
	videoMode.SetHeight(600)
	videoMode.SetBitsPerPixel(32)

	contextSettings := window.NewSfContextSettings()
	defer window.DeleteSfContextSettings(contextSettings)
	renderingWindow := graphics.SfRenderWindow_create(
		videoMode,
		"RPG",
		uint(window.SfResize|window.SfClose),
		contextSettings)
	defer window.SfWindow_destroy(renderingWindow)

	event := window.NewSfEvent()
	defer window.DeleteSfEvent(event)

	font := graphics.SfFont_createFromFile("Arial.ttf")
	defer graphics.SfFont_destroy(font)

	text := graphics.SfText_create()
	defer graphics.SfText_destroy(text)

	vector := system.NewSfVector2f()
	defer system.DeleteSfVector2f(vector)

	for window.SfWindow_isOpen(renderingWindow) > 0 {
		for window.SfWindow_pollEvent(renderingWindow, event) > 0 {
			if event.GetXtype() == window.SfEventType(window.SfEvtClosed) {
				return
			}
		}
		graphics.SfRenderWindow_clear(renderingWindow, graphics.SfColor_fromRGB(69, 67, 67))
		// Write Hello world! to the screen
		graphics.SfText_setFont(text, font)
		graphics.SfText_setFillColor(text, graphics.GetSfWhite())
		graphics.SfText_setCharacterSize(text, 24)
		graphics.SfText_setString(text, "Hello world!")
		vector.SetX(400)
		vector.SetY(300)
		graphics.SfText_setPosition(text, vector)
                // Crashed because 3rd parameter is nil
		graphics.SfRenderWindow_drawText(renderingWindow, text, nil)
		graphics.SfRenderWindow_display(renderingWindow)
	}
}

A lot of compilation warnings on Ubuntu 20.04

I started using your project inside mine, a porting in go of a N-bodies simulation.
When i run go build or go test or go run i get all these compilation warnings:

# gopkg.in/teh-cmc/go-sfml.v24/graphics
Graphics_wrap.c: In function ‘_wrap_sfRenderWindow_capture_graphics_23698568018502eb’:
Graphics_wrap.c:5697:3: warning: ‘sfRenderWindow_capture’ is deprecated [-Wdeprecated-declarations]
 5697 |   result = (sfImage *)sfRenderWindow_capture((struct sfRenderWindow const *)arg1);
      |   ^~~~~~
In file included from /usr/include/SFML/Graphics.h:46,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/RenderWindow.h:556:46: note: declared here
  556 | CSFML_GRAPHICS_API CSFML_DEPRECATED sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow);
      |                                              ^~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setFloatParameter_graphics_23698568018502eb’:
Graphics_wrap.c:6405:3: warning: ‘sfShader_setFloatParameter’ is deprecated [-Wdeprecated-declarations]
 6405 |   sfShader_setFloatParameter(arg1,(char const *)arg2,arg3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:421:42: note: declared here
  421 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloatParameter(sfShader* shader, const char* name, float x);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setFloat2Parameter_graphics_23698568018502eb’:
Graphics_wrap.c:6426:3: warning: ‘sfShader_setFloat2Parameter’ is deprecated [-Wdeprecated-declarations]
 6426 |   sfShader_setFloat2Parameter(arg1,(char const *)arg2,arg3,arg4);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:444:42: note: declared here
  444 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat2Parameter(sfShader* shader, const char* name, float x, float y);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setFloat3Parameter_graphics_23698568018502eb’:
Graphics_wrap.c:6449:3: warning: ‘sfShader_setFloat3Parameter’ is deprecated [-Wdeprecated-declarations]
 6449 |   sfShader_setFloat3Parameter(arg1,(char const *)arg2,arg3,arg4,arg5);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:468:42: note: declared here
  468 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setFloat4Parameter_graphics_23698568018502eb’:
Graphics_wrap.c:6474:3: warning: ‘sfShader_setFloat4Parameter’ is deprecated [-Wdeprecated-declarations]
 6474 |   sfShader_setFloat4Parameter(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:493:42: note: declared here
  493 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setVector2Parameter_graphics_23698568018502eb’:
Graphics_wrap.c:6500:3: warning: ‘sfShader_setVector2Parameter’ is deprecated [-Wdeprecated-declarations]
 6500 |   sfShader_setVector2Parameter(arg1,(char const *)arg2,arg3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:516:42: note: declared here
  516 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setVector2Parameter(sfShader* shader, const char* name, sfVector2f vector);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setVector3Parameter_graphics_23698568018502eb’:
Graphics_wrap.c:6526:3: warning: ‘sfShader_setVector3Parameter’ is deprecated [-Wdeprecated-declarations]
 6526 |   sfShader_setVector3Parameter(arg1,(char const *)arg2,arg3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:539:42: note: declared here
  539 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setVector3Parameter(sfShader* shader, const char* name, sfVector3f vector);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setColorParameter_graphics_23698568018502eb’:
Graphics_wrap.c:6552:3: warning: ‘sfShader_setColorParameter’ is deprecated [-Wdeprecated-declarations]
 6552 |   sfShader_setColorParameter(arg1,(char const *)arg2,arg3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:567:42: note: declared here
  567 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setColorParameter(sfShader* shader, const char* name, sfColor color);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setTransformParameter_graphics_23698568018502eb’:
Graphics_wrap.c:6578:3: warning: ‘sfShader_setTransformParameter’ is deprecated [-Wdeprecated-declarations]
 6578 |   sfShader_setTransformParameter(arg1,(char const *)arg2,arg3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:590:42: note: declared here
  590 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setTransformParameter(sfShader* shader, const char* name, sfTransform transform);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setTextureParameter_graphics_23698568018502eb’:
Graphics_wrap.c:6597:3: warning: ‘sfShader_setTextureParameter’ is deprecated [-Wdeprecated-declarations]
 6597 |   sfShader_setTextureParameter(arg1,(char const *)arg2,(struct sfTexture const *)arg3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:623:42: note: declared here
  623 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setTextureParameter(sfShader* shader, const char* name, const sfTexture* texture);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphics_wrap.c: In function ‘_wrap_sfShader_setCurrentTextureParameter_graphics_23698568018502eb’:
Graphics_wrap.c:6614:3: warning: ‘sfShader_setCurrentTextureParameter’ is deprecated [-Wdeprecated-declarations]
 6614 |   sfShader_setCurrentTextureParameter(arg1,(char const *)arg2);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/SFML/Graphics.h:47,
                 from Graphics_wrap.c:229:
/usr/include/SFML/Graphics/Shader.h:646:42: note: declared here
  646 | CSFML_GRAPHICS_API CSFML_DEPRECATED void sfShader_setCurrentTextureParameter(sfShader* shader, const char* name);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What am I doing wrong?

"Undefined reference to" errors when compiling basic_window example on Ubuntu 22.04

Output of go build or go run

# basic_window
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlendAlpha_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0xc9d): undefined reference to `sfBlendAlpha'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlendAdd_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0xced): undefined reference to `sfBlendAdd'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlendMultiply_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0xd3d): undefined reference to `sfBlendMultiply'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlendNone_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0xd8d): undefined reference to `sfBlendNone'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlack_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1d70): undefined reference to `sfBlack'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlack_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1da5): undefined reference to `sfBlack'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfWhite_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1dee): undefined reference to `sfWhite'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfWhite_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1e23): undefined reference to `sfWhite'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfRed_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1e6c): undefined reference to `sfRed'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfRed_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1ea1): undefined reference to `sfRed'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfGreen_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1eea): undefined reference to `sfGreen'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfGreen_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1f1f): undefined reference to `sfGreen'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlue_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1f68): undefined reference to `sfBlue'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfBlue_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1f9d): undefined reference to `sfBlue'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfYellow_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x1fe6): undefined reference to `sfYellow'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfYellow_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x201b): undefined reference to `sfYellow'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfMagenta_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x2064): undefined reference to `sfMagenta'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfMagenta_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x2099): undefined reference to `sfMagenta'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfCyan_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x20e2): undefined reference to `sfCyan'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfCyan_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x2117): undefined reference to `sfCyan'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfTransparent_set_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x2160): undefined reference to `sfTransparent'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfTransparent_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0x2195): undefined reference to `sfTransparent'
/usr/bin/ld: /tmp/go-link-1656247100/000002.o: in function `_wrap_sfTransform_Identity_get_graphics_0e245b41439e98a6':
Graphics_wrap.c:(.text+0xd528): undefined reference to `sfTransform_Identity'
collect2: error: ld returned 1 exit status

output of go env

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tomcroasdale/.cache/go-build"
GOENV="/home/tomcroasdale/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/tomcroasdale/go/pkg/mod"
GONOPROXY="github.com/Gigfinder-io/*"
GONOSUMDB="github.com/Gigfinder-io/*"
GOOS="linux"
GOPATH="/home/tomcroasdale/go"
GOPRIVATE="github.com/Gigfinder-io/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.7"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tomcroasdale/go-sfml/examples/basic_window/go.mod"
GOWORK=""
CGO_CFLAGS="-I/home/tomcroasdale/SFML/2.5.1/include -w"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-L/home/tomcroasdale/SFML/2.5.1/lib/gcc"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1250995538=/tmp/go-build -gno-record-gcc-switches"

Consider renaming examples/go

Running go get -u gopkg.in/teh-cmc/go-sfml.v24/... compiles and installs the go example into $GOPATH/bin. For users with $GOPATH/bin in their $PATH, the go example program may gain precedence over the go tool of the Go distribution.

(Win64) Incompatible type for argument 3 of 'sfRenderTexture_createWithSettings'

When building basic_window example (Win10 64bit) there is a compilation error:

Graphics_wrap.c: In function '_wrap_sfRenderTexture_createWithSettings_graphics_0e245b41439e98a6':
Graphics_wrap.c:4902:76: error: incompatible type for argument 3 of 'sfRenderTexture_createWithSettings'
 4902 |   result = (sfRenderTexture *)sfRenderTexture_createWithSettings(arg1,arg2,(sfContextSettings const *)arg3);
      |                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                            |
      |                                                                            const sfContextSettings *
In file included from d:\development\libs\CSFML\include/SFML/Graphics.h:45:
d:\development\libs\CSFML\include/SFML/Graphics/RenderTexture.h:68:131: note: expected 'sfContextSettings' but argument is of type 'const sfContextSettings *'
   68 | CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, sfContextSettings settings);
      |
~~~~~~~~~~~~~~~~~~^~~~~~~~

sfRenderTexture_createWithSettings in CSFML RenderTexture.h is indeed declared as accepting value object sfContextSettings, not the const pointer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.