DirectX 11 Rendering Object Inside out - c++

I am having alot of struggles trying to follow Frank Luna's book for DirectX 11 3D Programming, and I am currently up to chapter 7 section 2. I have imported the Skull model file and I have begun to render it. The strange thing is that when I am rendering it, it appears to be rendering the back faces over the front facing faces. I am pretty sure this is the case of what is happening. But I am putting forth this question for help and guidance on where I may be going wrong. I will edit this post with inclusions of my code if required to help me figure out where I am going wrong, Thanks alot! (photo's attached)
Photo - Facing the Skull, Slightly to the Left
Photo - Above the Skull, Facing Downwards
EDIT: I have set a breakpoint in my code for after the first draw call loop and it does not show any faces which are behind the fronts ones, so issue is solved at this frame, but when I continue to the next frame, this is when the problems start.

These kinds of problems are sometimes related to the setup of the CullMode in the D3D11_RASTERIZER_DESC. Try changing from D3D11_CULL_BACK to D3D11_CULL_FRONT or vice versa. Also have a look at the FrontCounterClockwise option of the D3D11_RASTERIZER_DESC.

I figured out what had been causing my grief. I have been using DirectXToolKits SpriteFont and SpriteBatch class's to use the function DrawString to display an FPS counter at the top left corner of the screen, and it must have been messing around with the ID3D11DeviceContext::DrawIndexed calls. Thankyou for all your input and brainstorming!!

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.

Texture is not Loading Properly

I'm making kind of a graphic engine using OpenGL, but I am having a bit of a problem, the texture is not loading properly, it loads like this:
While it should load the picture of the "heart" square fully as a square, but some of it is gone, and it kinda vibrates whenever the frames change, I realized if I remove the frames (on screen), it wouldn't get that problem.
Like, what is wrong with that thing?
EDIT: it appears that the problem is caused by shaders on AMD GPUs, I dunnu why and if someone knows what could be causing the problem by that please tell me, also I have a long code don't really know which is causing the problem...
and I tried a different method: I rendered the label on a different layer and it worked :/

Direct3d world to screen

I'm new in direct3d and i got a newbie question.
I got a point in the world and the location of the camera. I would like to know where i will see the point on my screen. I know the width/height of my screen, the field of view of the camera and everything else. I think that there will be function that do that and i don't need to calculate my self.
I searched a lot and couldn't find it, how do i do that?
The only thing i found is: http://msdn.microsoft.com/en-us/library/bb205516%28VS.85%29.aspx but i didn't understand what to give to him (im new in direct3d as i said)
Thank you for your help
First of all, Direct3D is not a solution to world to screen transformation, it is an API that lets you use the GPU to solve that problem faster on the GPU, but if you don't know, how to do it without Direct3D, then Direct3D will probably of no help. So you have to learn the linear Algebra, and the Rendering Pipeline (which is already documented in a lot of places).

When is the right time to draw?

I just finished essential part of my own personal 2D engine in C++ and I'm kinda deciding how to complete the part where it is actually supposed to display everything on the screen, namely when do I call that function which does the job.
I don't have much idea of how does the graphic card work, my biggest experience is calling bios graphic services to write some stuff on the screen. Could you give me a hint on this please? Or maybe some keywords I should try to google?
look up render loop.
In a game, you will do it in a loop. You can also look up game loop which is a related concept if you're working on a game.
Are you rendering to a back buffer and then trying to display that? Common terminology includes "flip" (as in page flipping) or "present". If your copying from a back buffer to the screen, it might also be a "blit" (or blt) from "bit-block transfer".

Strange error with hardware picking in directx

i am trying to get pickigng working in directx 9 and i am having some trouble. it works fine when i am rendering my mesh in software however i do get errors when rendering with a shader.
i can be off of a mesh but it still detects it as a hit (see image for more detail)
i am stopping animation controllers and updating frame matrices but still no joy with the picking.
http://tweetphoto.com/a7vtajzt
any help much apprechiated this has been driving me nuts for two days now.
regards
Mark
not to worry i found out that i was missing a clone function that i was doing in software mode but not hardware