So, my simple (not actually simple) goal is to create a junky pong game. I'm not really interested in a third dimension (3d) yet, but I was questioning whether or not to bother with ortho view or not. Can't I just set my Z axis to 0 at all times for all my objects? Viola, effectively 2d yes?
I've followed some basic tutorials on DirectX at DirectXProgrmaming.com, and I've come up with a basic Renderer class that manages the 3d stuff.
Code:
#ifndef RENDERER_H
#define RENDERER_H
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dx10.h>
#include "Vertex.h"
// include the Direct3D Library file
#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "d3dx11.lib")
#pragma comment (lib, "d3dx10.lib")
// define the screen resolution
#define SCREEN_WIDTH 1920
#define SCREEN_HEIGHT 1080
class Renderer
{
public:
Renderer(HWND hWnd);
~Renderer();
// function prototypes
void Update();
private:
IDXGISwapChain * swapchain; // the pointer to the swap chain interface
ID3D11Device *dev; // the pointer to our Direct3D device interface
ID3D11DeviceContext *devcon; // the pointer to our Direct3D device context
ID3D11RenderTargetView *backbuffer; // the pointer to our Direct3D backbuffer
ID3D11VertexShader *pVS; // the vertex shader
ID3D11PixelShader *pPS; // the pixel shader
ID3D11Buffer *pVBuffer; // the vertex buffer
ID3D11InputLayout *pLayout; // the input layout
void InitD3D(HWND hWnd); // sets up and initializes Direct3D
void InitPipeline(void);
void InitGraphics(void);
};
#endif
So, some questions on Ortho/2d... First off, I think the only reason I am tempted to do 2d in a 3d environment is because I already have a 3d environment set up via tutorials, and I don't have a 2d environment set up, and I'm really not sure how do go about doing that.
I saw a tutorial here: http://rastertek.com/dx11tut11.html
But honestly, before I get too deep into that, I wanted to ask you all if...
1. Is there a better tutorial out there?
2. Is there something a little more basic, I mean, to help me understand what the heck ortho is in relation to the following things:
A. vertex buffer
B. Pixel Buffer
C. Device Context
D. Rendering Pipeline
E. Other graphics lingo I'm not super familiar with
What I'm really asking, is does all the ortho setup happen here or, in my other initialization steps?
Code:
void Renderer::Update(void)
{
// clear the back buffer to a deep blue
devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f));
// select which vertex buffer to display
UINT stride = sizeof(Vertex);
UINT offset = 0;
devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset);
// select which primtive type we are using
devcon->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
// draw the vertex buffer to the back buffer
devcon->Draw(3, 0);
// switch the back buffer and the front buffer
swapchain->Present(0, 0);
}
Thanks, feel free to educate me .