I get the concept (Or I think I do) but I still have couple of question on the technical side of unique_ptr.
1. When you declare a unique_ptr as a class variable, you don't have to delete it in the destructor because it is not on the heap so when the class instance is deleted, the unique_ptr is deleted which trigger the real pointer delete?
2. How do you pass unique_ptr to other functions. Do you pass a ref to the unique_ptr object? Or do you pass uniqueptr.get() (Which sends the pointer to the real object)? Do you do the same if you send it to an internal method than to another class method? I personally pass the pointer as const, leaving the unique_ptr hidden. I'm wondering here what are the best practices.
3. What is the point of a unique_ptr as a class variable? I mean since the pointer has to dies when the owning instance is kill, all you have to do is to put it in the destructor. I understand that shared_ptr are more complicated since many object can own them which make the delete call tricky, but in the case of the unique_ptr, it's pretty straightforward.
4. What are the best practices regarding unique_ptr and passing the pointer to the object is hold to another class which stores it in a class variable. Is that a good practice first? The unique_ptr could be deleted and the pointer copy it hold in the other class would be invalid. Are unique_ptr meant to be pass around like that? Should i use shared_ptr in that case we're talking? So if another class stores it in a class variable the pointer would be deleted when only all the instances of these 2 classes would be deleted. Also how can you predict such cases if the good answer is to use shared_ptr. How can I plan that other people that might use my class could store my pointer internally.
I'm uncertain about how Shaders are "tied" to the game.
Let's say I have a Specular lighting Shader. It probably have lightsource's parameters. (Direction, intensity, etc). It does it's calculation and the graphic card use that to draw on the screen. This part is fine for me (At least if I'm not mistaken). But how is the Shader aware of the lightsource? I need to pass this information when I render with this Shader? Who check if the lightsource is blocked by another object before it reach my rendering object? Is it my scene renderer that need to make a check before it send the lightsource to the Shader?
Also is it possible that your Shader communicate with your game/other shader? In the case of a high reflectance surface could your Shader "re-emit" light that will be taken in consideration when rendering other objects?
Currently working on a "Platformer" type game on Windows phone 7. I'm having problem with the "Input" part of the development. For the phone the game will feature a Virtual (Transparent) buttons directly on the game screen (Kinda like the Shooter on Mobiles).
But what I'd like to do at the moment is to use my keyboard to make the input for the development time because it will be easier. I cannot touch 2 spot on my Windows phone emulator using the mouse (Moving right and jump for exemple).
My problem is that the keyboard input doesn't seems to be working in Windows Phone emulator. Is it possible to make it work? Or am I trying something I shouldn't? Maybe I should develop the game on a "Windows" platform and migrate when things are getting ready? Or is it possible to do what I want?
It's Windows Phone 7.1 and using the emulator provided in VS.
I'm currently trying to learn 3D programming for XNA with various tutorials I found. So far so good, but I have couple of question regarding the HLSL flow in a XNA game (Might be the same for non-xna game, I don't know).
In one of the tutorial I read, the person explain how to create a specular lighting. I understand the concept but when trying to think on a larger scale (Like a real game case), I have trouble to see how it will be integraded. Let's make a scenario here :
I have a scene with 2 cube and one light source. I put two cube in a straight line, and place the lightsoure so only the first cube has light on it and place my camera just behind the lightsource. How do the HLSL shader knows that it musn't do the lighting on the second cube because the first one is blocking the light? Do I have to manage that in the game code and apply the effect on the model to draw based on the light position? If so, how do I manage the case that the cude are not correctly aligned and part of the light would show up on the second cube?