windows 8 - (C++/DirectX11) Something wrong in ID3D11DeviceContext::Draw() (or in my head) -


using directx sdk included windows8 sdk. compile success, program stops in 1 place. debugging showed error in function:

    //id3d11devicecontext* devicecontext     //idxgiswapchain* swapchain     //const float background[4] = {0.0f, 0.0f, 0.0f, 0.0f};         void drawscene(){             devicecontext->clearrendertargetview(rendertargetview, backgroung);              devicecontext->draw(3, 0); //<-this              swapchain->present(0, 0);         } 

while commenting function goes ok. think have problems in functions:

bool initscene(){      hr = d3dcompilefromfile(l"effects.fx", 0, 0, "vs", "vs_4_0", null, null, &vsbuffer, null);     hr = d3dcompilefromfile(l"effects.fx", 0, 0, "ps", "ps_4_0", null, null, &psbuffer, null);      hr = device->createvertexshader(vsbuffer->getbufferpointer(), vsbuffer->getbuffersize(), null, &vs);     hr = device->createpixelshader(psbuffer->getbufferpointer(), psbuffer->getbuffersize(), null, &ps);      vertex v[] = {         vertex(0.0f, 0.5f, 0.5f),         vertex(0.5f, -0.5f, 0.5f),         vertex(-0.5f, -0.5f, 0.5f),     };      d3d11_buffer_desc vertexbufferdesc;     zeromemory(&vertexbufferdesc, sizeof(&vertexbufferdesc));      vertexbufferdesc.usage = d3d11_usage_default;     vertexbufferdesc.bytewidth = sizeof(vertex) * 3;     vertexbufferdesc.bindflags = d3d11_bind_vertex_buffer;     vertexbufferdesc.cpuaccessflags = 0;     vertexbufferdesc.miscflags = 0;      d3d11_subresource_data vertexbufferdata;     zeromemory(&vertexbufferdata, sizeof(vertexbufferdata));     vertexbufferdata.psysmem = v;      hr = device->createbuffer(&vertexbufferdesc, &vertexbufferdata, &trianglevertexbuffer);      uint stride = sizeof(vertex);     uint offset  = 0;      devicecontext->iasetvertexbuffers(0, 0, &trianglevertexbuffer, &stride, &offset);      hr = device->createinputlayout(layout, numelements, vsbuffer->getbufferpointer(), vsbuffer->getbuffersize(), &vertlayout);      devicecontext->iasetinputlayout(vertlayout);     devicecontext->iasetprimitivetopology(d3d11_primitive_topology_trianglelist);      d3d11_viewport viewport;     zeromemory(&viewport, sizeof(d3d11_viewport));     viewport.topleftx = 0;     viewport.toplefty = 0;     viewport.height = height;     viewport.width = width;      devicecontext->rssetviewports(1, &viewport);      return true; } 

or here:

bool init3d(){     dxgi_mode_desc bufferdesc;      zeromemory(&bufferdesc, sizeof(dxgi_mode_desc));      bufferdesc.width = width;     bufferdesc.height = height;     bufferdesc.refreshrate.numerator = 60;     bufferdesc.refreshrate.denominator = 1;     bufferdesc.format = dxgi_format_r8g8b8a8_unorm;     bufferdesc.scanlineordering = dxgi_mode_scanline_order_unspecified;     bufferdesc.scaling = dxgi_mode_scaling_unspecified;      dxgi_swap_chain_desc swapchaindesc;      zeromemory(&swapchaindesc, sizeof(dxgi_swap_chain_desc));      swapchaindesc.bufferdesc = bufferdesc;     swapchaindesc.sampledesc.count = 1;     swapchaindesc.sampledesc.quality = 0;     swapchaindesc.bufferusage = dxgi_usage_render_target_output;     swapchaindesc.buffercount = 1;     swapchaindesc.outputwindow = hwnd;     swapchaindesc.windowed = true;     swapchaindesc.swapeffect = dxgi_swap_effect_discard;      hr = d3d11createdeviceandswapchain(         null,         d3d_driver_type_hardware,         null,         null,         null,         null,         d3d11_sdk_version,         &swapchaindesc,         &swapchain,         &device,         null,         &devicecontext);      id3d11texture2d *backbuffer;     hr = swapchain->getbuffer(0, __uuidof(id3d11texture2d), (void**)&backbuffer);      hr = device->createrendertargetview(backbuffer, null, &rendertargetview);     backbuffer->release();      devicecontext->omsetrendertargets(1, &rendertargetview, null);      return true;  } 

i'm perfect lamer , can't understand what's going wrong. me please.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -