Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with shader #10

Open
pbaret opened this issue Dec 30, 2022 · 2 comments
Open

Issue with shader #10

pbaret opened this issue Dec 30, 2022 · 2 comments

Comments

@pbaret
Copy link

pbaret commented Dec 30, 2022

Hey,
I just found your video series and the source code for the RPG, I manage to build it and found a lot of interesting stuff so first of all thank you!
However I have a problem when I click "New Game", it crashes with a shader error in the console:

Failed to compile vertex shader:
WARNING: 0:1: '' :  #version directive missing
WARNING: 0:1: 'varying out' : symbol not available in current GLSL version
ERROR: 0:1: 'varying out' :  supported in fragment shaders only


ERROR::GAMESTATE::COULD NOT LOAD SHADER.

Any idea what is the problem? and maybe a hint on how to fix or work around this?

I know C++ very well, just started SFML (built 2.5.1 from source on Windows with MinGW 12.2.0, I do have a NVidia GPU on the machine) but I have very limited knowledge on shaders.

@blrbrb
Copy link

blrbrb commented Jan 22, 2023

When you create the RenderWindow, are you setting the gl version? Are you also specifying the version with the #version directive?
I had the same issue awhile back. Apparently, large portions of the SFML graphics module are written using depreciated parts of the OpenGL library and won't have foward compatibility. I fixed the issue by simply removing the depreciated part, "varying". Hope you find a solution soon! :)

@pbaret
Copy link
Author

pbaret commented Jan 23, 2023

No I didn't make any modifications of the original code when experiencing the crash.
I was just using my own toolchain to build the project : SFML and Compiler I have on my PC and CMAKE :

  • mingw 12.2.0
  • SFML version 2.5.1 built from source

I had to build a CMakeLists.txt though :

project(SFML_RPG)

cmake_minimum_required(VERSION 3.13.0)

add_executable(SFML_RPG)

find_package(SFML 2.5 COMPONENTS system window graphics network audio main REQUIRED)

target_sources(SFML_RPG PRIVATE
    src/AIComponent.cpp
    src/AttributeComponent.cpp
    src/DefaultEditorMode.cpp
    src/EnemyEditorMode.cpp
    src/Game.cpp
    src/HitboxComponent.cpp
    src/MeleeWeapon.cpp
    src/PlayerGUI.cpp
    src/RegularTile.cpp
    src/Sword.cpp
    src/TileMap.cpp
    src/stdafx.cpp
    src/AIFollow.cpp
    src/Bird1.cpp
    src/EditorMode.cpp
    src/EnemySpawnerTile.cpp
    src/GameState.cpp
    src/Inventory.cpp
    src/MovementComponent.cpp
    src/PlayerGUITabs.cpp
    src/SettingsState.cpp
    src/Tab.cpp
    src/VectorMath.cpp
    src/AIOption.cpp
    src/Bow.cpp
    src/EditorState.cpp
    src/EnemySystem.cpp
    src/GraphicsSettings.cpp
    src/Item.cpp
    src/PauseMenu.cpp
    src/RangedWeapon.cpp
    src/SkillComponent.cpp
    src/TextTagSystem.cpp
    src/Weapon.cpp
    src/AnimationComponent.cpp
    src/CharacterTab.cpp
    src/Enemy.cpp
    src/Entity.cpp
    src/Gui.cpp
    src/MainMenuState.cpp
    src/Player.cpp
    src/Rat.cpp
    src/State.cpp
    src/Tile.cpp
    src/main.cpp
)

target_include_directories(SFML_RPG PRIVATE 
    inc/
    ${SFML_DIR}/../../../include        # required otherwise can't find SFML headers
)

target_link_directories(SFML_RPG PRIVATE
    ${SFML_DIR}/../..       # required otherwise can't find SFML libraries when linking
)

target_compile_options(SFML_RPG PUBLIC -Wconversion) 

target_link_libraries (SFML_RPG sfml-audio sfml-graphics sfml-network sfml-system sfml-window)


configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Shader/fragment_shader.frag ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Shader/vertex_shader.vert ${CMAKE_CURRENT_BINARY_DIR}/ COPYONLY)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants