Jump to content
  • Advertisement

theHOUSE16

Member
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

145 Neutral

About theHOUSE16

  • Rank
    Member
  1. theHOUSE16

    Assimp index array problem

    I forgot to post the output in case you wanted to look at the vertex and index data. Current working dir: /Users/user/Documents/warmachine/warmachine SDL initialized. OpenGL VERSION: 4.1 INTEL-10.12.13 OpenGL RENDERER: Intel HD Graphics 4000 OpenGL Engine GLSL VERSION: 4.10 OpenGL VENDOR: Intel Inc. Loading model file terrain.obj... 0 animations 1 materials 1 meshes 0 textures 24 vertices -1 1 -1 -1 0 0 2 2 -1 -1 -1 -1 0 0 2 2 -1 -1 1 -1 0 0 2 2 1 1 -1 0 0 -1 2 2 1 -1 -1 0 0 -1 2 2 -1 -1 -1 0 0 -1 2 2 1 1 1 1 0 0 2 2 1 -1 1 1 0 0 2 2 1 -1 -1 1 0 0 2 2 -1 1 1 0 0 1 2 2 -1 -1 1 0 0 1 2 2 1 -1 1 0 0 1 2 2 -1 -1 -1 0 -1 0 2 2 1 -1 -1 0 -1 0 2 2 1 -1 1 0 -1 0 2 2 1 1 -1 0 1 0 2 2 -1 1 -1 0 1 0 2 2 -1 1 1 0 1 0 2 2 -1 1 1 -1 0 0 2 2 -1 1 -1 0 0 -1 2 2 1 1 -1 1 0 0 2 2 1 1 1 0 0 1 2 2 -1 -1 1 0 -1 0 2 2 1 1 1 0 1 0 2 2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 0 2 19 3 5 20 6 8 21 9 11 22 12 14 23 15 17 Acount:192(24) F3count:36(12) DONE Program ended with exit code: 0
  2. I'm trying to get assimp to import a model into a vertex array and index array. I'm loading a cube but when i draw it on screen, this is what renders.   [attachment=30242:Screen Shot 2016-01-10 at 10.35.24 PM.png]   This is the same cube with the camera moved up a bit so you can get an idea of where all the faces are being drawn.    [attachment=30243:Screen Shot 2016-01-11 at 10.21.33 PM.png]   I think its an issue with the index array because all the vertices appear to be in the correct place but i can't find the issue. I'm sure its something stupid i'm missing so hopefully another pair of eyes can help. Here's the full code. Everything relevant to assimp importing is in the Mesh constructor and each mesh(only one in this case) is drawn with the draw method in the Mesh class so i think the problem is in one of those.   Any ideas? #include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" #include "glm/gtc/type_ptr.hpp" #include "assimp/cimport.h" #include "assimp/Importer.hpp" #include "assimp/scene.h" #include "assimp/postprocess.h" #include <vector> #include <iostream> #include <SDL2/SDL.h> #include <OpenGL/gl3.h> SDL_Window* window; SDL_GLContext gl_context; SDL_DisplayMode current; SDL_Event event; int width = 800; int height = 600; glm::mat4 proj_matrix; glm::mat4 view_matrix; float cam_x = 0.0; float cam_y = 0.0; float cam_z = 5.0; float tar_x = 0.0; float tar_y = 0.0; float tar_z = 0.0; float up_x = 0.0; float up_y = 1.0; float up_z = 0.0; unsigned int program; const char* vs = "#version 400\n" "in vec3 pos;" "uniform mat4 mvp;" "void main(){" " gl_Position = mvp * vec4(pos, 1.0);" "}"; const char* fs = "#version 400\n" "out vec4 frag_color;" "void main(){" " frag_color = vec4(0.5, 0.0, 0.5, 1.0);" "}"; class Mesh{ public: unsigned int vbo,ind, vao; int a_count; int f3_count; float* data_array; unsigned int* index_array; glm::mat4 model_matrix; Mesh(char* file_path){ std::cout << "Loading model file " << file_path << "..."; const aiScene* scene = aiImportFile(file_path, aiProcess_GenNormals | aiProcess_JoinIdenticalVertices); if(!scene)//if scene fails to load std::cout << "FAILED\n" << std::endl; else{ std::cout << std::endl; std::cout << "\t" << scene->mNumAnimations << " animations" << std::endl; std::cout << "\t" << scene->mNumMaterials << " materials" << std::endl; std::cout << "\t" << scene->mNumMeshes << " meshes" << std::endl; std::cout << "\t" << scene->mNumTextures << " textures" << std::endl; const aiMesh* mesh = scene->mMeshes[0]; std::cout << "\t" << mesh->mNumVertices << " vertices" << std::endl; float* vertex_array = new float[mesh->mNumVertices * 3 * sizeof(float)]; float* normal_array = new float[mesh->mNumVertices * 3 * sizeof(float)]; float* uv_array = new float[mesh->mNumVertices * 2 * sizeof(float)]; int a,b,c,d;//counters for verts norms and uvs, d for indices a = b = c = d = 0; f3_count = mesh->mNumFaces * 3; for(unsigned int j = 0; j<mesh->mNumVertices; j++){ const aiVector3D* vp = &(mesh->mVertices[j]); vertex_array[a++] = (vp->x); vertex_array[a++] = (vp->y); vertex_array[a++] = (vp->z); const aiVector3D* vn = &(mesh->mNormals[j]); normal_array[b++] = (vn->x); normal_array[b++] = (vn->y); normal_array[b++] = (vn->z); const aiVector3D* vt = &(mesh->mTextureCoords[0][j]); //uv_array[c++] = (vt->x); //uv_array[c++] = (vt->y); uv_array[c++] = 2.0f; uv_array[c++] = 2.0f; } a_count = (mesh->mNumVertices) * 8; //a_count = a+b+c; data_array = new float[a_count * sizeof(float)]; a = b = c = 0; for(int i = 0; i<(mesh->mNumVertices * 8);){ data_array[i++] = vertex_array[a++]; data_array[i++] = vertex_array[a++]; data_array[i++] = vertex_array[a++]; data_array[i++] = normal_array[b++]; data_array[i++] = normal_array[b++]; data_array[i++] = normal_array[b++]; data_array[i++] = uv_array[c++]; data_array[i++] = uv_array[c++]; } for(int i = 0; i<a+b+c; i++){ if (i%8 == 0 && i != 0) std::cout << std::endl; std::cout << data_array[i] << " "; } index_array = new unsigned int[f3_count * sizeof(unsigned int)]; for(int i = 0; i<mesh->mNumFaces; i++){ const struct aiFace* vf = &(mesh->mFaces[i]); index_array[d++] = (vf->mIndices[0]); index_array[d++] = (vf->mIndices[1]); index_array[d++] = (vf->mIndices[2]); } std::cout << std::endl; for(int i = 0; i<d; i++) std::cout << index_array[i] << " "; std::cout << std::endl; std::cout << "Acount:" << a_count << "(" << a_count/8 << ")" << " F3count:" << f3_count<< "(" << f3_count/3 << ")" << std::endl; std::cout << "DONE" << std::endl; } glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, a_count * sizeof(float), &data_array[0], GL_STATIC_DRAW); glGenBuffers(1, &ind); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ind); glBufferData( GL_ELEMENT_ARRAY_BUFFER, f3_count * sizeof(unsigned int), &index_array[0], GL_STATIC_DRAW ); unsigned int normal_offset = 3 * sizeof(float); unsigned int uv_offset = 6 * sizeof(float); unsigned int stride = 8 * sizeof(float); glGenVertexArrays(1, &vao); glBindVertexArray(vao); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ind); glBindBuffer(GL_ARRAY_BUFFER, vbo); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, (void*)0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, stride, (void*)normal_offset); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, stride, (void*)uv_offset); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); }; void draw(){ glBindVertexArray(vao); glUseProgram(program); model_matrix = glm::mat4(1.0f); view_matrix = glm::lookAt(glm::vec3(cam_x,cam_y,cam_z), glm::vec3(tar_x,tar_y,tar_z), glm::vec3(up_x,up_y,up_z)); proj_matrix = glm::perspective(70.0f, (float)width/height, 0.1f, 50.0f); glm::mat4 mvp = proj_matrix * view_matrix * model_matrix; glUniformMatrix4fv(glGetUniformLocation(program,"mvp"), 1, GL_FALSE, &mvp[0][0]); glDrawElements(GL_TRIANGLES, f3_count, GL_UNSIGNED_SHORT, (void*)0); } }; std::vector<Mesh> meshes; unsigned int compile_shader(const char* v_source, const char* f_source){ int vs_status = -1; int fs_status = -1; unsigned int vs = glCreateShader (GL_VERTEX_SHADER); glShaderSource (vs, 1, &v_source, NULL); glCompileShader (vs); glGetShaderiv(vs, GL_COMPILE_STATUS, &vs_status); if(vs_status != GL_TRUE){ int length; char buffer[1000]; glGetShaderInfoLog(vs, sizeof(buffer), &length, buffer); std::cout <<"Vertex Shader ID:"<< vs << " OpenGL Shader Compile Error at " << buffer << std::endl; } unsigned int fs = glCreateShader (GL_FRAGMENT_SHADER); glShaderSource (fs, 1, &f_source, NULL); glCompileShader (fs); glGetShaderiv(fs, GL_COMPILE_STATUS, &fs_status); if(fs_status != GL_TRUE){ int length; char buffer[1000]; glGetShaderInfoLog(fs, sizeof(buffer), &length, buffer); std::cout << "Fragmemt Shader ID: " << fs << "OpenGL Shader Compile Error at " << buffer << std::endl; } unsigned int program = glCreateProgram (); glAttachShader (program, fs); glAttachShader (program, vs); glLinkProgram (program); glDeleteShader(vs); glDeleteShader(fs); return program; } void init(){ if(SDL_Init(SDL_INIT_VIDEO) != 0) std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl; std::cout << "SDL initialized." << std::endl; SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE ); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); window = SDL_CreateWindow("Warmachine ;)", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL); SDL_SetWindowPosition(window, 50, 50); gl_context = SDL_GL_CreateContext(window); if (gl_context == NULL) std::cout << "There was an error creating the OpenGL context." << std::endl; SDL_GL_MakeCurrent(window, gl_context); SDL_GetWindowDisplayMode(window, &current); std::cout << "OpenGL VERSION: " << glGetString(GL_VERSION) << std::endl; std::cout << "OpenGL RENDERER: " << glGetString(GL_RENDERER) << std::endl; std::cout << "GLSL VERSION: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; std::cout << "OpenGL VENDOR: " << glGetString(GL_VENDOR) << std::endl; glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); //glEnable(GL_CULL_FACE); //glCullFace(GL_BACK); //glFrontFace(GL_CCW); program = compile_shader(vs, fs); meshes.push_back(Mesh("terrain.obj")); glClearColor(0.2f, 0.2f, 0.2f, 0.0f); } int input(){ int exit = 1; while(SDL_PollEvent(&event)){ if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE){ exit = 0; } if (event.type == SDL_MOUSEWHEEL){ if(event.wheel.x > 0) cam_x += 0.5f; if(event.wheel.x < 0) cam_x -= 0.5f; if(event.wheel.y > 0) cam_y += 0.5f; if(event.wheel.y < 0) cam_y -= 0.5f; } } return exit; } int main(){ char cwd[1024]; if (getcwd(cwd, sizeof(cwd)) != NULL) fprintf(stdout, "Current working dir: %s\n", cwd); init(); while(input()){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for(int i = 0; i<meshes.size(); i++){ meshes[i].draw(); } SDL_GL_SwapWindow(window); } return 0; }
  3.  I just preferred the elegance of having all of my data in one unit but being that i couldn't find a solution, it looks like i'll have to split like you suggested. Thanks. 
  4. hi,   I'm trying to implement per pixel linked list for order independent transparency based on the sample from the OpenGL redbook 8th edition. Their implementation is two pass where the first pass builds an unordered list per pixel of all fragments and a second pass to sort them. I would like to implement it in a single pass using insertion sort mainly for speed purposes. My problem is i can't figure out how to do an atomic insertion sort. I have a r32ui head pointer buffer(uimage2D) that holds atomically updated counters that correspond to the first fragment in each list and a second 1d rgba32ui buffer(uimageBuffer) that holds all the fragments with the uint next pointer in the x component, packed rgb color in the y component and depth in the z component for sorting.   The problem is when the fragment shader runs for a fragment and i step through the linked list and find where to insert the new fragment, I don't know how to atomically update the pointer uints that are stored in the x component of my fragment buffer. From what i understand its only possible to use atomic operations on r32i and r32ui format images. But i'm sure i've heard of per pixel linked list being done with insertion sort.   Is it possible to do this without breaking by fragment buffer into r32ui?   thanks
  5. Oh, and the reason that i use 0.999999 when i call unproject for some z's is because i was getting undefined or -inf or something like that when i used 1.0 and i thought if i got an actual number output from the function it would be more useful in finding out what i was doing wrong.
  6. I'm trying to take the corners of my camera frustum in NDC and convert them to into world space and use those coordinates to generate something like cascading shadow maps. I've been trying to mimic the gluUnProject function (from https://www.opengl.org/wiki/GluProject_and_gluUnProject_code) except instead of starting with screen coordinates then going to NDC i just pass the NDC as arguments. Problem is the output of my unproject function is incorrect. Here's a visualization of my scene and camera to help explain it. Its not to scale or anything but it should help you understand. My camera is places at (0, 0, 5) looking at (0,0,0) which is where the monkey is placed. The near plane is set to 0.000001(for testing purposes) and the far plane is set to 50. So the z value of the near coordinates should be roughly 5(which it is) and the z value for the far coordinates should be about -45 but for some reason this comes out to be 3.294118.    Here's what my unproject looks like this: void unproject(float x, float y, float z){ vec4 in; vec4 out; mat4 m; mat4 A; vec4 world_coord; vec3 object_coordinate; A = mvp_matrix; m = inverse(A); //in the sample i was following, theres a bit of code to convert screen coords to NDC //i just set in equal to my parameters which are already in NDC in = vec4(x,y,z,1.0); out = m * in; out[3]=1.0/out[3]; world_coord[0] = out[0]*out[3]; world_coord[1] = out[1]*out[3]; world_coord[2] = out[2]*out[3]; } I call unproject() like this. Once for every corner of the frustum and once for a point i'll use to set lookAt for my shadow maps: unproject(-1.0, -1.0, -1.0);//near bottom left unproject(-1.0, -1.0, 0.999999);//far bottom left unproject(-1.0, 1.0, -1.0);//near top left unproject(-1.0, 1.0, 0.999999);//near top left unproject(1.0, -1.0, -1.0);//near bottom right unproject(1.0, -1.0, 0.999999);//far bottom right unproject(1.0, 1.0, -1.0);//near top right unproject(1.0, 1.0, 0.999999);//far top right unproject(0.0, -1.0, 0.0);//the point at the bottom middle of NDC When i print the output of this function i get:  -0.000001 -0.000001 4.999999 //near bottom left -2.108860 -1.318038 3.294118 //far bottom left -0.000001 0.000001 4.999999 //near top left -2.108860 1.318038 3.294118 //near top left 0.000001 -0.000001 4.999999 //near bottom right 2.108860 -1.318038 3.294118 //far bottom right 0.000001 0.000001 4.999999 //near top right 2.108860 1.318038 3.294118 //far top right 0.000000 -0.000001 4.999998//the point at the bottom middle of NDC The z values of the near plane seem right but the x and y values seem wrong. And the x, y and z values of the far plane are wrong. It may have something to do with the inverted matrix because when i print it i get this:  MVP MATRIX 0.892592 0.000000 0.000000 0.000000 0.000000 1.428148 0.000000 0.000000 0.000000 0.000000 -1.000000 -1.000000 0.000000 0.000000 4.999998 5.000000 INVERTED MATRIX 1.120332 0.000000 -0.000000 0.000000 0.000000 0.700207 0.000000 -0.000000 -0.000000 0.000000 -2621440.000000 -524288.000000 0.000000 -0.000000 2621439.000000 524288.000000 500000 and 200000 seem a bit large for this but i got the same thing from separate inverse matrix calculators.   Any ideas?
  7.   Ahhhh, i completely forgot about texture units. That pretty much answered my question. Thanks.
  8. Sorry, a bit of a noob question but, is it possible to apply a variable number of shadow maps in one pass?  By variable i mean having a single pixel shader that can take any number of light matrices and shadow maps and calculate the lighting on that pixel from all the lights in one pass. Is that possible? What I’d like to do and what seems most efficient to me is to have all of my shadow maps and light matrices in arrays of something similar and pass them to glsl so that I could do all of my shadowing in one pass but from what I’ve been able to find I don’t think its possible to pass an array of matrices or an array of structs to glsl. Is the only option to do a pass per light and save the previous lighting in a texture? It seems like there would be a more efficient method.   If this isn't possible whats the standard method for rendering with multiple shadow maps?  
  9. theHOUSE16

    Efficient shadow maps of multiple lights

    Basically i'm asking is there a way to do all of my shadows in 1 pass.
  10. theHOUSE16

    Efficient shadow maps of multiple lights

    I've already implemented deferred shading and a single shadow map in my deferred shader but i'm interested in how to take that shader and add more shadow maps to it.   
  11. I'm a little new to graphics programming so sorry if this question is a little on the basic side but what is an efficient implementation of a variable number of shadow maps? By variable i mean having a single pixel shader that can take any number of lights matrices and shadow maps and calculate the lighting on that pixel from all the lights without having to run the shader multiple times. Is this possible? I was thinking something like having an array of lights and their textures, passing that to glsl and iterating over the array in a single shader but from what I've read you can't pass an array of mat4s to glsl and you can't pass an array of structs either.    And if its not possible what is the standard way of handling multiple lights?
  12. It was because i wasnt using GL_DEPTH_BUFFER_BIT when i cleared the default buffer originally. 
  13. I think i've solved it but i'm not exactly sure why it works. If i bind the default framebuffer AND glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) before i bind the bind my second framebuffer and glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) that so that i can draw to it, then it renders the quad and not the monkey like it should but otherwise it only renders the clearcolor. It seems to be something dealing with glclear.
  14. I'm trying to write a deferred renderer with sdl and opengl and am having trouble with the initial switching framebuffers part. Before i tried to switch framebuffers, when i was still foward rendering my scene looked like this. Its a little crude but it gets the point across. [attachment=22724: figure.jpg] On the left is the camera and at the very front of screenspace(z= -1) is the quad that i would texture with the output from my first pass. Behind that is the suzanne model. So when i foward render i get this(the color is the texture coords, i havent tried applying a texture yet): [attachment=22725:Screen Shot 2014-07-19 at 5.44.40 AM.png] and if i move the quad to z = -1.1 i get this: [attachment=22726:Screen Shot 2014-07-20 at 1.17.29 AM.png] Just like you would expect. The problem is as soon as i add glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); before rendering suzanne it only renders the clearcolor and that is all. I do switch back to the default framebuffer for the quad render and the framebuffer status is 0x8cd5(complete).    Here's my code:   init const char* vertex_shader = getVShader(); const char* fragment_shader = getFShader(); const char* ss_v_source = getSSVS(); const char* ss_f_source = getSSFS(); SDL_GetWindowDisplayMode(window, &current); init_camera(); glClearColor(0.95f, 0.95f, 0.95f, 0.0f); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); head_node = create_graph("Data/Scene/test.grf"); unsigned int vs = glCreateShader (GL_VERTEX_SHADER); glShaderSource (vs, 1, &vertex_shader, NULL); glCompileShader (vs); check_shader(vs); unsigned int fs = glCreateShader (GL_FRAGMENT_SHADER); glShaderSource (fs, 1, &fragment_shader, NULL); glCompileShader (fs); check_shader(fs); shader_program = glCreateProgram (); glAttachShader (shader_program, fs); glAttachShader (shader_program, vs); glLinkProgram (shader_program); //init ss quad glGenBuffers(1, &ss_vbo); glBindBuffer(GL_ARRAY_BUFFER, ss_vbo); glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(float), &ss_quad_pos, GL_STATIC_DRAW); glGenBuffers(1, &ss_st); glBindBuffer(GL_ARRAY_BUFFER, ss_st); glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(float), &ss_quad_st, GL_STATIC_DRAW); glGenVertexArrays(1, &ss_vao); glBindVertexArray(ss_vao); glBindBuffer(GL_ARRAY_BUFFER, ss_vbo); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, ss_st); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, NULL); glEnableVertexAttribArray(1); //set up ss shader ss_v_shader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(ss_v_shader, 1, &ss_v_source, NULL); glCompileShader(ss_v_shader); check_shader(ss_v_shader); ss_f_shader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(ss_f_shader, 1, &ss_f_source, NULL); glCompileShader(ss_f_shader); check_shader(ss_f_shader); ss_program = glCreateProgram(); glAttachShader(ss_program, ss_v_shader); glAttachShader(ss_program, ss_f_shader); glLinkProgram(ss_program); //fbo set up glGenFramebuffers(1, &framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); //generate and bind texture for normals glGenTextures(1, &normals_tex); glBindTexture(GL_TEXTURE_2D, normals_tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, window_data.width, window_data.height, 0, GL_RGB, GL_FLOAT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //attach to fbo glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, normals_tex, 0); //check fbo status GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); printf("FrameBuffer status: 0x%x\n", status); glBindFramebuffer(GL_FRAMEBUFFER, 0); } main loop render_scene(); deferred(); SDL_GL_SwapWindow(window); render_scene glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); proj_matrix = perspective(70.0f, (float)current.w/(float)current.h, 0.1f, 1000.0f); view_matrix = lookAt(vec3(camera.position[0],camera.position[1],camera.position[2]), vec3(camera.target[0],camera.target[1],camera.target[2]), vec3(camera.up[0],camera.up[1],camera.up[2])); mat4 mvp_matrix = proj_matrix * view_matrix * curr->transform; mat4 world_matrix = curr->transform; GLint mvp_id = glGetUniformLocation(shader_program,"mvp"); glUseProgram(shader_program); glUniformMatrix4fv(mvp_id, 1, GL_FALSE, &mvp_matrix[0][0]); GLint world_matrix_id = glGetUniformLocation(shader_program,"world_pos"); glUseProgram(shader_program); glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, &world_matrix[0][0]); glUseProgram (shader_program); glBindVertexArray (curr->mesh->vao); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, curr->mesh->ibo); glDrawElements(GL_TRIANGLES, 3 * curr->mesh->f_count, GL_UNSIGNED_INT, (void*)0); and deferred glBindFramebuffer(GL_FRAMEBUFFER, 0); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(ss_program); glBindVertexArray(ss_vao); glDrawArrays(GL_TRIANGLES, 0, 6); I havent actually taken the output from the geometry pass and tried to use it in the deferred function which is why any uniforms and all of that kind of stuff is missing. At this point i'm only trying to figure out why switching to another framebuffer and back is causing problems. What am i missing?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!