OpenGL, screen doesn't update after adding Assimp 3D model [closed] - opengl

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I am using OpenGL 4.0, I have 3 things in my scene, they are-
1- VBO Plane
2- Cube maps
3- 3D models [3ds/obj]
I am using Assimp library to import 3D models, the code which I built to import models was done with the help of a tutorial on youtube from "TheCPlusPlusGuy".
Here is the issue I am facing, I can render the plane in my scene, I can render the cube maps, a.k.a. skyboxes, in my scene, I can render them together.
But When I am rendering any 3D model, be it .3ds or .obj, the screen doesn't update. Even if i resize the screen its not getting updated.
This only happens when I render a 3D model. I used flags and enabled drawing 3D models at runtime, the program runs fine until I render the models, once I render the models, the models itself do not appear on screen, but the screen again freezes.
I googled it, but no one else seems to be having an issue like this.
My primary diagnostic is because I am using VBO for planes, cubemaps, and 3D models I am having this issue.

Here's a list of suggestions:
Using VBOs is not the problem. Nor is using Assimp.
Make sure you've specified the proper number of indices and primitives in your buffer and draw calls, and that they are properly formatted. The OpenGL docs can be vague on what these numbers need to be (bytes, indices, triangles?) so make sure that's done well. The Wiki does a better job of explaining this.
Does your model actually get past the loading stage? Have you tried a very simple model?
Make sure you are only loading the model once (ie not in the rendering loop, and if so, there's a mechanism to ensure that it only loads once). Repeatedly telling your program to load a model will make it run very slowly and runs the risk of eating up all your memory.
Make sure you've translated the model properly from Assimp's data structures to your own. Check that values are being set properly. Load an OBJ and print the values you're copying - do they line up with the .obj file?
Do you have a valid OpenGL context at the time you're loading the model? Loading from Assimp doesn't require one, but going from that data structure to a VBO does.
I'm sure you've done a number of these things but I've had tricky times doing this task, too. Going through step by step will help you narrow down the problem.

I am using Assimp to import models in my editor, but Assimp is only used to read models and mesh data and the values are stored in my own model/mesh format. I assume we all do this? I have had no problems with Assimp, and I am also led to believe that skyboxes etc should be rendered after all other opaque objects so you can do a few tricks to minimize rendering time (skyboxes are to be considered as one of the furthest distant objects).
I am inclined to agree with Bartek. Assimp seems to be irrelevant to the problem you are having, and I would consider redesigning your rendering methods.

I forgot to do this after rendering the plane->
glBindVertexArray(0);
After that the program was working like a charm.

Related

Vertex buffer not clearing properly

Context
I'm a beginner in 3D graphics and I'm starting out with Vulkan, which I already know it's not recommended save it please, currently working on a university project to develop the base of a 3D computer graphics engine based on the Vulkan API.
The problem
Example of running the app to render the classic 2D triangle
Drawing a 3D mesh after having drawn the triangle
So as you can see in the images above I want to be able to:
Run the engine.
Choose an object to be drawn.
Close the window.
Choose another object to be drawn.
Open the same window back up with only the last object chosen visible.
And the way I have been doing this is by essentially cleaning up the whole swap chain and recreating it from scratch once the window is closed and a new object has been chosen. Now I'm aware this probably sounds like terrorism for any computer graphics engineer but the reason I'm doing this is because I don't know a better way, I have just finished the vulkan tutorial.
Solutions tried
I have checked that I do a vkDestroyBuffer and vkFreeMemory on the current vertex buffer before recreating it again once I choose a different object.
I have disabled depth testing entirely in case it had something to do with it, it doesn't.
Note: The code is extensive and I really don't have a clue of which part of it could be relevant to the problem, so I opted for not cluttering the question, if there is an specific part you think it might help you find the solution please request it.
Thank you for taking the time to read my question.
A comment by user369070 ended up drawing my attention to the function I use to read OBJ files which made me realize that this function wasn't cleaning a data structure I use to store the vertices of the object chosen to be drawn before passing them to the vertex buffer.
I just had to add vertices = {}; at the top of the function to solve it.

Using Qt3D for a huge topography model?

My scene currently consists of a huge topography model (Mill. Verticies). Now the scene becomes more complex and contains many smaller 3D objects. Does it make sense to switch from a QFrambufferObject (with C ++ / OpenGL) to Qt3D?
What about the speed?
Which file format (Wavefront OBJ, Stanford Triangle Format PLY, STL (STereoLithography)) is suitable? I am currently loading the data from the .hgt format into a vector array and then into the QFrambufferObject.
With Qt3D, is it possible to load only the tiles in the graphics card that are currently visible in the viewport or to delete them as soon as they leave the viewport when the camera angles change?
That's difficult to say. I assume by
Does it make sense to switch
you mean will it be fast enough. Regarding your two points:
Qt3D uses assimp internally to load models, so if that library is able to load hgt files, so should be Qt3D.
What do you mean by reload? Do they change dynamically in the model? Or do you mean re-render? There's QFrustumCullung but that seems to render the whole entity still. Do you know whether your object consists of multiple parts? Because when Qt3D loads models (i.e. whole scenes) from files I think it persists its structure. If your model is split into multiple standalone components it could be that QFrustumCulling improves rendering speed because they don't get drawn when they are not viewed.
I personally feel like Qt3D is slower compared to a hand-crafted renderer in OpenGL. But it constantly improves so if it doesn't take long to try it out maybe it's worth a shot. Also, the flexibility of Qt3D might make up for the slower rendering speed.

Highlight specific parts of a mesh c++ OpenGL

I have imported a mesh object (.obj file from blender) into openGl window (glfw) context. I am following various tutorials on 3D picking to allow me to select it. What I cannot get my head around is, how to allow sub-portions of the mesh to get highlighted when clicked at one point. For example, a car mesh in which if you click over the door, the entire door gets highlighted. Without going into game engines, because my intention is to apply this concept to 3d diagrams in an app, what is the most straightforward way to implement this.
PS -- Before someone downvotes this, I have spent hours on google trying to search for an answer so apologies if this is off-topic / unsuitable.
the mesh has some colour information in form of vertex colours or textures. To highlight part of the mesh, you need to change the colour information from vertex arrays or textures that are used. This can be expensive cpu operation to generate the required arrays and textures, but after the data is generated, blitting it to screen takes no time. The main complexity is in modifying the data structures of the mesh.

vtk Filters causing point doubling and mangling normal values

Using VTK version 5.1, I'm having some issues with some models not displaying correctly in OpenGL.
The process for getting the models into VTK is a bit roundabout, but gets there and is fairly simple. Each model is a manifold mesh comprised of only quads and tris.
Blender models->custom export format containing points, point normals, and polygons
Custom export format->Custom C++ parser->vtkPolyData
vtkPolydata->vtkTriangleFilter->vtkStripper->vtkPolyDataNormals->final product
As our final product was showing irregular and missing normals when it was rendered, I had VTK write the object to a plaintext file, which I then parsed back into Blender using python.
Initial results were that the mesh was correct and matched the original model, however, when I used the Blender "select non-manifold" option, about 15% of the model showed to be nonmanifold. A bit of reading around online suggested the "remove doubles" as a solution, which did in fact solve the issue of making the mesh closed, but the normals were still irregular.
So, I guess I'm hoping there are some additional options/functions/filters I can use to ensure the models are properly read and/or processed through the filters.
This was solved by requesting that Blender perform a triangulization of the mesh prior to the export operation.
The mangling was due to Blender performing implicit triangulization of quads, resulting in faces which were stored as 4 non-coplanar points. By forcing explicit triangulation in advance, I was able to successfully perform the export and maintain model integrity/manifold-ness. The holes that were being experienced were due to the implicit triangulation not being copied by the exporter and thus causing loss of data.

Modeling in OpenGL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to model a seashell using a bunch of polygons, for example as shown in: link text
But I am new to OpenGL. How would I get started modeling this, and what would the procedure be like?
I am assuming you are going to generate the geometry procedurally instead of "sculpting it".
What you need to do is to generate your geometry just like in the mathematics example and store your it in vertex buffer objects (VBO). There are multiple ways of doing this, but generally you will want to store you vertex information (position, normal, texture coords if any) in one buffer, and the way these vertices are grouped into faces in another (called an index array).
You can then bind these buffers and draw them with a single call to glDrawElements().
Be careful that the vertices in the faces are all in the same winding order (counter-clockwise or clockwise) and the the winding order is specified correctly to OpenGL, or you will get your shell inside out!
VBOs are supported in OpenGL 1.4 and up. In the extremely unlikely event that your target platform does not support that (update your drivers first!) you can use Vertex Arrays. They do pretty much the same thing, but are slower as they get sent over the bus every frame.
While modelling objects procedurally (i.e. generating coordinates as numbers in the code) may be OK for learning purposes, it's definitely not the thing you want to do, as it gets very impractical if you have anything more complicated than a few triangles or a cyllinder). Some people consider procedural generation an art, but you need a lot of practice to achieve nice-looking (not to mention, realistic) results with that approach.
If you want to display a more complex, realistic model, the approach is to:
create the model in a modelling tool (like the free and powerful Blender)
save it to a file in a given format,
in your program, load the object from the file to memory (either to your RAM to display using Vertex Arrays or to your GPU memory directly using a Vertex Buffer Object) and display it.
Common format (though an old an inconvenient one) is .obj (Wavefront OBJ), Blender is able to save to that and you are likely to google an OpenGL OBJ loader (or you can roll your own - untrivial, but still easy).
An alternative is to create an export script for Blender (very easy, if you know Python) and save the model as a simple binary file containing vertices, etc; then load it in your application code very easily.