Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kojack

Pages: 1 2 [3] 4 5 ... 21
31
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 05:23:07 am »
Don't worry, it does get pretty confusing at the beginning. Visual Studio doesn't go out of its way to make it easier either (as we'll see soon).

SFML 32bit will be fine, as long as your project has the platform set to Win32/X86 instead of X64.

For the missing DLLs...
When the run a program, it looks in a few places for the dlls. One is the system path (set in Windows, every directory in the path will be searched). The other is the "working directory".
If you run a program by clicking on it in explorer, the working directory is set to the same directory as where the program is. So if you click on c:\game\main.exe, it will search c:\game for the dlls.

This is where VS is annoying.
Running a program from inside of Visual Studio uses a working directory set in the project properties. The default is $(ProjectDir), which means it will look for the dlls in the same directory as the .vcxproj file, not where the exe ended up!
I always change the working directory to $(TargetDir), that makes it look for dlls where the exe is.

The setting is in Debugging / Working Directory. If you set it to $(TargetDir) and copy the SFML dlls into the same directory as the exe file you built, it should hopefully work.

32
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 03:48:37 am »
The include paths thing was for the compile error from the top.

Visual studio can build Windows executables (exe) and libraries (dlls) as either 32bit or 64bit. The important part is that they can't be mixed. The executable and all libraries must be the same bit size or they are incompatible. So you should get the SFML that matches what you want your project to be.

Windows itself used to have 32bit and 64bit versions. The 32bit Windows can only run 32bit programs. The 64bit Windows can run both 32bit and 64bit programs.

My personal preference is 64bit, I stopped doing anything C++ related in 32bit many years ago (some of my stuff uses a lot of ram). But 32bit does have a wider audience (some people still using old 32bit versions of windows).

33
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 02:06:14 am »
Mixing the 32bit SFML download with 64bit platform in the project settings isn't going to work, but that's not the cause of the issue here. (you can't mix 32bit and 64bit).

The error in the first post says it can't find SFML/Graphics.hpp. So the code most likely has:
#include <SFML/Graphics.hpp>

But your settings have the additional includes set to: C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\include\SFML
Visual Studio adds the #include path to the additional includes path, so it was looking for:
C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\include\SFML\SFML\Graphics.hpp
(double SFML).

If you change the additional includes to: C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\include it should work.

(Or so both #include <Graphics.hpp> and #include <SFML/Graphics.hpp> work, you can set the additional includes path to: C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\include;C:\users\xxxxxx\Downloads\SFML-2.6.1-windows-vc17-32-bit\SFML-2.6.1\include\SFML )

34
Graphics / Re: sf::Rect
« on: February 05, 2024, 10:44:21 pm »
I'd forgotten too, had a suspicion and had to google around to verify. :)

I assume without the static cast it would just give some warnings during the build about having to truncate ints to smaller types (if a Rect<short or char> was used) but would otherwise work. Floats or doubles wouldn't need the cast.

Or maybe the template would get confused. I should test it, I'm curious now.

35
Graphics / Re: load font error -
« on: February 05, 2024, 10:19:28 am »
Including the fonts seems to work in both cases but when i hit the build button i get loads of error messages
When you say "including the fonts" you don't mean #include do you? Because that would definitely cause compile errors.

36
Threads with SFML rendering need special care. https://www.sfml-dev.org/tutorials/2.6/window-opengl.php#rendering-from-threads
Basically an opengl context can only be active on one thread at a time. You need to deactivate the window's context on the main thread and enable the window's context in the thread before rendering there will work.
(Then deactivate it in the thread and reactivate in the main thread to do the other rendering).

37
Graphics / Re: RectangleShape.getPosition always returns 0 for value
« on: February 04, 2024, 09:25:20 pm »
It's not the issue you are asking about, but in your addMenu function you are creating a temporary font variable, loading a font with it and setting the font on the text object.
The issue is setFont doesn't store the font in the text object, it just stores a pointer to the font. The font itself must be kept alive, otherwise the result is undefined behavior.

38
Graphics / Re: sf::Rect
« on: February 04, 2024, 10:13:36 am »
I would guess it's there to make sure the type is T to match the min and max signature.
For integer datatypes, the type of the result of a + is not always the type of the two operands. If you have a Rect<short>, then left and width are shorts, but left+width is an int.
(From cppreference.com: "In particular, arithmetic operators do not accept types smaller than int as arguments")

39
Graphics / Re: LineStrip VertexArray and ConvexShape problem
« on: February 01, 2024, 11:15:34 pm »
ConvexShape needs shapes to be convex. That means no inward angles like the curved top part. Your shape is concave, which is harder to draw filled.

Why concave doesn't work is Shapes (like ConvexShape) use a triangle fan from the centre. To reach the top corners from the centre, it has to draw over the top of the curved parts, resulting in the triangle shape instead of the curve.

There's no built in way to do concave shapes in SFML (that I know of), you'll need to generate a triangle mesh using an algorithm like "ear clipping" (it can turn concave into triangles that don't overlap). But implementing that can be tricky.

Or depending on how you intend to use it, maybe do something like draw a white rectangle then a black circle over the top.

40
General / Re: Can't resolve LNK2001 "unresolved symbol"
« on: January 28, 2024, 03:56:15 am »
When SFML is linked statically, you have to manually link in all of the dependency libraries.
In your case it looks like you haven't added opengl32 and freetype as addition libraries.

There's a table of what you need to link here: https://www.sfml-dev.org/tutorials/2.5/start-cb.php (around half way down).

41
Graphics / Re: Drawing Vertex Array with big Texture
« on: January 27, 2024, 04:10:13 am »
Of course these max sizes are the theoretical max size supported by the gpu/driver. It doesn't necessarily mean you can actually create one that big because it might not currently fit in memory.
For example a single 16384x16384 texture takes up 1GB of video ram.

Array textures do look like a good solution, especially since they do eliminate edge bleeding that atlases can suffer from. But getting that into SFML might be a little tricky. I've also heard bindless textures are the new preferred way, but I've never looked into them (again, not in SFML so might be tricky).

42
General / Re: Window flickers black during animation
« on: January 27, 2024, 03:54:02 am »
Cool. :)

43
SFML has two ways of doing keyboard input:
- event based using pollEvent and checking for sf::Event::KeyPressed and sf::Event::KeyReleased
- immediate check using sf::Keyboard::isKeyPressed.

Generally you shouldn't use isKeyPressed inside of the event loop (or really do almost any of the main game logic). This is because isKeyPressed is usually used when you want to check if a key is currently held down, but the event loop only runs when a key starts to be pressed or gets released, not in between.
(The event loop will also pick up key repeat events when the OS starts doing them, so it will happen more than just twice, but not at the frame rate)


44
General / Re: Window flickers black during animation
« on: January 27, 2024, 03:39:38 am »
What does the animation texture look like? When moving, the code is cycling through top left corners of frames starting at 64, 128, 192 and 256. Do you have 4 frames of the character with those coordinates? My guess is maybe theres only 3 frames for movement and the if(XR>256) part should be if(XR>=256) so it cycles 64, 128, 192

45
What exactly is it doing that isn't correct? I just tried that code and it rotates and moves in all directions fine.
(Although I'm using SFML 3).

Pages: 1 2 [3] 4 5 ... 21