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

Recent Posts

Pages: 1 2 3 [4] 5 6 ... 10
31
Graphics / Loading SFML Textures in Opengl
« Last post by Bogdan on December 08, 2024, 08:57:10 pm »
Hello there,
I've encountered a new problem with sfml/opengl loading of textures. There is much outdated info on the net about opengl and sfml...
As the example below uses a different library, I wanted to ask: How to do the texture loading part just with SFML and Opengl. If I try using sf::Texture, it always says that it's incompatible wit Gluint type.

unsigned int texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
// set the texture wrapping/filtering options (on the currently bound texture object)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// load and generate the texture
int width, height, nrChannels;
unsigned char *data = stbi_load("container.jpg", &width, &height, &nrChannels, 0);
if (data)
{
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
    glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
    std::cout << "Failed to load texture" << std::endl;
}
stbi_image_free(data);
32
Graphics / sf::View - not working correct
« Last post by tBane on December 08, 2024, 11:20:53 am »
Hi! I tried positioning text in texture but my code now work. I think so SFML 2.6.2 not working correctly, because I think my code is correct. I use global coordinates for all objects and result is in screenshot. I think this red bar should be a hover of blue rect.


(click to show/hide)
33
General / Re: Build SFML from source, DLLs are nowhere to be seen
« Last post by TheIrishDev on December 07, 2024, 03:08:32 am »
I believe he is trying to say when you are to build SFML, you need to specify "-DBUILD_SHARED_LIBS=On" in a string of commands like "cmake . -B "build" -DBUILD_SHARED_LIBS=On".
34
System / CMake can't find System with SFMLConfig.cmake when installed with Vcpkg.
« Last post by TheIrishDev on December 07, 2024, 02:55:42 am »
So the program I'm making has been a journey for me to try and take on a semi-large project. I've done a lot of wrong with it that I've tried to right, and the one thing I never really got around to until now was dependency management. I tried integrating Vcpkg into my CMake file and obviously one of the things I need was SFML. So, I wrote a vcpkg.json file and when I run CMake everything builds fine, but when it gets to linking I get an error saying System couldn't be found in the SFMLConfig.cmake file. Specifically, the error says:
```
CMake Error at build-d/vcpkg_installed/x64-windows/share/sfml/SFMLConfig.cmake:144 (message):
  Found SFML but requested component 'System' is missing in the config
  defined in
  C:/Users/My_Name/Documents/dev/FortIDE/build-d/vcpkg_installed/x64-windows/share/sfml.
Call Stack (most recent call first):
  C:/Users/My_Name/Documents/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
  CMakeLists.txt:78 (find_package)


CMake Error at C:/Users/My_Name/Documents/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
  Found package configuration file:

    C:/Users/My_Name/Documents/dev/FortIDE/build-d/vcpkg_installed/x64-windows/share/sfml/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.
Call Stack (most recent call first):
  CMakeLists.txt:78 (find_package)


-- Configuring incomplete, errors occurred!
```
Is this something new. The installed SFML version is 2.6.2. When I run `vcpkg list` it says all the packages but system are installed even though when I look in the lib and bin folders in the install directory for the deps, the -system.dll and system.lib are there. Has anybody else come across this or am I doing something wrong here? If it helps this is my cmake file:
```
cmake_minimum_required(VERSION 3.15)
if (DEFINED ENV{VCPKG_ROOT})
    set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
else()
    message(FATAL_ERROR "VCPKG_ROOT environment variable not set. Please set it to the root directory of your vcpkg installation.")
endif()

project(FortIDE)

# Set C++ standard
add_compile_definitions(ANTLR4CPP_STATIC SFML_STATIC GIT_STATIC)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

set(CMAKE_BUILD_TYPE "Release")
# Set Boost root and include/library directories
#set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/deps/boost")
#set(BOOST_INCLUDEDIR "${BOOST_ROOT}/boost")
#set(BOOST_LIBRARYDIR "${BOOST_ROOT}/stage/lib")
#set(SFML_DIR "${CMAKE_SOURCE_DIR}/deps/SFML/build")
#set(spdlog_DIR "${CMAKE_SOURCE_DIR}/deps/spdlog/build")
#set(TinyXML_DIR "${CMAKE_SOURCE_DIR}/deps/tinyxml2/build")
#set(FREETYPE_LIBRARY "${CMAKE_SOURCE_DIR}/deps/freetype/build")
#set(FREETYPE_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/deps/freetype/include")
# Policy to handle FindBoost module removal warning
cmake_policy(SET CMP0167 OLD)

# Create the executable target
add_executable(FortIDE src/Main.cpp)  # Replace `main.cpp` with your main source file

# Specify source files for ImGui
#set(IMGUI_SOURCES
 #   ${CMAKE_SOURCE_DIR}/deps/imgui/imgui.cpp
  #  ${CMAKE_SOURCE_DIR}/deps/imgui/imgui_draw.cpp
  #  ${CMAKE_SOURCE_DIR}/deps/imgui/imgui_tables.cpp
  #  ${CMAKE_SOURCE_DIR}/deps/imgui/imgui_widgets.cpp
  #  ${CMAKE_SOURCE_DIR}/deps/imgui/imgui_demo.cpp  # Optional
#)
file(GLOB FILETREE_SOURCES ${CMAKE_SOURCE_DIR}/src/mainfunc/FileTree/*.cpp)
file(GLOB ANTLR_SOURCES ${CMAKE_SOURCE_DIR}/src/mainfunc/F90Files/*.cpp)
set (MAIN_SOURCES
    ${CMAKE_SOURCE_DIR}/src/mainfunc/mainfunc.cpp
    ${CMAKE_SOURCE_DIR}/src/mainfunc/c_Parser.cpp
    ${CMAKE_SOURCE_DIR}/src/mainfunc/Config.cpp
    ${CMAKE_SOURCE_DIR}/src/mainfunc/f_MainMenu.cpp
    ${CMAKE_SOURCE_DIR}/src/mainfunc/searchParser/s_Parser.cpp
    ${CMAKE_SOURCE_DIR}/src/mainfunc/FileTree/FileTree.cpp
    ${CMAKE_SOURCE_DIR}/deps/ImGuiColorTextEdit/ImGuiDebugPanel.cpp
    ${CMAKE_SOURCE_DIR}/deps/ImGuiColorTextEdit/LanguageDefinitions.cpp
    ${CMAKE_SOURCE_DIR}/deps/ImGuiColorTextEdit/TextEditor.cpp
    ${CMAKE_SOURCE_DIR}/deps/ImGuiColorTextEdit/UnitTests.cpp
    ${FILETREE_SOURCES}
    ${ANTLR_SOURCES}
)

# Add source files to the target
target_sources(FortIDE PRIVATE ${MAIN_SOURCES})

# Include directories
#target_include_directories(FortIDE PRIVATE
#    ${CMAKE_SOURCE_DIR}/deps/spdlog/include
#    ${CMAKE_SOURCE_DIR}/deps/libgit2/include
#    ${CMAKE_SOURCE_DIR}/deps/imgui
#    ${CMAKE_SOURCE_DIR}/deps/imgui-sfml
#    ${CMAKE_SOURCE_DIR}/deps/SFML/include
#    ${CMAKE_SOURCE_DIR}/deps/tinyxml2/
#    ${CMAKE_SOURCE_DIR}/deps/boost_1_86_0
#    ${CMAKE_SOURCE_DIR}/deps/antlr4/runtime/Cpp/runtime/src
#    ${CMAKE_SOURCE_DIR}/deps/portable-file-dialogs/
#    ${CMAKE_SOURCE_DIR}/deps/ImGuiColorTextEdit/

#)

# Use vcpkg packages
find_package(Boost REQUIRED COMPONENTS filesystem system)
find_package(SFML 2.6.2 REQUIRED COMPONENTS Main Graphics Window System)
find_package(spdlog REQUIRED)
find_package(TinyXML2 REQUIRED)
find_package(portable-file-dialogs CONFIG REQUIRED)
find_package(antlr4-runtime REQUIRED)
find_package(libgit2 REQUIRED)

# Platform-specific settings
if (WIN32)
    target_compile_definitions(FortIDE PRIVATE)
    target_link_libraries(FortIDE PRIVATE OpenGL32 winmm glu32)
elseif (UNIX)
    target_link_libraries(FortIDE PRIVATE pthread dl)
endif()

target_link_libraries(FortIDE PRIVATE
    Boost::filesystem
    Boost::system
    sfml-main
    sfml-graphics
    sfml-window
    sfml-system
    spdlog::spdlog
    tinyxml2
    portable-file-dialogs
    antlr4-runtime
    git2
)
```
35
General discussions / Re: SFML releases
« Last post by eXpl0it3r on December 07, 2024, 12:29:39 am »
SFML 3.0.0-rc.2

