Jump to content

  • Log In with Google      Sign In   
  • Create Account

Wilhelm van Huyssteen

Member Since 22 Mar 2008
Offline Last Active Yesterday, 01:34 PM

Posts I've Made

In Topic: You, according to the internet.

18 August 2014 - 06:09 AM

I'm obese and I absolutely love Forex trading. I also fancy Russian women.

In Topic: Directx 11 constant buffer question

12 August 2014 - 01:41 AM

Ah i see. Thnx a lot. I was able to adjust how I pack the variables and the issue is resolved.

In Topic: Directx 11 constant buffer question

11 August 2014 - 02:09 PM

Ok. I am busy writing a java directx wrapper in c++ to add directx support to my java game engine which only supported opengl up til now. C++ is also completely new to me same as directx so i might be making silly mistakes. I didnt know that constant buffers were futher split into registers.


Here is the relevant c++ code that creates and updates constant buffers. when updating A constant buffer I basically just point to a raw array of bytes. I handle the layout of that byte array java side only.


ID3D11Buffer*           g_pConstantBuffer[14];
JNIEXPORT void JNICALL Java_dmdx_DmdxNative_createConstantBuffer(JNIEnv* env, jobject, jint slot, jint size)
  ZeroMemory(&bd, sizeof(bd));
  bd.Usage = D3D11_USAGE_DEFAULT;
  bd.ByteWidth = size;
  bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
  bd.CPUAccessFlags = 0;
  HRESULT hr = g_pd3dDevice->CreateBuffer(&bd, nullptr, &g_pConstantBuffer[slot]);
  if (FAILED(hr))
    printf("c++ error 8");
  g_pImmediateContext->VSSetConstantBuffers(slot, 1, &g_pConstantBuffer[slot]);
  g_pImmediateContext->PSSetConstantBuffers(slot, 1, &g_pConstantBuffer[slot]);

JNIEXPORT void JNICALL Java_dmdx_DmdxNative_updateConstantBuffer(JNIEnv *env, jobject, jint slot,jobject data)
  g_pImmediateContext->UpdateSubresource(g_pConstantBuffer[slot], 0, nullptr, env->GetDirectBufferAddress(data), 0, 0);


EDIT: ok so you said everything is stored in 16 byte (4 float right?) registers. By that Im thinking im just building up that array incorrectly. When i changed al my float3's to float 4's it started working perfectly. Then i thought i should simply pad my float3's with 4 bytes at the end so they fit into 16 bytes instead but that doesnt seem to work.

In Topic: OpenGL to DirectX. Constant buffers.

01 July 2014 - 02:51 AM

Yes i stil use some pretty old opengl I supose I will first refactor my existing code into using uniform buffer objects before continueing with the directX implementation.



In Topic: GPU based heightmap editor

12 June 2014 - 02:37 AM



Ive gone through a similiar process with my editor (see video here http://www.gamedev.net/blog/807/entry-2259360-strife-world-editor/). It used to be CPU based but the framerate became so low it was pretty unusable to do continues drawing. I use a grayscale image next to the terrain display to draw on because it seemed better at the time. However for painting textures or placing models onto the terrain i use picking to get the coordinates under the cursor. I use two 24 bit textures. one for x and one for y. i treat the 24bit's (RGB8) as one number so i can go from 0 to 16777216. wich is overkil but only going from 0.0 to 1.0 (wich is 0-255 when using 8 bit textures is way to little if you have a big heightmap).