• Content count

  • Joined

  • Last visited

Community Reputation

119 Neutral

About SetsudanHana

  • Rank
  1. The way i'm doing lookat for my camera: void Camera::update() { double sinAlfa = glm::sin(m_alfa * DAG2RAD); double sinBeta = glm::sin(m_beta * DAG2RAD); double cosAlfa = glm::cos(m_alfa * DAG2RAD); double cosBeta = glm::cos(m_beta * DAG2RAD); m_viewMatrix = glm::lookAt( m_position, glm::vec3(m_position.x + sinAlfa*cosBeta, m_position.y - sinBeta, m_position.z - cosAlfa*cosBeta), glm::vec3(0.0f, 1.0f, 0.0f)); } just counting sin and cos function for each of angles of your camera, and with little math you can count point your camera is looking at. DAG2RAD is just pi/180 to convert my angle to radiants. I dont know if it solves your problem, but i hope it will help.
  2. OpenGL Problem with Deffered Rendering

    Sry i didnt answer, timezone...   But what about texture initializing, i did everything according to the tutorial and there was no line about setting any TexParameter. I checked out values in CodeX and you may be right about this filtering, i will try to save those textures as an image from my code and check results there.   And yeah i will have to think about optimalization, but now it is my least problem.
  3. So i'm trying to implement deffered rendering in my first "graphic engine" using this tutorial: . And got some issues with drawing my position and normal to the texture. I think i'm sending everything alright, cause before it worked normally with forward rendering. This is how it looks. Position: Normal:   Texture coords, diffuse and depth buffer are looking fine.   Here are my shaders for model geometry (for terrain it is similar, just with additional calculation)   VS: #version 400 layout(location = 1) in vec3 vertex_position; layout(location = 2) in vec2 vertex_texture; layout(location = 3) in vec3 vertex_normals; uniform mat4 pvw_matrix; uniform mat4 world; layout(location = 0) out vec2 texture_coords; layout(location = 1) out vec3 normals; layout(location = 2) out vec3 world_pos; void main() { vec4 tmp = (world * vec4(vertex_normals, 0.0)); normals =; tmp = (world * vec4(vertex_position, 1.0)); world_pos =; texture_coords = vertex_texture; gl_Position = pvw_matrix * vec4( vertex_position, 1.0 ); } FS: #version 400 layout(location = 0) in vec2 TexCoord; layout(location = 1) in vec3 Normal; layout(location = 2) in vec3 WorldPos; layout (location = 0) out vec3 WorldPosOut; layout (location = 1) out vec3 DiffuseOut; layout (location = 2) out vec3 NormalOut; layout (location = 3) out vec3 TexCoordOut; uniform sampler2D sampler; void main() { vec4 texel = texture(sampler, TexCoord); WorldPosOut = WorldPos; DiffuseOut =; NormalOut = normalize(Normal); TexCoordOut = vec3(TexCoord, 0.0); } Thanks for any clues, that will help me solve this riddle. I will paste more code if necessary. Link to my repo is here:  
  4. it works, i knew that it is something so simple... I'm just dumb
  5. loadTextFile function: std::string ResourceManager::loadTextFile(const std::string& path) { std::ifstream file(path); if(!file.good()) { OutputDebugStringA("File not found"); return nullptr; } std::stringstream stream ; stream << file.rdbuf(); file.close(); return stream.str(); } i cant use cout, becuase i dont have console, but OutputDebugStringA on each of them gives this:     last line dont have '\n', thats why they looked merged   EDIT:   changing to multibyte, didnt do anything
  6. Yeah, it is faster to ask on few sites.   Yes, i found this suggestion on stackoverflow, but it changed nothing
  7. @mhagain   yes it is set up to unicode   @Ectara   i added '\0' by myself, and now it throws this one:       EDIT:   i changed every 1.0 to 1.0f in my shaders, and i'm back to my previous error
  8. length() function is giving me valid value so i do think, they do have null terminator
  9. i'm getting those errors while compiling shaders, this is code from my ShaderLoadingClass: ResourceManager manager; std::string container = "Just simple container"; container = manager.loadTextFile(file + ".vs"); const char* vertex_shader = container.c_str(); container = manager.loadTextFile(file + ".fs"); const char* fragment_shader = container.c_str(); unsigned int vs = glCreateShader (GL_VERTEX_SHADER); glShaderSource (vs, 1, &vertex_shader, NULL); glCompileShader (vs); unsigned int fs = glCreateShader (GL_FRAGMENT_SHADER); glShaderSource (fs, 1, &fragment_shader, NULL); glCompileShader (fs); checkErrors(vs); checkErrors(fs); unsigned int shader_programme = glCreateProgram (); glAttachShader (shader_programme, fs); glAttachShader (shader_programme, vs); glLinkProgram (shader_programme); return new ShaderClass(shader_programme);
  10. Ok, so i'm starting my adventure with openGL 4 and shaders. And i occured weird syntax error while compiling vertext shader. Even when i take simple vertex shader: #version 400 in vec3 vector_position; void main() { gl_Position = vec4(vector_position, 1.0); } i do get this error:       What is weird about this, my fragment shader is compiling without errors: #version 400 out vec4 color; void main() { color = vec4(1.0, 0.0, 0.0, 1.0); } and gives this message:       I tried testing those shaders by putting them as const char* in code, and they work fine. To make it easier here are some additional informations:   using SDL 2.0 initializing OpenGL by SDL2.0 using GLEW to load extensions reading text files by this function: std::ifstream file(path); if(!file.good()) { OutputDebugStringA("File not found"); return nullptr; } std::stringstream stream ; stream << file.rdbuf(); file.close(); return stream.str(); Thank you for fast answer.