FAQ Database Discussion Community


C++ SFML Segfault between renderer and object

c++,pointers,segmentation-fault,sfml
Before I start, I'm going to apologize ahead of time for any seemingly obvious mistakes I may have made. I'm pretty in over my head at this point and there's probably quite a few errors in here. Any suggestions on fixing what I have, or better ways of setting up...

Linker error with SFML

c++,linker-error,sfml
I get a series of errors when running g++ -lsfml-window -lsfml-graphics -lsfml-system main.cpp on the example SFML code, when running Ubuntu, SFML 2.2 and g++ 4.8.2. I've tried reinstalling SFML from the package manager (libsfml-dev) and nothing works. Example SFML Code: #include <SFML/Graphics.hpp> #include <string> int main() { sf::RenderWindow window(sf::VideoMode(200,...

SFML code completion not working for Code::Blocks 13.12 on Ubuntu 14.04

c++,ubuntu,codeblocks,sfml,code-completion
EDIT: NOT WORKING ON ANY IDE, SEEMS TO BE A GENERAL MISCONFIG So hello guys. It's taking a bit longer to set my Ubuntu system to code with SFML and C++ than expected. This should be one of the last problems really. So my C::B 13.12 install via apt-get on...

Process returned 139 (0x8B) Segmentation fault

c++,multidimensional-array,vector,sfml
I got the following problem: I'm somewhat new to C++, looked up how to make multidimensional arrays without predefinition of size, I found something and tried it. I got a Process returned 139 (0x8B) as an answer. I looked up everything I found about it but It didn't help me...

4th Shooting statement not working in SFML game

c++,sfml
I am currently creating a game using SFML 2.0. Basically it is a top-down shooter and I am having difficulty with the statement below. Which shoots an arrow when the space bar is pressed. There are four statements which depend on the way the player sprite (archSprite) is facing. This...

How to read a bitmap from the Windows Clipboard

c++,windows,bitmap,sfml
I am writing an extremely small C++ program to help me animate sprites. I'd like it to take data I copy to the clipboard from photoshop, manipulate it in my program, then overwrite the clipboard with the transform. The problem though is that I'm not sure how to read the...

Mouse input isn't correct to world coordinates

c++,sfml
There are probably millions of these questions but, I can't get the coordinates of the mouse so that they line up with the program coordinate system, when the window is re-sized. I've tried mapPixelToCoords() and getting the mouse coordinates using sf::Event::MouseButton or sf::Mouse, but to no avail. This problem is...

Unresolved Externals using Cmake and Visual Studio 2013

c++,visual-studio-2013,cmake,sfml,unresolved-external
I've been having problems with cmake and Visual Studio 2013 with SFML. When I try and compile my program, I'm getting unresolved externals for everything that uses SFML. I've had problems with this on multiple machines, and also with some other libraries in some case. I'm using the following command...

Passing control of a drawing window “deeper” into a program?

c++,design,graphics,sfml
I am using SFML 2.3 to control the graphics in my program. I need a class to be able to access the window, to draw to it even if that class was not the one that originally created the window (does not have ownership). E.g. the Battle class needs to...

C++ Verifying Sent Packets on Real Time Network using SFML

c++,network-programming,sfml,fps
I am building a networkable program that transfers graphical changes on a 2d screen with SFML UDP libraries. I want to run close to all of the processing on the host server, and only send the graphic updates and command return values to the client. I want to make a...

SFML Networking Error: undefined references des when linking

c++,networking,codeblocks,sfml,mingw32
I recently started learning SFML, but when I got to the section of Networking, I always get a lot of errors: obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD1Ev[__ZN2sf11TcpListenerD1Ev]+0x1): undefined reference to `_imp___ZTVN2sf11TcpListenerE' obj\Release\main.o:main.cpp:(.text$_ZN2sf11TcpListenerD1Ev[__ZN2sf11TcpListenerD1Ev]+0xb): undefined reference to `_imp___ZN2sf6SocketD2Ev' obj\Release\main.o:main.cpp:(.text$_ZN2sf9TcpSocketD1Ev[__ZN2sf9TcpSocketD1Ev]+0x1): undefined reference to `_imp___ZTVN2sf9TcpSocketE'...

