i have created function input file , returns string file content:
file_to_string.cpp
#include <fstream> #include "file_to_string.h" std::string file_to_(const char* name) { std::ifstream in(name); std::string output((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>()); return output; } when call function in same file works properly. however, when execute file part of glut project returns nothing.
these rest of files project made of (i have suppressed superfluous parts of main file):
file_to_string.h
#include <iostream> #include <string> std::string file_to_(const char* name); main.cpp
#include <gl/glut.h> #include "file_to_string.h" static void checkshaders (void) { std::cout << file_to_("shader.vs"); } int main(int argc, char** argv) { checkshaders(); glutinit(&argc, argv); glutinitdisplaymode(glut_double | glut_rgba); glutinitwindowsize(512, 384); glutinitwindowposition(100, 100); glutcreatewindow("program"); return 0; } shader.vs
#version 330 layout (location = 0) in vec3 position; void main() { gl_position = vec4(0.5 * position.x, 0.5 * position.y, position.z, 1.0); }
i have found problem. turns out "lightness races in orbit" says linking problem. in order codeblocks recognize shader file, file name must contain full path when function called.
Comments
Post a Comment