Read the announcement here: https://en.sfml-dev.org/forums/index.php?topic=29735.0
36
General discussions / SFML 3.0.0-rc.2 released
« Last post by eXpl0it3r on December 07, 2024, 12:29:13 am »
We're happy to announce the second Release Candidate for SFML 3! ๐ŸŽ‰

Three years in the making, with over 1'100 commits, 41 new contributors, and a lot of time invested, we want to thank each and everyone who helped SFML 3 get this far. 
A special thanks to vittorioromeo for laying the foundation early on and a massive thank you to ChrisThrasher for relentlessly pushing SFML 3 forward - he currently sits at over 500 pull requests alone! ๐Ÿ™Œ

With the second release candidate we've majorly reworked our dependency handling. SFML will no longer ship third-party binaries in its source code distribution! Instead, unless the user decides to use system-wide available dependencies, SFML will fetch and build its dependencies on-the-fly by utilizing CMake's FetchContent.

If everything goes to plan, this will be the final Release Candidate, as all the features and breaking changes have been merged and the open issues are mostly about documentation and minor alignments.

We Need You! ๐Ÿซต

We need your help to test this release candidate! 
As the dependency handling was changed, it would help greatly, if you could report any issues, crashes or just general feedback, so we have a chance to fix or clarify as many things before the release. 
It's highly appreciated and will help us make SFML 3 even more stable!

