Package d3d11

Examples of d3d11.D3D11


            immediateContext.VSSetShader(pointerTo(vs), null, 0);
            immediateContext.PSSetShader(pointerTo(ps), null, 0);
           
            // Update rotation matrix for triangle
            D3DXMatrixRotationZ(pointerTo(mat), angle.addAndGet(1) * 0.01f);
            D3D11_MAPPED_SUBRESOURCE mappedData = immediateContext.Map(constBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0);
            pointerTo(mat).copyTo(mappedData.pData());
            immediateContext.Unmap(constBuffer, 0);
            immediateContext.VSSetConstantBuffers(0, 1, pointerToPointer(pointerTo(constBuffer)));
           
            // Set primitive topology and draw
            immediateContext.IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
View Full Code Here


  public final void IASetInputLayout(ID3D11InputLayout layout) {
    IASetInputLayout(pointerTo(layout));
  }
 
  public final D3D11_MAPPED_SUBRESOURCE Map(ID3D11Resource resource, int subResource, ValuedEnum<D3D11_MAP> MapType, int MapFlags) {
    D3D11_MAPPED_SUBRESOURCE mappedData = new D3D11_MAPPED_SUBRESOURCE();
//    try {
      int result = Map(pointerTo(resource), subResource, MapType, MapFlags, pointerTo(mappedData));
      if(result != 0) {
        throw new D3D11Exception("Could not map resource", result);
      }
View Full Code Here

    D3D11_BUFFER_DESC bufferDesc = new D3D11_BUFFER_DESC(D3D11_BIND_VERTEX_BUFFER,
                               D3D11_USAGE_DEFAULT,
                               D3D11_CPU_ACCESS_NONE,
                               0,
                               (int)(9 * sizeOf(Float.class)));
    D3D11_SUBRESOURCE_DATA initData = new D3D11_SUBRESOURCE_DATA();
    initData.pSysMem(pointerToFloats(0.0f, 1.0f, 0.5f, 1f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f));
    initData.SysMemPitch(0).SysMemSlicePitch(0);
    final ID3D11Buffer vertexBuffer = device.CreateBuffer(bufferDesc, initData);
    delete(initData)// Delete data of regain memory
   
    // Create constant buffer (size must be multiple of 16)
    bufferDesc.BindFlags(D3D11_BIND_CONSTANT_BUFFER);
View Full Code Here

    D3D11_BUFFER_DESC bufferDesc = new D3D11_BUFFER_DESC(D3D11_BIND_VERTEX_BUFFER,
                               D3D11_USAGE_DEFAULT,
                               D3D11_CPU_ACCESS_NONE,
                               0,
                               (int)(9 * sizeOf(Float.class)));
    D3D11_SUBRESOURCE_DATA initData = new D3D11_SUBRESOURCE_DATA();
    initData.pSysMem(pointerToFloats(0.0f, 1.0f, 0.5f, 1f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f));
    initData.SysMemPitch(0).SysMemSlicePitch(0);
    final ID3D11Buffer vertexBuffer = device.CreateBuffer(bufferDesc, initData);
   
    JNIEnv env = JAWTUtils.getJNIEnv();
    JAWT jawt = JAWTUtils.getJAWT(env);
    while(frame.isEnabled()) {
View Full Code Here

                               0,
                               (int)(9 * sizeOf(Float.class)));
    D3D11_SUBRESOURCE_DATA initData = new D3D11_SUBRESOURCE_DATA();
    initData.pSysMem(pointerToFloats(0.0f, 1.0f, 0.5f, 1f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f));
    initData.SysMemPitch(0).SysMemSlicePitch(0);
    final ID3D11Buffer vertexBuffer = device.CreateBuffer(bufferDesc, initData);
    delete(initData)// Delete data of regain memory
   
    // Create constant buffer (size must be multiple of 16)
    bufferDesc.BindFlags(D3D11_BIND_CONSTANT_BUFFER);
    bufferDesc.Usage(D3D11_USAGE_DYNAMIC);
    bufferDesc.CPUAccessFlags(D3D11_CPU_ACCESS_WRITE);
    bufferDesc.ByteWidth((int) sizeOf(D3DXMATRIX.class));
    final ID3D11Buffer constBuffer = device.CreateBuffer(bufferDesc, null);
   
    final AtomicInteger angle = new AtomicInteger(0);
    final D3DXMATRIX mat = new D3DXMATRIX();
    D3DXMatrixIdentity(pointerTo(mat));
   
View Full Code Here

                               0,
                               (int)(9 * sizeOf(Float.class)));
    D3D11_SUBRESOURCE_DATA initData = new D3D11_SUBRESOURCE_DATA();
    initData.pSysMem(pointerToFloats(0.0f, 1.0f, 0.5f, 1f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f));
    initData.SysMemPitch(0).SysMemSlicePitch(0);
    final ID3D11Buffer vertexBuffer = device.CreateBuffer(bufferDesc, initData);
   
    JNIEnv env = JAWTUtils.getJNIEnv();
    JAWT jawt = JAWTUtils.getJAWT(env);
    while(frame.isEnabled()) {

      if(frame.isVisible())
        JAWTUtils.withLockedSurface(env, jawt, frame, new LockedComponentRunnable() {
          @Override
          public void run(Component comp, long peer) {
            immediateContext.ClearRenderTargetView(pointerTo(rtView), pointerToFloats(0.0f, 0.125f, 0.3f, 1.0f));
           
            int stride = (int) (sizeOf(Float.class) * 3);
            immediateContext.IASetVertexBuffers(0, 1, pointerToPointer(pointerTo(vertexBuffer)), pointerToInt(stride), pointerToInt(0));
           
            immediateContext.IASetInputLayout(layout);
            immediateContext.VSSetShader(pointerTo(vs), null, 0);
            immediateContext.PSSetShader(pointerTo(ps), null, 0);
           
            immediateContext.IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
            immediateContext.Draw(3, 0);
           
            swapChain.Present(0, 0);
          }
        });
   
      try {
        Thread.sleep(5);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
   
    vs.Release();
    ps.Release();
    layout.Release();
    vertexBuffer.Release();
    swapChain.Release();
    device.Release();
  }
View Full Code Here

   
    final IDXGISwapChain swapChain = dxgiFactory.CreateSwapChain(dxgiDevice, DXGI.SwapChainDescription(frame));
    dxgiDevice.Release();
    dxgiFactory.Release();
   
    ID3D11Texture2D backBuffer = swapChain.GetBuffer(0, ID3D11Texture2D.class);
    final ID3D11RenderTargetView rtView = device.CreateRenderTargetView(backBuffer, null);
    backBuffer.Release();

    immediateContext.OMSetRenderTargets(rtView, null);
    immediateContext.RSSetViewport(new D3D11_VIEWPORT(frame.getWidth(), frame.getHeight()));
   
    // Shader
View Full Code Here

       
    final IDXGISwapChain swapChain = DXGIFactory.CreateSwapChain(DXGIDevice, desc);
    DXGIDevice.Release();
   
    // Get back buffer
    ID3D11Texture2D backBuffer = swapChain.GetBuffer(0, ID3D11Texture2D.class);
   
    // Create render target view
    final ID3D11RenderTargetView rtView = device.CreateRenderTargetView(backBuffer, null);
   
    // Set render target
    Pointer<Pointer<ID3D11RenderTargetView>> ppRTV = allocatePointer(ID3D11RenderTargetView.class);
    ppRTV.set(pointerTo(rtView));
    immediateContext.OMSetRenderTargets(1, ppRTV, null);
    ppRTV.release();
   
    // Set viewport
    D3D11_VIEWPORT vp = new D3D11_VIEWPORT();
    vp.Width(800).Height(600).MinDepth(0).MaxDepth(1).TopLeftX(0).TopLeftY(0);
    immediateContext.RSSetViewports(1, pointerTo(vp));
   
    // Clear screen with some color
    final Pointer<Float> pColor = allocateFloats(4).setFloats(new float[] {0.7f, 0.8f, 0.3f, 1.0f});
   
    JNIEnv env = JAWTUtils.getJNIEnv();
    JAWT jawt = JAWTUtils.getJAWT(env);
    while(frame.isEnabled()) {

      JAWTUtils.withLockedSurface(env, jawt, frame, new JAWTUtils.LockedComponentRunnable() {
       
        @Override
        public void run(Component arg0, long arg1) {
          // TODO Auto-generated method stub
          immediateContext.ClearRenderTargetView(pointerTo(rtView), pColor);
          // Present screen
          swapChain.Present(0, 0);
          //frame.repaint();
        }
      });
    }
   
    // Wait to see results
    //Thread.sleep(5000);

    // Release Swap chain and Factory
    rtView.Release();
    backBuffer.Release();   
    swapChain.Release();
    DXGIFactory.Release();
   
    // Dispose JFrame
    frame.dispose();
View Full Code Here

   
    final IDXGISwapChain swapChain = dxgiFactory.CreateSwapChain(dxgiDevice, DXGI.SwapChainDescription(frame));
    dxgiDevice.Release();
    dxgiFactory.Release();
   
    ID3D11Texture2D backBuffer = swapChain.GetBuffer(0, ID3D11Texture2D.class);
    final ID3D11RenderTargetView rtView = device.CreateRenderTargetView(backBuffer, null);
    backBuffer.Release();

    immediateContext.OMSetRenderTargets(rtView, null);
    immediateContext.RSSetViewport(new D3D11_VIEWPORT(frame.getWidth(), frame.getHeight()));
   
    // Shader
View Full Code Here

    final IDXGISwapChain swapChain = dxgiFactory.CreateSwapChain(dxgiDevice, DXGI.SwapChainDescription(frame));
    dxgiDevice.Release();
    dxgiFactory.Release();
   
    ID3D11Texture2D backBuffer = swapChain.GetBuffer(0, ID3D11Texture2D.class);
    final ID3D11RenderTargetView rtView = device.CreateRenderTargetView(backBuffer, null);
    backBuffer.Release();

    immediateContext.OMSetRenderTargets(rtView, null);
    immediateContext.RSSetViewport(new D3D11_VIEWPORT(frame.getWidth(), frame.getHeight()));
   
View Full Code Here

TOP

Related Classes of d3d11.D3D11

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.