Jump to content
  • Advertisement

Maxjen

Member
  • Content Count

    27
  • Joined

  • Last visited

Everything posted by Maxjen

  1. Maxjen

    Crazy GLSL bug

    Thanks again!   Well, with the fix it is effectively clamped now. It can't get greater than 1 because both vectors for the dot product are normalized and if it is smaller than 0 the if-block where the specularColor is calculated wont be entered and specularColor stays at (0, 0, 0).
  2. Hi,   I am experiencing a really weird GLSL bug. I have implemented point lights following this tutorial, but I get some strange artefacts and I narrowed them down to the following line in my fragment shader: specularFactor = pow(specularFactor, matSpecularPower); specularFactor is of type "highp float" and matSpecularPower is "uniform highp float" and set to 1.0 for debugging purposes. If I change the line to the following everything looks different and I don't have those black artefacts: specularFactor = pow(specularFactor, 1.0); Here are some screenshots: with first line with second line   How is this possible if matSpecular is also set to 1.0? And I am sure it is because I also get the first result if I change it to this: if (matSpecularPower == 1.0) { specularFactor = pow(specularFactor, matSpecularPower); } And the second result if I change it to this: if (matSpecularPower == 1.0) { specularFactor = pow(specularFactor, 1.0); } I am on Linux and have an Intel graphics card if that is important. Help, please! Even ideas of things I could try would be appreciated.
  3. Maxjen

    Crazy GLSL bug

    Okay, I figured it out, thanks! Like you suggested I tried different values increasing by 0.1 and found out that both lines give identical results except if the value is exactly 1. My guess is that if you write pow(specularFactor, 1.0) openGL removes that line because it expects the result to be specularFactor. However in my case specularFactor was negative for some fragments and then pow yields undefined results (apparently even if the second parameter is 1.0). The solution was a simple if statement: if (specularFactor > 0.0) { specularFactor = pow(specularFactor, matSpecularPower); ... Now the artefacts are gone and everything works perfectly.
  4. Maxjen

    C++ c

    Hi,   I made a very simple container class because I need a vector where I can remove elements in the middle without changing the position of the other elements but I am worried that it doesn't free up everything when I delete it. Here is the code: template <typename T> class Vector { private: T* elements; int elementCount; int elementCapacity; int freeElement; // first free element int* freeElementList; // each array element is the index of the next free element public: Vector(int initialCapacity) { elementCount = 0; elementCapacity = initialCapacity; elements = (T*)malloc(elementCapacity * sizeof(T)); freeElement = 0; freeElementList = (int*)malloc(elementCapacity * sizeof(int)); for (int i = 0; i < elementCapacity; ++i) freeElementList[i] = i + 1; } ~Vector() { free(freeElementList); free(elements); } int addElement(T& element) { if (elementCount == elementCapacity) { elementCapacity *= 2; int* oldFreeElementList = freeElementList; freeElementList = (int*)malloc(elementCapacity * sizeof(int)); memcpy(freeElementList, oldFreeElementList, elementCount * sizeof(int)); free(oldFreeElementList); for (int i = elementCount; i < elementCapacity; ++i) freeElementList[i] = i + 1; T* oldElements = elements; elements = (T*)malloc(elementCapacity * sizeof(T)); memcpy(elements, oldElements, elementCount * sizeof(T)); free(oldElements); } elements[freeElement] = element; int result = freeElement; freeElement = freeElementList[freeElement]; elementCount++; return result; } void removeElement(int index) { freeElementList[index] = freeElement; freeElement = index; elementCount--; } T getElement(int index) { return elements[index]; } }; For example if I use it to store STL vectors will the destructor actually delete all their elements?   EDIT: sorry, I forgot to set the right title. It was supposed to be something like "C++ custom container"
  5. Maxjen

    C++ c

    Ah, I just overlooked it. I expected it in the removeElement method, but it was in the clear method.   Your correct. A warning when I accidentally do something wrong is all I need, I just didn't see that it's already there.   Yes, that's better, thanks!
  6. Maxjen

    C++ c

    Okay, now I know that you can write unsigned instead of unsigned int. Also thanks for showing how to implement the rule of three. I think there might be a little bug if removeElement is called for an element that isn't used. The value of nextFreeIndex of that element would get lost and be overridden by freeIndex. Maybe an assertion that isUsed() is -1 like you suggested earlier would help here?   I agree about the name, though it's hard to think of something new. Maybe just call it Container?
  7. Maxjen

    C++ c

    Wow, lots of interesting stuff. I didn't even know you could have internal structs. That alone will be very helpful in some other places. It was a bit overwhelming, but I think I understood most of it now (though I wouldn't be able to reproduce it) except the reinterpret cast. I will look that up.   I will also look at the code some more and try to adapt as much as possible to improve my coding skills. Thanks for taking the time! You guys are awesome!
  8. Maxjen

    C++ c

    Ah, I didn't know about operator new(). That should make everything a bit cleaner. Learned something again, thanks!
  9. Maxjen

    C++ c

    I never actually used this class for vertex buffers but initially I started managing memory like this because I needed to upload stuff into the vertex buffer. I later thought it was neat and made it into a class without realizing that it wouldn't work correctly if used with non-trivial objects. To fix that I started this post but it's probably more trouble than it's worth.   I did that at first, but I adjusted my code according to fastcall22's second response using placement new.   I think I am currently not relocating objects with C memory functions. I use placement new to copy construct the old objects. But I just noticed that I forgot to call the destructors of the released objects when relocating.   It turns out that I don't need this class. If anything I will make a version only for trivial objects. But I learned plenty about placement new, smart pointers, initialization lists and the rule of three/five, so thanks! I appreciate all the responses.
  10. Maxjen

    C++ c

    I thought about it a bit more and I think I can actually do what I want with a map or a list. Initially it was important that the position of the elements remained the same because I uploaded the whole thing into an opengl vertex buffer. I wanted to be able to delete vertices in the middle, but if I used the swap-back method the index buffer wouldn't be correct anymore.   However in my new render class I am using a huge container with all the vertex data of my world and in every frame I assemble a vertex buffer and an index buffer using only the elements of the container that I want to render.(which I will later do with some sort of spatial partitioning) So now only that assembled vertex buffer needs to be in contiguous space and for that I can use a normal STL vector.(since I don't have to delete anything)   I will be thinking about what the most optimal container for the vertex pool is.   In my use case I wouldn't have to iterate over the vector except to delete it. And the classes that would use the vector would keep track of all the elements they added and only use getElement for those elements.   Even though I probably wont use the class anymore, did I get it right now? template <typename T> class Vector { private: unsigned char* elements; int elementCount; int elementCapacity; int freeElement; // first free element int* freeElementList; // each array element is the index of the next free element bool* isUsed; public: Vector(int initialCapacity) { elementCount = 0; elementCapacity = initialCapacity; elements = new unsigned char[elementCapacity * sizeof(T)]; freeElement = 0; freeElementList = new int[elementCapacity]; isUsed = new bool[elementCapacity]; for (int i = 0; i < elementCapacity; ++i) { freeElementList[i] = i + 1; isUsed[i] = false; } } ~Vector() { for (int i = 0; i < elementCapacity; ++i) { if (isUsed[i]) ((T*)(elements + i * sizeof(T)))->~T(); } delete [] freeElementList; delete [] elements; delete [] isUsed; } int addElement(const T& element) { if (elementCount == elementCapacity) { elementCapacity *= 2; int* oldFreeElementList = freeElementList; freeElementList = new int[elementCapacity]; memcpy(freeElementList, oldFreeElementList, elementCount * sizeof(int)); delete [] oldFreeElementList; bool* oldIsUsed = isUsed; isUsed = new bool[elementCapacity]; memcpy(isUsed, oldIsUsed, elementCount * sizeof(bool)); delete [] oldIsUsed; for (int i = elementCount; i < elementCapacity; ++i) { freeElementList[i] = i + 1; isUsed[i] = false; } unsigned char* oldElements = elements; elements = new unsigned char[elementCapacity * sizeof(T)]; for (int i = 0; i < elementCount; ++i) { if (isUsed[i]) new (elements + i * sizeof(T)) T(*((T*)(oldElements + i * sizeof(T)))); } delete [] oldElements; } new (elements + freeElement * sizeof(T)) T(element); isUsed[freeElement] = true; int result = freeElement; freeElement = freeElementList[freeElement]; elementCount++; return result; } void removeElement(int index) { if (isUsed[index]) { ((T*)(elements + index * sizeof(T)))->~T(); freeElementList[index] = freeElement; freeElement = index; elementCount--; } } T getElement(int index) { return *((T*)(elements + index * sizeof(T))); } };
  11. Maxjen

    C++ c

    Ok, I changed the class to use new/delete instead of malloc/free and I am calling the destructors manually. However, I don't know if I still have to call the constructors manually. I think right now the line "elements[freeElement] = element;" uses the copy constructor to construct the elements, or not? template <typename T> class Vector { private: T* elements; int elementCount; int elementCapacity; int freeElement; // first free element int* freeElementList; // each array element is the index of the next free element bool* isUsed; public: Vector(int initialCapacity) { elementCount = 0; elementCapacity = initialCapacity; elements = new T [elementCapacity]; freeElement = 0; freeElementList = new int [elementCapacity]; isUsed = new bool [elementCapacity]; for (int i = 0; i < elementCapacity; ++i) { freeElementList[i] = i + 1; isUsed[i] = false; } } ~Vector() { for (int i = 0; i < elementCapacity; ++i) { if (isUsed[i]) elements[i].~T(); } delete [] freeElementList; delete [] elements; delete [] isUsed; } int addElement(T& element) { if (elementCount == elementCapacity) { elementCapacity *= 2; int* oldFreeElementList = freeElementList; freeElementList = new int [elementCapacity]; memcpy(freeElementList, oldFreeElementList, elementCount * sizeof(int)); delete [] oldFreeElementList; bool* oldIsUsed = isUsed; isUsed = new bool [elementCapacity]; memcpy(isUsed, oldIsUsed, elementCount * sizeof(bool)); delete [] oldIsUsed; for (int i = elementCount; i < elementCapacity; ++i) { freeElementList[i] = i + 1; isUsed[i] = false; } T* oldElements = elements; elements = new T [elementCapacity]; memcpy(elements, oldElements, elementCount * sizeof(T)); delete [] oldElements; } elements[freeElement] = element; isUsed[freeElement] = true; int result = freeElement; freeElement = freeElementList[freeElement]; elementCount++; return result; } void removeElement(int index) { elements[index].~T(); freeElementList[index] = freeElement; freeElement = index; elementCount--; } T getElement(int index) { return elements[index]; } }; About the rule of three: If I don't plan to copy instances of the class do I still need it?
  12. Hi,   I made a simple scene with only one triangle and am now trying to use a projection matrix created by glm. However when I multiply each vertex with it in my shader the triangle disappears.   This is how I create the projection matrix: projectionMatrix = glm::perspective(45.0f, 800.0f/600.0f, 0.1f, 100.0f);   My triangle vertices have these coordinates: v1(-1, -1, 1) v2(1, -1, 1) v3(0, 1, 1)   I multiply the vertices with the matrix like this: gl_Position = projectionMatrix * vec4(in_Position.x, in_Position.y, in_Position.z, 1.0);   I am also a bit confused how the projection matrix works. After reading this tutorial I compared the matrix shown there with the one in glm and they differ slightly. For example glm uses the w component of the vector to store -z instead of +z. Doesn't this flip the signs of the x and y components after perspective divide? I also manually multiplied vectors with zNear(0.1f) and zFar(100.0f) as their z component. I think the multiplication should give values that become -1 and 1 after perspective divide but it doesn't.   glm::vec4 v1(-1.0f, -1.0f, 0.1f, 1.0f); v1 = projectionMatrix * v1;        // v1 = ( -1.810660, -2.414213, -0.300400, -0.100000)   glm::vec4 v2(1.0f, -1.0f, 100.0f, 1.0f); v2 = projectionMatrix * v2;       // v2 = ( 1.810660, -2.414213, -100.400406, -100.000000)   Hopefully someone can help me.
  13. Maxjen

    glm and perspective matrices

    I finally found the problem. In my shader-class I called glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, stride, offset) with 2 instead of 3 as the size parameter. This was because I mainly copy pasted the class from an older 2d project where I only needed 2 components per vertex. Oh well, at least I learned quite a bit about projection matrices.
  14. Maxjen

    glm and perspective matrices

    Thanks! It still doesn't work with z = -1, but the projection matrix on that page is the same as the one in glm so now I should be able to figure out what the problem is.
  15. Hi,   I am trying to use uniform variables in my shader but for some reason glGetUniformLocation always returns -1.  I am mostly following Lazy Foo's tutorial. Here is the relevant code: PointLineShader::PointLineShader() { GLuint vertexShaderId = loadShader("Shader/pointLine.vert", GL_VERTEX_SHADER); GLuint fragmentShaderId = loadShader("Shader/pointLine.frag", GL_FRAGMENT_SHADER); programId = glCreateProgram(); glAttachShader(programId, vertexShaderId); glAttachShader(programId, fragmentShaderId); glLinkProgram(programId); glDetachShader(programId, vertexShaderId); glDetachShader(programId, fragmentShaderId); glDeleteShader(vertexShaderId); glDeleteShader(fragmentShaderId); positionLocation = glGetAttribLocation(programId, "in_Position"); if (positionLocation == -1) { printf("%s is not a valid glsl program variable!\n", "in_Position"); } colorLocation = glGetAttribLocation(programId, "in_Color"); if (colorLocation == -1) { printf("%s is not a valid glsl program variable!\n", "in_Position"); } // this doesn't work projectionMatrixLocation = glGetUniformLocation(programId, "projectionMatrix"); if (projectionMatrixLocation == -1) { printf("%s is not a valid glsl program variable!\n", "projectionMatrix"); } modelViewMatrixLocation = glGetUniformLocation(programId, "modelViewMatrix"); if (modelViewMatrixLocation == -1) { printf("%s is not a valid glsl program variable!\n", "modelViewMatrix"); } } And the vertex shader: #version 400 uniform mat4 projectionMatrix; uniform mat4 modelViewMatrix; in vec2 in_Position; in vec4 in_Color; out vec4 ex_Color; void main(void) { gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(in_Position.x, in_Position.y, 0.0, 1.0); //gl_Position = projectionMatrix * modelViewMatrix * vec4(in_Position.x, in_Position.y, 0.0, 1.0); ex_Color = in_Color; } To initialize openGL I am using SDL2 and glew. I noticed that I set the openGL version to 3.2 in SDL, but in the shaders I have "#version 400". If I change or remove it the shader won't compile.   I am not sure if it might be related, but textures also don't work right now even though I am using the same code as in my other program which uses SFML except for the image loading functions.
  16. Ok, I figured it out. The problem was that I didn't use the variables so they were compiled out. Maybe that is what Geometrian meant. The detaching of the shader after linking should be okay: http://stackoverflow.com/questions/9113154/proper-way-to-delete-glsl-shader But thanks for the #version 400 core tip. Now I only have to solve the texture problem.
  17. That didn't work Also, I think the variables that are being optimized out are gl_ProjectionMatrix, etc. That is why I am trying to use my own variables.   Maybe I am doing something wrong with the initialization? This is how I create my openGL context: if (SDL_Init(SDL_INIT_VIDEO) < 0) // Initialize SDL's Video subsystem sdldie("Unable to initialize SDL"); // Or die on error // Request opengl 3.2 context. // SDL doesn't have the ability to choose which profile at this time of writing, // but it should default to the core profile SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); // Turn on double buffering with a 24bit Z buffer. // You may need to change this to 16 or 32 for your system SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); // Create our window centered at 512x512 resolution mainwindow = SDL_CreateWindow(PROGRAM_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenWidth, screenHeight, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); if (!mainwindow) // Die if creation failed sdldie("Unable to create window"); checkSDLError(__LINE__); // Create our opengl context and attach it to our window maincontext = SDL_GL_CreateContext(mainwindow); checkSDLError(__LINE__); // This makes our buffer swap syncronized with the monitor's vertical refresh SDL_GL_SetSwapInterval(1); GLenum status = glewInit(); if(status != GLEW_OK) { fprintf(stderr, "INFO: glew couldn't be initialized. Exit\nGLEW Error: %s", glewGetErrorString(status)); close(); }
  18. Hi,   I'm trying to compile a simple SDL2 application with cmake under Linux. My CMakeLists.txt looks like this: project(Test) cmake_minimum_required(VERSION 2.8) aux_source_directory(. SRC_LIST) find_package(OpenGL) add_executable(${PROJECT_NAME} ${SRC_LIST}) #target_link_libraries(${PROJECT_NAME} /usr/local/lib/libSDL2.so ${OPENGL_gl_LIBRARY}) target_link_libraries(${PROJECT_NAME} /usr/local/lib/libSDL2.a pthread dl rt ${OPENGL_gl_LIBRARY}) It works immediately if I link it to libSDL2.so, but if I link it to libSDL2.a I have to add pthread, dl and rt or it gives me undefined reference errors like /usr/bin/ld: /usr/local/lib/libSDL2.a(SDL_syssem.o): undefined reference to symbol 'sem_getvalue@@GLIBC_2.2.5'. Can somebody explain why this is? And is it correct that if I link my application to libSDL2.a that I can execute the binary file on any Linux installation without requiring SDL2 to be installed?
  19. Maxjen

    link libSDL2.a with cmake

    I think right now I am only linking libSDL2 statically. Will I still have trouble? project(Test) cmake_minimum_required(VERSION 2.8) set(SRC_LIST main.cpp) find_package(OpenGL) #SDL2 plus dependencies set(SDL2     /usr/local/lib/libSDL2.a     pthread     dl     rt     m ) include_directories("${PROJECT_SOURCE_DIR}/include/") add_executable(${PROJECT_NAME} ${SRC_LIST}) target_link_libraries(${PROJECT_NAME} ${SDL2} ${OPENGL_gl_LIBRARY}) I would like to be able to for example send the binary file to friends so they can test it and I think it would be too much to ask them to install SDL2 because on most distributions it can't be easily installed with the package manager. But it would be perfectly fine to link everything else dynamically.
  20. Maxjen

    link libSDL2.a with cmake

    Thanks, that was very helpful!   I did ldd libSDL2.so and it listed these dependencies. $ ldd libSDL2.so     linux-vdso.so.1 =>  (0x00007fff507fe000)     libm.so.6 => /lib64/libm.so.6 (0x00007fa64d693000)     libdl.so.2 => /lib64/libdl.so.2 (0x00007fa64d48f000)     libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa64d272000)     librt.so.1 => /lib64/librt.so.1 (0x00007fa64d06a000)     libc.so.6 => /lib64/libc.so.6 (0x00007fa64ccb2000)     /lib64/ld-linux-x86-64.so.2 (0x0000003b9b400000) However, I am still unsure if I have to add the dependencies that I haven't specified in my CMakeLists.txt so that it still works with those DSO linking changes. As mentioned I had to add libpthread, libdl, and librt. Must I now add libm, libc, linux-vdso and ld-linux-x86-64?  
  21. [quote name='Brother Bob' timestamp='1357223653' post='5017111'] Bind a VBO and set a pointer, then bind another VBO and set another pointer. Yes, the second binding will unbind the first one, but a vertex attribute pointer depends on the VBO binding when the pointer is set, not when the arrays are drawn. [/quote] Thank you very much, that is all I needed to know! [quote name='haegarr' timestamp='1357224003' post='5017115'] There is perhaps still a misunderstanding. The vertex positions are the same for the faces, edges, and point handles. You need only 1 VBO with the position, and that is the VBO I've mentioned as "shared". However, you need to transport the edge color as well, and that attribute is unique to edge rendering. Hence create another VBO for the edge color (but notice that it is still given for each vertex; but that isn't a problem with your kind of coloring the edges). [/quote] There is no misunderstanding but thanks! What you described is exactly how I was going to do it. There was only the technical problem of how to use more than one vertex buffer.
  22. Hi, I'm trying to write a 2D map editor. It is based on triangles. The problem I have is drawing the selection. Here is how it should look like when I select one vertex: [attachment=13016:selection.png] What I have is Triangle class which creates a vertex buffer where all the triangle vertex positions, colors and texture coordinates are. I have a separate class where I store the data for the selection. It has a stl map which maps two integers (vertex indices, lower first) to a structure which contains two bool values to decide if the vertices are selected or not. Now all I need is a way too use that information too draw the edges like in the picture. So for every entry in that map I want to draw a line which gets the positions of the vertices from the vertex buffer of the Triangle class and the information whether or not the vertices are selected from e.g. another vertex buffer in the Selection class. The problem is that I don't know how or if it is possible to bind two vertex buffer at once. If anyone knows or can think of a better way to do this please tell me. Oh, the picture is not exactly what I want. In my case there should be a third half selected edge that goes down from the selected vertex.
  23. No help? Basically I only want to do what was already suggested I just don't know exactly how to do it in openGL.     I want 2 VBOs but how? If I bind one buffer and then the next will the first buffer not be unbound? Or is it enough to bind the buffer, set the vertex attrib pointers and then unbind it again before the draw call?
  24. Wow, so many replies! Thanks!   To clarify what I want to do: The Triangle class will be used only for the ground. For other type of objects I will make seperate classes. And I want to perform the most basic actions on the vertices like move, rotate, scale.(like in blender) This is inspired by the game soldat. This is an example of a map in soldat.   How the drawing is done: In two passes. Somewhere in my main loop I call triangles->draw() and later selection->draw(). The Triangle class manages the vertex buffer for the triangles. It has functions to add/remove triangles and if the buffer is full it automatically creates a new buffer with twice the size and copies the data. The buffer has this structure:   struct Vertex { float x, y; // position float u, v; // texturecoords char r, g, b, a; // color }; The Triangle class also has the index buffer for drawing the triangles. This is the draw function for the triangles:   void Triangles::draw() { glUseProgram(shaderProgram); glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId); // vertex glVertexAttribPointer(vertexPositionLocation, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); // texCoord glVertexAttribPointer(texCoordLocation, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)(2 * sizeof(float))); // color glVertexAttribPointer(vertexColorLocation, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), (GLvoid*)(4 * sizeof(float))); glEnableVertexAttribArray(vertexPositionLocation); glEnableVertexAttribArray(texCoordLocation); glEnableVertexAttribArray(vertexColorLocation); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferId); glEnable(GL_TEXTURE_2D); for(int i = 0; i < triangleCount; ++i) { if(trianglesData[i].isUsed) { glBindTexture(GL_TEXTURE_2D, trianglesData[i].texture->id); glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, (GLvoid*)(sizeof(Triangle)*i)); } } glDisable(GL_TEXTURE_2D); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glDisableVertexAttribArray(vertexColorLocation); glDisableVertexAttribArray(texCoordLocation); glDisableVertexAttribArray(vertexPositionLocation); glBindBuffer(GL_ARRAY_BUFFER, 0); glUseProgram(0); }   I will also replace the for loop in the future and instead use the spatial tree from Box2D to draw only currently visible triangles.   Now the problem is the draw method of the selection class. Currently I already render white points for the vertices and I reuse the vertex buffer from the Triangle class with a new index buffer. I want to do the same for the edges, however I need additional information. For every edge where at least one vertex is selected I need two booleans to know how to draw the line. e.g. if only one vertex is selected then the line should fade from full white to transparent. I think this information doesn't belong into the Triangle class because I might e.g. use the Triangle class later in the game itself where I don't need selections. So instead I want to create a new buffer with the booleans. What I don't know is how to use them both at once. e.g. can I even do something like this:   glBindBuffer(GL_ARRAY_BUFFER, triangleVertexBufferId); glVertexAttribPointer(vertexPositionLocation, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); glBindBuffer(GL_ARRAY_BUFFER, selectionVertexBufferId); glVertexAttribPointer(vertexSelectionLocation, 2, GL_FLOAT, GL_FALSE, sizeof(Selection), 0); ... glDrawElements(GL_LINES, ...); Wouldn't the result be that only the second buffer is bound when I draw the lines? But I need both.  
  • 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!