Reach out: GitHub Issues / Discord / Forum / Bluesky / Twitter / Fediverse

Highlights

- SFML has *finally* been updated to support and use C++17 โš™๏ธ
- The test suite has been massively expanded to 57% code coverage ๐Ÿงช
- OpenAL has been replaced with miniaudio ๐Ÿ”Š
- New and improved event handling APIs โŒจ๏ธ
- Scissor and stencil testing ๐Ÿ–ผ๏ธ
- And more...

See the changelog for more details.

Migration

SFML 3 is a new major version and as such breaking changes have been made. 
To ease the pain of migration, we've written an extensive migration guide.

Migration Guide ๐Ÿ“

If you think, something is wrong or could be improved, please reach out on Discord or leave a comment on the dedicated issue. The more feedback we get, the more we can improve the guide.

Known Issues

See the GitHub Release page for an updated list
37
General / Re: Build SFML from source, DLLs are nowhere to be seen
« Last post by Deedolith on December 07, 2024, 12:12:27 am »
I do not see such entry within CMake, should I add it ?
38
General / Re: Build SFML from source, DLLs are nowhere to be seen
« Last post by eXpl0it3r on December 06, 2024, 11:54:23 pm »
With SFML 3 (master) we've changed the default behavior to match CMake's default behavior by building static libraries, if nothing has been specified.
If you want to build shared libraries, you can set BUILD_SHARED_LIBS to ON.

See also the migration guide if you're coming from SFML 2
39
General / Build SFML from source, DLLs are nowhere to be seen
« Last post by Deedolith on December 06, 2024, 09:51:33 pm »
Hello,

I am having troubles building SFML from source.
Here are the steps I did:
- Clone the github repository with GitHub Desktop.
- Configure the project with CMake
- Generate the project with CMake (all options left to default values).
- Open the project with Visual Studio 2022.
- Build Debug/x64 and Release/x64 (no option change).

There are no compile errors, libraries (.lib files) are generated, but no DLLs.
Did I miss something ?
40
Graphics / Re: [SOLVED] Unabled to load file problem - loadFromFile.
« Last post by kojack on December 06, 2024, 12:11:41 am »
Your output directory (where the .exe file is put) is $(SolutionDir), the location of the .sln file.
Your working directory (where it will look for asset/labyrinth.png) is $(ProjectDir), the location of the .vcxproj file.
So sounds like your asset directory isn't in the project directory where Visual Studio has been told to look for it.
(I always either change $(ProjectDir) to $(TargetDir), which looks where the .exe was put, or in code I find the exe path and change working directory to it)
Pages: 1 2 3 [4] 5 6 ... 10