You need to use brackets whenever the operator precedence dictates a different order ( * (dereference) has a lower precedence than ->).
But I wonder why you have a pointer to pointer for the device context at all. Usually you declare your DX objects as pointers, not as double pointers. Or are you confused by e.g. D3D11CreateDeviceAndSwapChain ? Note that the double pointer on the device context is a out parameter. Hmmm, a quick google search shows Java doesn't have such a thing (like the out keyword in C#). In this case you declare a pointer, but use & (address of operator)
ID3D11DeviceContext* immediateContext = NULL;
D3D11CreateDeviceAndSwapChain( ..., &immediateContext);
Also: Be more precise when having troubles: Copy the exact error message from your compiler/linker and also copy relevant code (function definition and function call in this case). Please use code tags when you do.
PS:...and beaten.
Thanks. I obviosly got confused by the pointer thing. So when I have 1 pointer in one class, I can acces the original object. When I give this pointer away as one pointer to anoother class-instance am I'm accessing the same object as in the main class ? Or do I have to give a pointer to the pointer to acces the original ?
I personally thing know I can give this pointer as one.
To the error :
1>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d10.h(608): warning C4005: 'D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS': Makro-Neudefinition
1> c:\program files (x86)\windows kits\8.1\include\shared\winerror.h(50445): Siehe vorherige Definition von 'D3D10_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS'
1>c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d10.h(609): warning C4005: 'D3D10_ERROR_FILE_NOT_FOUND': Makro-Neudefinition
1> c:\program files (x86)\windows kits\8.1\include\shared\winerror.h(50454): Siehe vorherige Definition von 'D3D10_ERROR_FILE_NOT_FOUND'
1> Code wird generiert...
1>Main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall InitD3D11::initialize(struct ID3D11Device *,struct ID3D11DeviceContext *,class Window *,struct HWND__ * *,long *,struct IDXGISwapChain *,struct ID3D11RenderTargetView *,struct ID3D11DepthStencilView *,struct ID3D11Texture2D *)" (?initialize@InitD3D11@@QAEXPAUID3D11Device@@PAUID3D11DeviceContext@@PAVWindow@@PAPAUHWND__@@PAJPAUIDXGISwapChain@@PAUID3D11RenderTargetView@@PAUID3D11DepthStencilView@@PAUID3D11Texture2D@@@Z)" in Funktion ""void __cdecl init(void)" (?init@@YAXXZ)".
1>Main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall InitD3D11::initPipeline(long *,struct ID3D11DeviceContext *,struct ID3D11Device *,struct ID3D11VertexShader *,struct ID3D11PixelShader *,struct ID3D10Blob *,struct ID3D10Blob *,struct ID3D11InputLayout *)" (?initPipeline@InitD3D11@@QAEXPAJPAUID3D11DeviceContext@@PAUID3D11Device@@PAUID3D11VertexShader@@PAUID3D11PixelShader@@PAUID3D10Blob@@5PAUID3D11InputLayout@@@Z)" in Funktion ""void __cdecl init(void)" (?init@@YAXXZ)".
1>Main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall InitD3D11::InitGraphics(long,struct ID3D11Device *,struct ID3D11DeviceContext *,class Window *,struct ID3D10Blob *,struct ID3D11InputLayout *,struct ID3D11Buffer *,struct ID3D11Buffer *,struct ID3D11ShaderResourceView *,struct ID3D11SamplerState *,struct ID3D11Buffer *,class WorldHolder *)" (?InitGraphics@InitD3D11@@QAEXJPAUID3D11Device@@PAUID3D11DeviceContext@@PAVWindow@@PAUID3D10Blob@@PAUID3D11InputLayout@@PAUID3D11Buffer@@5PAUID3D11ShaderResourceView@@PAUID3D11SamplerState@@5PAVWorldHolder@@@Z)" in Funktion ""void __cdecl init(void)" (?init@@YAXXZ)".
1>Main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall Draw::mainLoop(struct tagMSG *,bool *,struct ID3D11DeviceContext *,struct ID3D11Device *,class WorldHolder *,struct ID3D11RenderTargetView *,struct ID3D11DepthStencilView *,struct IDXGISwapChain *)" (?mainLoop@Draw@@QAEXPAUtagMSG@@PA_NPAUID3D11DeviceContext@@PAUID3D11Device@@PAVWorldHolder@@PAUID3D11RenderTargetView@@PAUID3D11DepthStencilView@@PAUIDXGISwapChain@@@Z)" in Funktion "_WinMain@16".
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_main" in Funktion "___tmainCRTStartup".
... : fatal error LNK1120: 5 nicht aufgelöste Externe
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========
... I think you can see now, why I didn't just wrote the log before instand of describing it .. It's in German.
But the main error you see is "nicht aufgelöste Externe" or the same as "nicht aufgelöste externe Verweise" what means something like "unresolved external symbols".
Code :
void somevoid()
{
draw.mainLoop(&msg, &ranCorrectly, deviceContext, device, &wHold, backbuffer, depthStencilView, swapChain);
....
( this is called in preInit(); and dont get called after mainLoop ):
directX.initialize(device, deviceContext, &wnd, &hWnd, &hResult, swapChain, backbuffer, depthStencilView, stencilImageBuffer);
directX.initPipeline(&hResult, deviceContext, device, vertexShader, pixelShader,VS, PS, inputLayout);
directX.InitGraphics(hResult, device, deviceContext, &wnd, VS, vertexLayout, vertexBuffer, indexBuffer, shaderTexture, samplerState, bPerObject, &wHold);
}
void initialize(ID3D11Device *device, ID3D11DeviceContext *deviceContext, Window *wnd, HWND *hWnd, HRESULT *hResult, IDXGISwapChain *swapChain, ID3D11RenderTargetView *backbuffer, ID3D11DepthStencilView* depthStencilView, ID3D11Texture2D* depthStencilBuffer)
{
DXGI_MODE_DESC bufferDesc;
DXGI_SWAP_CHAIN_DESC swapChainDescription;
ID3D11Texture2D *pBackBuffer;
D3D11_TEXTURE2D_DESC depthStencilDesc;
D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
D3D11_VIEWPORT viewport;
ZeroMemory(&bufferDesc, sizeof(DXGI_MODE_DESC));
bufferDesc.Width = *wnd->windowSizeX;
bufferDesc.Height = *wnd->windowSizeY;
bufferDesc.RefreshRate.Numerator = 60;
bufferDesc.RefreshRate.Denominator = 1;
bufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
ZeroMemory(&swapChainDescription, sizeof(DXGI_SWAP_CHAIN_DESC));
swapChainDescription.BufferDesc = bufferDesc;
swapChainDescription.BufferCount = 4;
swapChainDescription.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDescription.BufferDesc.Width = *wnd->windowSizeX;
swapChainDescription.BufferDesc.Height = *wnd->windowSizeY;
swapChainDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDescription.OutputWindow = *hWnd;
swapChainDescription.SampleDesc.Count = 8;
swapChainDescription.Windowed = TRUE;
swapChainDescription.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
*hResult = D3D11CreateDeviceAndSwapChain
(NULL,
D3D_DRIVER_TYPE_HARDWARE,
NULL,
D3D11_CREATE_DEVICE_DEBUG,
NULL,
NULL,
D3D11_SDK_VERSION,
&swapChainDescription,
&swapChain,
&device,
NULL,
&deviceContext);
if (FAILED(hResult))
exit(*hResult);
*hResult = swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer);
if (FAILED(hResult))
exit(*hResult);
*hResult = device->CreateRenderTargetView(pBackBuffer, NULL, &backbuffer);
if (FAILED(hResult))
exit(*hResult);
depthStencilDesc.Width = *wnd->windowSizeX;
depthStencilDesc.Height = *wnd->windowSizeY;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 8;
depthStencilDesc.SampleDesc.Quality = 0;
depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;
*hResult = device->CreateTexture2D(&depthStencilDesc, NULL, &depthStencilBuffer);
if (FAILED(hResult))
exit(*hResult);
ZeroMemory(&descDSV, sizeof(descDSV));
descDSV.Format = depthStencilDesc.Format;
descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
descDSV.Texture2D.MipSlice = 0;
*hResult = device->CreateDepthStencilView(depthStencilBuffer, NULL, &depthStencilView);
if (FAILED(hResult))
exit(*hResult);
deviceContext->OMSetRenderTargets(1, &backbuffer, depthStencilView);
ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = *wnd->windowSizeX;
viewport.Height = *wnd->windowSizeY;
viewport.MinDepth = 0.0F;
viewport.MaxDepth = 1.0F;
deviceContext->RSSetViewports(1, &viewport);
pBackBuffer->Release();
}
Please don't get shocked by the functions itself. I quickly wrote them in this quote and didn't copied them from original. But they key points are in.
There are some parts, that I know are total bullshit and are only for testing, I'll change it, when the tests are over.