Answer the question
In order to leave comments, you need to log in
File not opening?
Good day! I can't open the file, tried it in different ways, but the result does not change. I develop on Linux using Clion.
Opening function:
static std::string LoadShader(const std::string& fileName)
{
std::ifstream file;
file.open((fileName).c_str());
std::string output;
std::string line;
if(file.is_open())
{
while(file.good())
{
getline(file, line);
output.append(line + "\n");
}
}
else
{
std::cerr << "Unable to load shader: " << fileName << std::endl;
}
return output;
}
Shader::Shader(const std::string &filename)
{
m_program = glCreateProgram();
m_shaders[0] = CreateShader(LoadShader(filename + ".vs"), GL_VERTEX_SHADER);
m_shaders[1] = CreateShader(LoadShader(filename + ".fs"), GL_FRAGMENT_SHADER);
......
}
Shader shader(".res/basicShader");
cmake_minimum_required(VERSION 3.6)
project(1_)
# includes FindSDL2.cmake
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
link_libraries(${GLEW_LIBRARIES})
endif()
include_directories(${SDL2_INCLUDE_DIR})
set(SOURCE_FILES main.cpp src/Display.cpp headers/Display.h src/Shader.cpp headers/Shader.h)
add_executable(1_ ${SOURCE_FILES})
target_link_libraries(1_ ${SDL2_LIBRARY})
target_link_libraries(1_ ${OPENGL_LIBRARY})
Answer the question
In order to leave comments, you need to log in
The problem was solved, it was necessary to specify the working directory in Clion.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question