Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by beans222

  1. The std130 layout will pad out the float to a vec4. The buffer won't be the right size for the uniform struct in the shader and the shader will read zero.
  2. beans222

    OBJ File Problem

    For example, let's make position 6 be 0,1,0. The faces would then be: f (0,1,0)/11 5/12 1/9  then later on f 7/15, (0,1,0)/16 ... Two faces can and do touch after all. They aren't assigned, the data is just used in that order. If any part of the full vertex (position + uv) doesn't match another full vertex they are unique even if part is the same (and get different indices for the GL element buffer). You will end up duplicating data, outputing a position multiple times if it appears with different uvs.   Also, easier to think of those v-lines as positions. Edit: if that's not terribly clear, I apologize. I'm exhausted. I'll post some code tomorrow if necessary.
  3. beans222

    OBJ File Problem

    If you need indices for your engine (or just want to always use indexed renders) Sponji has the right info. What I was getting at with a flat array is that you can build a flat array from the indices after you've read the file: std::vector<int> indices; // pairs: position, uv, position, uv, etc std::vector<vertex> vertices(indices.size()/2); for(int i = 0; i < indices.size()/2; ++i) { vertices[i].x = points[indices[i]].x; // and y, z vertices[i].u = texcoords[indices[i+1]].u // and v } // where points and texcoords are the v and vt from the obj file // and indices is all of the face data. and then 'vertices' is all you need into one vbo with glDrawArrays.
  4. beans222

    OBJ File Problem

    OpenGL only supports 1 index buffer, where an index refers to the "complete" vertex that includes all attributes (uv, normal, etc). The easiest way to go is to copy the position and uv coordinates to a buffer as you read (or after) the indices and just render using glDrawArrays without an element array buffer. Otherwise, you'll need to build a new index buffer based on unique pairs of position+uv.   Also, the binding of GL_ELEMENT_ARRAY_BUFFER is part of the state of a vertex array. Even if you set up glVertexAttribPointers later, you might as well bind the VAO before the element buffer and have that all set (and not messing up the previous VAO's state).
  5. The vertex shader input attributes need to be assigned a location, whether with layout or glBindAttribLocation.     There's a typo highlighted, that should be GL_UNIFORM_BUFFER. Also, I didn't try to get the lighting glsl to work, I just output red from the fragment shader to make sure there was output. It's a cube!
  6.   glBindBufferBase/Range also bind the generic target, so at least for just filling the buffer, those last two calls are the same.         This is where you need to glBindBufferBase to binding point 1 that you've set up for the block. No need to unbind it. And also stop using NULL when you mean zero.
  7. std140 layout pads a vec3 to 4.
  8. Are you just trying to implement a first person view/camera? If so, you either need to simply add the camera's look vector to position (for a floating camera); or need to cross multiply look with up (0,1,0), then the cross result with up, to get forward (for a character that can move and look in somewhat different directions).
  9. beans222

    OpenGL suddenly won't draw buffers?

    My guess would be that the shader compiler is optimizing out the 'inNormal' attribute resulting in glEnableVertexAttribArray raising invalid value (-1 for an attribute index).
  10. Have you set up the depth buffer? Needs to be enabled, cleared each frame, and the most common clear value is 1.0. Here's a wiki page about is: http://www.opengl.org/wiki/Depth_Buffer   edit: also obj indices start at 1, need to adjust to 0 for gl elements if you haven't already.
  11. GL_POLYGON draws a *single* polygon. Try hitting 'triangulate' in blender before exporting to obj and rendering GL_TRIANGLES.
  12.   This. You are sending the 8 vertices of a cube to GL, but drawing triangles that's not going to work (cube has 6 faces that are quads = 12 total triangles). You need to make a GL_ELEMENT_ARRAY buffer out of the faces section of the obj file data.   If you haven't already seen this online book, stop now and read: http://arcsynthesis.org/gltut/
  13. beans222

    Noob question about glDrawArrays

    2904 / 3 = 968. (it is divisible)
  14. It sounds like instancing is extactly what you want. You can create a vertex array with only the instance attribute(s) enabled/setup and avoid using the 6 vertices all together, then in the shader use gl_VertexID? to determine which vertex of the quad it is. Use glDrawArraysInstanced normally [eg for 2 instances of the quad: glDrawArraysInstanced(GL_TRIANGLES, 0, 6, 2) ]
  15. How are you setting up the ModelView matrix to use instancing?
  16. beans222

    Stir, a C/C++ build tool

      The user can set include_dirs as well as libs (anything without .a gets a -l), although I now realize somehow library search directories (-L) got left behind. I forgot about pkg-config (thank you), but it should (keyword ) currently work by just putting it (the back-tick quoted cmd) in the respective cflags and ldflags settings. Maybe I should come up with specific settings (pkgs, pkg_libs, pkg_cflags, etc) to make it less error-prone though.   Can always write a tweaked config file and use a command-line option to change the build directory (compiling into the source tree is not yet supported).     Currently the link command depends on the file type of the set output file. Stir seeing .so will trigger a bunch of "-shared" flags. I haven't really got around to testing that yet. I admit COFF will very well take some extra work (been a while since I've dealt with .DLLs).     Not sure about Mac OS, if the compilers work the same way generating one object per source and then link, things should work out (mainly I just have hard-coded file extensions and command-line options use - instead of configured to /, being the problem porting). As for cross-building, the compiler and linker are settings, so you can still have the system compiler be "gcc", but then have "gcc_elf_x86-64" for osdev kernel development. or Atmel, etc. Not sure it would matter to Stir.     In Stir, I have several "pseudo-targets" that make calling Stir look like common usage of Make, 'clean' and 'all'. I could add 'install' that runs either a default platform-specific install pattern or runs a section of the config file (I already have sections called before/after that can run shell scripts for before the project and after a successful link).     Thanks, I'll have a look at those later tonight.
  17. beans222

    Stir, a C/C++ build tool

    Not liking the available options of CMake, Scons, or plain old Make, I decided to write my own utility. Stir, best for small/medium projects (I imagine parts don't scale well yet), only needs to be told the directory structure of a project (or projects), it will automatically search for c/c++ sources files along with their dependencies (currently requires the compiler support the -MMD switch).   It's pretty new, but it's starting to be usable. If anyone could give it a try and some feedback, I'd appreciate it. The doc.html file on the repository has the information on the configuration file format, and I've uploaded a Linux 64-bit binary to the repository as well as attached. It requires C++11 and 3 Boost libraries: filesystem, program_options, and system (they are statically linked to the binary in the repo).   https://github.com/space222/stir    
  18. beans222

    Stir, a C/C++ build tool

      Thank you for your response; those questions were quite helpful :)
  19. beans222

    (Super) Smart Pointer

    Read Buckeye's original post again. If the AI has a pointer *to the pointer* to the enemy, they can all see whether the enemy object exists/NULL or not with a single if-statement. No looping. The AI just sees a lack of enemy next time they get updated.
  20. beans222

    Terrain - map editor

    I would go height map for a terrain editor. Bullet's height map object allows for the map array to be dynamically modified. Creating a new btBvhTriangleMeshShape every time the terrain is modified may or may not be too slow, but using the height map wouldn't require quite as much Bullet-related code.   On the other hand, do you really need physics *while* the terrain is being altered/extruded/etc? You could stop physics, allow the user to extrude (terminology?) a hill, and then start simulating again after building a new btBvhTriangleMeshShape. If your editor includes placing other objects (like debris), you might need to use an invisible sphere to push away other objects before creating a new btBvhTriangleMeshShape. Or even try to detect which non-static objects would need to be moved and just warp them above the new highest point in the area and let them fall back down (the user will have to re-place them, but hey, they rose a hill there).   Disclaimer: I've never written such an editor; I use Blender (poorly).
  21. beans222

    some assembly unknowns

    If you use NASM to output a raw binary it will assume 16-bit code for a DOS .com executable.   http://www.nasm.us/doc/nasmdoc6.html
  22. Everything looks in order there. Before I didn't understand your method of going rootnode down but still giving out final transforms on the way; wouldn't have thought of that.   How about how the final array is generated for the shader (bone_matrix) ?
  23. The offset matrix should only be multiplied with the final transform for the bone's node (after all parent nodes have been multiplied in).
  24. Can you post the code that builds the bone array?
  25. You should use ApochPiQ's suggestion of a vector of pointers. Removal of one in the middle becomes invalidating the pointer (whether unique_ptr's reset or a raw null). Adding a new one then requires traversing the array to see if any slots can be reassigned without push_back (which might reallocate and copy, but still better than copying an entire array of large objects).   std::vector::erase literally removes the element, copying everything else down a slot. To use a vector of objects like the pointer version, you'd need a way to mark a Player object as invalid so you can search for an available id in the middle of the list before using push_back to add to the end.
  • 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!