SFML: I'm making a Animal Crossing clone, but I'm having problems rendering the Player

c++,sfml
Recently, I decided to make an Animal Crossing clone in C++ and SFML 2.1. But I'm having some issues. The Player won't show up when commanded to be rendered. The program will compile and run just fine but the player just won't show up. Here's my code: #include <iostream> #include...

Focus sprite by leftclick and then remove focus by leftclick again. (C++ and SFML 2.2)

c++,sfml
In the following code a sprite can by clicked with left mouse button and then moved around freely. Then you have to hit the right button to "free" it again. Now what is, if I want to use left button for removing the focus, instead of right button. Is this...

Error running .exe compiled with i586-mingw32msvc-g++ and SFML on linux

c++,makefile,sfml,mingw32,wine
EDIT: Thanks random downvoter! EDIT 2: Thanks @πάνταῥεῖ for explaining what was wrong with the question. When running a debugger I get Program received signal SIGSEGV, Segmentation fault. 0x0046f4c6 in ?? () EDIT 3: This only happens if I run the cross compiled program. If I compile the program in...

How to check collision on 2D map in SFML?

c++,arrays,2d,collision-detection,sfml
I have one RectangleShape for wall and I draw this one object for every "1" on my 2D map: int map[5][8] = { { 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 1, 0, 1, 1,...

Calculating velocity from speed and direction

c++,sfml,trigonometry,angle
I have an object which wants to move from point A to point B, at a certain speed (using SFML C++). sf::Vector2f aPos; //sf::Vector2f has two members x and y, stored as floats sf::Vector2f bPos; float speed; //pixels per tick I want to use these variables to find out a...

OpenGL 3.3 - I can only bind to GL_TEXTURE0

c++,opengl,textures,sfml
I've been trying to follow an OpenGL-3.3 tutorial for some time but it appears that I can only bind a texture to GL_TEXTURE0 otherwise I get a black square. Example: This works glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glActiveTexture(GL_TEXTURE0 + 0); glBindTexture(GL_TEXTURE_2D, texture1); glUniform1i(glGetUniformLocation(shader.program, "our_texture1"), 0); shader.bind(); glBindVertexArray(vertex_array); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT,...

Objects rotating around another object keep accelerating

c++,rotation,sfml
Ok so I'm still new to programming and I've been trying to work on a scene graph and whenever I rotate an object its children keep accelerating around it when all I want them to do is rotate around the parent object at the same speed it (the parent object)...

Tricky bugs in refacored pong from sfml examples

c++,qt-creator,sfml,pong
I am learning SFML by pong example. Original code can be found there. I am trying to put this lines in a function and then make a call: sf::RenderWindow window( sf::VideoMode( gameWidth, gameHeight, 32 ), "SFML Pong", sf::Style::Titlebar | sf::Style::Close ); window.setVerticalSyncEnabled( true ); sf::RenderWindow CreateWindow( int width, int height,...

Unwanted database file being generated, how to prevent and remove?

c++,sql-server,visual-studio-2013,sfml,visual-c++-2013
When generating a new C++ project - specifically, I create a new "Empty Project", the directory the file is stored in seems to contain an .sdf file. This seems to be generated whenever I open the project in Visual Studio 2013, even after I delete it. I also seem unable...

Tile-based Movement and Animation

c++,animation,sprite,sfml
I am currently working on a demo, just to get to grips of how to make a game. It might turn into something in the future, but for now, it's just for learning. My demo is, I guess, influenced by The Legend of Zelda. It has that top-down look that...

The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz could not be located in the dynamic link library sfml-graphics-2.dll

c++,sfml
Today I decided to download, install, and attempt to use SFML 2.2. I also downloaded Code::Blocks with the MinGW compiler. I set up everything and installed everything correctly (or so I thought) and tried to run a sample code to see if it would work: #include <SFML/Graphics.hpp> int main() {...

CMake issues with trying to include my source files

c++,cmake,sfml,clion
I am trying to use the CLion IDE on Linux and I am migrating my SFML application over. It insists I use CMake which I am currently having problems with. cmake_minimum_required(VERSION 2.6) project(SFML2) include_directories("${PROJECT_BINARY_DIR} src/") include_directories("${YOUR_DIRECTORY} src") # Define sources and executable set(EXECUTABLE_NAME "SFML") add_executable(${EXECUTABLE_NAME} src/SFML.cpp) # Detect and add...

Movement of sprite using fixed time step

c++,game-engine,game-physics,sfml,movement
I have this loop: sf::Clock clock; sf::Time timeSinceLastUpdate = sf::Time::Zero; while (mWindow.isOpen()) { processEvents(); timeSinceLastUpdate += clock.restart(); while (timeSinceLastUpdate > TimePerFrame) { timeSinceLastUpdate -= TimePerFrame; processEvents(); update(TimePerFrame); } render(); } and in update function I do this: object.speed = object.speed * TimePerFrame.asSeconds(); and then I run a method in which...

Add velocity to a sprite in the direction of the mouse, when i push a button

c++,sfml
float avx = 20;//avatar x coordinate float avy = 20;//avatar y coordinate float avd = 0;//avatar rotation degree I have it so the sprite is angled in the direction of the mouse(avd). sf::Vector2f av = avatar.getPosition(); sf::Vector2i m = sf::Mouse::getPosition(window); sx = m.x - av.x; sy = m.y - av.y;...

Working out the point on a circle using another point and the angle between them

c++,sfml,trigonometry
I have a point on a circle with center (0, 0), called (x1, y1), and an angle called A (in degrees). I want to find a function which lets me find another point on the circle (x2, y2), like this: I have a function which looks like this (I am...

Preventing unauthorised use of components

c++,oop,sfml
I'm building a component system where an abstract type Component is inherited from to make components. So far, I have drawable, physical, movable and other components. All seems to go well, and in the Game class I perform the following: void Game::init() { pPlayer->addComponent(pMovable); } void Game::processEvents() { if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))...

Issues Configuring CLion, Cmake, and SFML

cmake,sfml,clion
I am currently trying to configure my Cmake file to include the SFML libraries. My CMakeLists.txt. I'm using OS X Yosemite if that matter at all. cmake_minimum_required(VERSION 2.8.4) project(SFMLTest) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=lib++") set(SOURCE_FILES main.cpp) add_executable(SFMLTest ${SOURCE_FILES}) #Detect and add SFML set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Users/Home/SFML-2.2-osx-clang-universal/cmake/Modules" ${CMAKE_MODULE_PATH}) find_package(SFML 2.2 REQUIRED system window graphics...

cmake target_link_libraries() launching error Cannot specify link libraries for target “debug”

c++,api,cmake,sfml
I'm trying to link CLion and SFML (using windows, mingw w64, SFML 64, CMake) and i triied to configure the CMakeLists.txt properly. here's the cmakelist : cmake_minimum_required(VERSION 3.2) project(Test_Utilisation_SFML) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(SOURCE_FILES main.cpp) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin") message(WARNING "CMake runtime output Directory : ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") add_executable(Test_Utilisation_SFML.exe ${SOURCE_FILES}) # Detect and add SFML...

C++ Pthread/SFML Music - Error AL lib: (EE) alc_cleanup: 1 device not closed

c++,pthreads,sfml
I have a project that is to recode the Bomberman and I implemented the sf :: Music for music added to main menu but I come across an error: AL lib: (EE) alc_cleanup: 1 device not closed And it's relied to this : void *pthreadSound(void *); int main(int, char **){...

Using sf::Shape with a default constructor

c++,sfml
I would like to create a class with a sf::Shape as a member variable, but for some reason i cannot set it's parameters in the default constructor, only in main. Any idea why, the error says "expression must have class type". Thank you to anyone that can help out. #include...

Stretch sf::Sprite across entire window

sfml
I have a sf::Sprite and when drawing it to the window I want it to fill the entire window. sf::RenderWindow.draw takes an optional sf::RenderStates. Is that what I need to mess with?...

Combine std::wstring and function

c++,string,ascii,sfml,wstring
I'm creating text in SFML 2.1 (It doesn't really matter) in c++. Setting a text string looks like that: text.setString("something"); Ok, but because my game language is Polish, I have to enter some characters like ą,ż,ł,ś,ć etc. , which are not 'supported' in my game's ASCII encoding. Iv'e came up...

OpenGL rendering causes graphical glitch

opengl,graphics,3d,sfml,immediate-mode
Code is below. When the program runs, it generates a more or less correct image, but there are some graphical glitches. Here are some images:. Any ideas on what could be causing this? The weirdest part is that the issue appears to form on triangles, even though the image is...

error: `MEMBER` in `class CLASS` does not name a type; C++

c++,gcc,sfml
Hey there i have constructed a class to store some Information as static Members of the class. At Compile-time i got the error: error: ‘cubeLength’ in ‘class Config’ does not name a type error: ‘cellColor’ in ‘class Config’ does not name a type Content of Config.h #ifndef CONFIG_H #define CONFIG_H...

CMake link library from subdirectory

c++,gcc,linker,cmake,sfml
I am trying to include SFML sources in my project. My directories are laid out like this: main SFML (subtree synced with the official git repo) src <various modules> General (here lies the binary) From the main level I am adding SFML subdirectory first and then src. As I've seen...

Can't figure out my own code

c++,function,sfml
I'm having lots of trouble figuring out why my code isn't working. I don't have anyone else to turn to for help so I am hoping that someone here can help me. I'm working on a game in C++ and I am needing my ground to cut away, so to...

SFML C++ not rendering

c++,variables,rendering,sfml
I got a problem, I'm writing a small game, and few times when I added new variable such as float or sf::Vector2f, sfml is not rendering other elements or not moving (or other odd problems). This is my main function: const int resW=800, resH=600; sf::RenderWindow app(sf::VideoMode(resW, resH), "Jump");//, sf::Style::Fullscreen); int...

Snake Game - Collision I have no idea

c++,sfml
I write the game "snake" and I have a problem with body snake, namely the Snake head is saved to the list std::list<sf::RectangleShape> listaSnake; (library SFML) and I don't know how I can do collision when the position Snake head will be equal position body. I only know how to...

Error while loading shared libraries: libsfml-graphics.so.2.2.0

c++,linux,shared-libraries,sfml
Full Error: error while loading shared libraries: libsfml-graphics.so.2.2.0: cannot open shared object file: No such file or directory This is probably the quintillionth time I've run into this error with SFML. This error oddly only occurs when running the executable, rather than during compilation. I don't know what is causing...

Change the way i load resources

c++,sfml
I have made a few games using c++ sfml and they work pretty well. I think my game structuring needs alot of work. At the moment I load all my sprites and textures at the begining of my main function, and then pass them wherever needed. could someone give me...

program linked to SFML dlls wont start, returns 0xC000007B or missing __gxx_personality_v0

c++,dll,sfml
I was trying to compile example from SFML page http://www.sfml-dev.org/tutorials/2.3/start-cb.php (at the bottom) I dowloaded the version for GCC 4.9.2 DW2, set everything needed (linker, directories) and it compiled without errors. When the application starts it says that it needs .dll files so I copied them from SFML/bin directory. Then...

Multiple socket 'handshaking' in UDP network using SFML C++ libraries

c++,sockets,network-programming,udp,sfml
I am coding a real-time, network program with UDP protocol using SFML libraries. The server will be handling all of the processing, sending packets to the client and vice versa. I need a method to synchronize the screen updates, because there will be a real-time user interface on both sides...

Call a non-static method from no object using std::function

c++,object,callback,sfml
While doing some random-ish, weird-ish things to understand a little bit more C++ (just to say I'm still a newbie), I came across something I can't properly understand : I'm currently using SFML which provides a few methods to create and manage a window, namely this method to close it:...

SFML window.close() does not kill the process when using multithreading

c++,multithreading,process,sfml,close
Below is a test file which essentially performs the same basic task as my actual program. It opens a SFML window, creates some threads, then tries to close them when the window is closed. Unfortunately, when the sfml window is closed, the console window (and the process) continue to run....

Moving focussed sprites gradually to target position (C++ & SFML)

c++,sfml
I'm trying to find out, how to move sprites to a target position. (focus a sprite by left-click and then left-click again to move it towards the position, that was clicked). What's wrong with my code? How to implement such functionality. Thx in advance for any help. #include <SFML/Graphics.hpp> #include...

SFML - Rotating a sprite around its center using a Transform

rotation,sfml
I have an object that needs to be able to be rotated around its center, but keeping the same origin (for setting position, etc). So, I figured I needed to use a Transform. Code is in Java (JSFML), but I figured the syntax was similar and able to be understood...

Wish To Execute A Function Periodically But Continue With The Rest Of Program Loop

c++,loops,main,sfml
Currently my program consists of a main loop which executes whilst a window is open. Inside the loop there is a function which must execute periodically (say every second or so), BUT the rest of the main loop has to continue executing and the loop to repeat without the periodic...

OpenCV mat to SFML image

c++,opencv,sfml
Is there a way to format an OpenCV mat to a SFML image. Or is there any other way to display the mat in a SFML window? I've tried converting the mat array into a uchar array, but the result is a black screen. cv::VideoCapture cap(0); // open the video...

Cannot run c++ release build on a PC without visual studio. (SFML and C++)

c++,visual-studio-2012,sfml
The title pretty much says it all. I am learning C++ at the moment and decided to try to make a game. My friend who also wants to learn c++, but does not have VS installed tried to run it, and it crashed on start up. It was fine when...

already defined class C++

c++,visual-studio,networking,sfml
I don't understand one think. I have a header file called "network.h", and there are declaration of the class with functions. In "network.cpp" file I've these functions. When want include "network.h" in main.cpp and compile my project (Microsoft Visual Studio 2007) I got this message: network.obj : error LNK2005: "class...

SFML not linking statically to openal32 (links statically to all other dependencies)

c++,cmake,sfml
I compiled SFML using CMake for MinGW. After running "mingw32-make install" everything is built and installed with no errors. But when running the examples - pong.exe, sound.exe, sound-capture.exe and voip.exe all depend upon openal32.dll. I specified SFML_USE_STATIC_LIBS = true when configuring CMake and all other dependencies of the example executables...

Ping Pong paddles are not acting as expected

c++,sfml
I am trying to learn SFML and C++ so I decided to try and make my own Ping Pong game however for some reason player 1 is not clearing properly and player 2 is a lot slower and jittery (same as player 1). Could someone help me out with this...

C++ sfml receives close event just after window opens

c++,xcode,sfml
I am trying to follow a SFML tutorial from this link, however, for some reason my application seems to be caling the close event as soon as my program enters into the event loop. Here is my code. #include <SFML/Graphics.hpp> #include <iostream> // Here is a small helper for you...

Undefined symbols for architecture x86_64: CMMotionManager with SFML

c++,ios,objective-c,sfml
I have been trying to build my SFML app for iOS but I keep running into hurdles. The latest of which is an error that I don't understand, I do not work on Mac much and therefore don't know what most of the errors mean. This specific error seems to...

SFML 2.3 and CodeBlocks error compilation

c++,compilation,codeblocks,sfml
I'm trying to make sfml works with codeblocks. I did everything said in this video tutorial : https://www.youtube.com/watch?v=gEGWO8ug2bY Everything works if I only add SFML/Graphics.hpp, so my config isn't completely bad. But if I try to add SFML/Audio.hpp (I need to add sounds to my project) and write "sf::Music background_music;"...

How to rotate points about a specific origin?

c++,matrix,rotation,sfml,points
I'm working on rotating the vertices of my object around a point located on the object that's not necessarily its center. I followed this tutorial pretty closely and got the vertices to keep their same proportions, i.e. the shape that they create does rotate about the given point, however the...