Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by SamiHuutoniemi

  1. SamiHuutoniemi

    Draw HUD

    Hello! I'm drawing my FPS as a sprite, and I want to have it drawn to the screen independetly of the camera position. For example, always in the lower left corner. I'm using an orthographic projection and I always have the z value of the sprite greater than the camera, and it always seems to draw it the same distance away from the camera. So far, so good. But if I move the camera in the x or y directions, the sprite moves in those directions too. Do I need a separate viewport? Any other ideas?
  2. SamiHuutoniemi

    Direct 2D for game Programming

    I'll give you a great hint: http://lmgtfy.com/?q=direct2d Then check out the first link!
  3. SamiHuutoniemi

    Shadows from point lights

    Ok, thanks! Will look into this!
  4. Hello! I'm doing some shadowmapping and was wondering about how it is done with point lights (instead of spot lights). Since you don't really have a light direction, how do decide what the shadowmap should cover? Anybody have experience in this field?
  5. SamiHuutoniemi

    Shadows from point lights

    The cube version sounds very much easier. Does it still use perspective projection?
  6. SamiHuutoniemi

    Does my shader code look alright?

    Why would you want to return both texture color and the "other" color from the pixel shader? Don't you want to either blend them in the shader, or somewhere before this point decide what color you want to output?
  7. Hello! Was just wondering about how shaders know which cbuffer maps to what I send in to the shader from the C++ code. Say I have three equally sized cbuffers in a shader. Then I obviously make three calls to V/PSSetConstantBuffers. How does it know which cbuffer to put what in?
  8. SamiHuutoniemi

    Read/Write binary

    Never mind. I solved it. Sinces vertices was already a pointer, I shouldnt have used "vertices" instead of "&vertices". /Facedesk EDIT: I see you solved it too! Thanks for the help. Sometimes one just feels really stupid. And I blame my copy/paste!
  9. SamiHuutoniemi

    Read/Write binary

    Hello! Instead of reading a model from a huge obj-file (21 mb) I made a simple binary format which i wrote data to. But when I try to read it I get problems. It happens when I want to read an array of vertices. I get an access violation on the read line. [source lang="cpp"]vertices = new TextureVertex[numVertices]; buffer.read((char*) &vertices, sizeof(TextureVertex) * numVertices);[/source] The value of numVertices is 10920, and the data IS in the stream I read from. Is it possible that the memory that is allocated to vertices is not sequential? If it isnt, how do I force it to be? Is it something else? (The data is read from an object which also has a "TextureVertex* vertices" of the same length.
  10. SamiHuutoniemi

    Caustics - simple questions

    Okay! Thanks both Luca and Bacterius! So are you saying that if I have a completely planar bottom surface, I would have to tesselate it into pretty (very) small triangles to get a nice effect?
  11. SamiHuutoniemi

    Caustics - simple questions

    Hey! When discussing caustics, what exactly are caustic volumes and caustic triangles? Caustics is the effect of light being bent by a surface and then somehow being absorbed by another surface. If we talk water volumes (like an ocean), is the caustic volume the full water volume, and the triangle some arbitrary triangle at the floor? Cause I'm really confused about the terminology!
  12. SamiHuutoniemi

    Caustics - simple questions

    For example: http://graphics.ucsd.edu/~henrik/papers/interactive_caustics/interactive_caustics.pdf
  13. SamiHuutoniemi

    Problem drawing in directx

    What version of DirectX? Is it an ortographic projection? Some code? =)
  14. SamiHuutoniemi

    Try to write a Game engine

    You might want to state some of the questions here, and you might get some help...
  15. Short question: If I am in clip space (unless I've misunderstood, that's where I am after multiplying with the WorldViewProjection matrix), should I not be able to get the z-coordinate of any one pixel from the gl_FragCoord.z value?
  16. SamiHuutoniemi

    Z-coordinate in clip space (GLSL)

    So the gl_FragCoord.xy coordinates are screen coordinates? And by depth coordinate, may I assume you mean gl_FragCoord.z?
  17. Hello! So if I in DirectX 11 want to create a sprite from an image file, comprising of a number of sprites - is this the way to go? 1) Create a temporary texture from the file. (i.e. D3DX11CreateTextureFromFile) 2) Somehow create a blank texture 3) Copy a region of the temporary texture to the blank one (i.e. CopySubresourceRegion) 4) Create a shader resource view from the no longer blank texture (i.e. CreateShaderResourceView) Or how would you do it? (If like this - how do I in the simplest way create a blank texture?) Thanks!
  18. SamiHuutoniemi

    Create sprites from tilesets

    I'm not exactly sure what you mean with the first part. I dont want to create a file. I want to create a blank texture onto which i can copy a subregion of a bigger texture. Can this be done? =) And yes. I would think that the it's very possible to use the second method. However, I'd prefer to save only the relevant texture data in any one sprite object, and thus not the whole original tileset and rectangle data. But if I must do this, how do I render part of a shader resource view? Right now I pretty much just plug it into the pixelshader and then draw. Any hints?
  19. Hello! I have a problem with Boost threads. The program is a "for fun" program that draws the Mandelbrot set in DirectX 11. I want to use threads to be able to make use of a progress bar (or circle in this case), as it takes around 30-40 seconds to calculate the image at full HD on this computer. To calculate the image, I have a Mandelbrot class with a method "Calculate", which fires up 4 threads that split the calculation into 4 parts of the image. If I just instantiate an object of the Mandelbrot class, and call the Calculate-method, all works. However, I cannot use the progress circle this way. To do that, I want to fire up another thread, which has the Calculate method as starting point, and let the main thread go on with the progress circle business. This works sometimes, but most of the time, the application crashes and burns. Badly. Seems random when it crashes as well. Anybody have boost experience, perhaps in combination with DirectX 11? I think I'm correct in that device context calls are not threadsafe, why I have arranged for a mutex to lock every time the device context is used. This should not be needed for the Direct3D Device, right? If it crashes (which is most of the times I run it), only two of the calculate-threads terminate. The other two + the "CalcThread" do not finish. Any ideas? Some code. Dont worry about the making of progress circle objects. It's extremely inefficient. I know. But it should have nothing to do with the issue. [source lang="cpp"]void MandelbrotMain::InitializeObjects() { Shader* unlitTextureShader = new Shader(d3dEngine, UNLIT_TEXTURESHADER); unlitTextureShader->Initialize(); shaders["UNLIT_TEXTURESHADER"] = unlitTextureShader; pMandelbrot = new Mandelbrot(d3dEngine, shaders["UNLIT_TEXTURESHADER"]); //pMandelbrot->Calculate(); boost::thread* t1 = new boost::thread(boost::bind(&Mandelbrot::Calculate, pMandelbrot)); OutputDebugString(L"CalcThread starting: "); OutputDebugStringA(ToString(t1->get_id()).c_str()); } void MandelbrotMain::GameLoop() { MSG msg; while (true) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { break; } TranslateMessage(&msg); DispatchMessage(&msg); } else { /* RENDER THE SCENE */ d3dEngine->BeginScene(XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f)); Sprite* pSprite; if (pMandelbrot->GetDone()) { pSprite = pMandelbrot->GetSprite(); pSprite->ResetTransforms(); pSprite->Scale(700.0f, 400.0f, 1.0f); pSprite->Render(); } else { if (pProgress) { delete pProgress; pProgress = 0; } pProgress = new Progress(d3dEngine, shaders["UNLIT_TEXTURESHADER"], pMandelbrot->GetPercentDone()); pSprite = pProgress->GetSprite(); pSprite->ResetTransforms(); pSprite->Scale(100.0f, 100.0f, 1.0f); if (!pMandelbrot->GetDone()) { pSprite->Render(); } } if (pProgress) { delete pProgress; pProgress = 0; } d3dEngine->EndScene(); /* END OF RENDERING */ } } } [/source] [source lang="cpp"]void Mandelbrot::Calculate() { boost::thread t1(boost::bind(&Mandelbrot::CalculateMandelbrotRange, this, _1, _2), -1.0f, -0.50000001f); OutputDebugString(L"\nThread 1 starting: "); OutputDebugStringA(ToString(t1.get_id()).c_str()); boost::thread t2(boost::bind(&Mandelbrot::CalculateMandelbrotRange, this, _1, _2), -0.5f, -0.00000001f); OutputDebugString(L"\nThread 2 starting: "); OutputDebugStringA(ToString(t2.get_id()).c_str()); boost::thread t3(boost::bind(&Mandelbrot::CalculateMandelbrotRange, this, _1, _2), 0.0f, 0.49999999f); OutputDebugString(L"\nThread 3 starting: "); OutputDebugStringA(ToString(t3.get_id()).c_str()); boost::thread t4(boost::bind(&Mandelbrot::CalculateMandelbrotRange, this, _1, _2), 0.5f, 0.99999999f); OutputDebugString(L"\nThread 4 starting: "); OutputDebugStringA(ToString(t4.get_id()).c_str()); OutputDebugString(L"\n"); t1.join(); t2.join(); t3.join(); t4.join(); pSprite = new Sprite(pD3DEngine, pShader); pSprite->Initialize(0, pixels, xw, yw, xw*16); //12 = 4 bytes per color, 3 colors (RGB), xw*12 is number of bytes per row delete [] pixels; OutputDebugString(L"Done, let's render\n"); done = true; } [/source]
  20. SamiHuutoniemi

    Boost threaded application crashes

    I get an unhandled exception. It doesnt really give me much more information that this. I have only worked on this on my laptop. On my more powerful desktop, I have run it about 10 times in a row without crashes now. Starting to think it's just as simple as an "out of memory" issue. Could it be this?
  21. Hello! I'm trying to create a 2d texture from memory data. The data is in the form of 200*200 XMFLOAT4's. I would think that this should work, but all I get is black. PIX shows that the sprite would be rendered in the right place though. Dont mind that the code has a texture array. I only use the first (and only) element. The last three parameters have the values 200, 200, 800. Any thoughts? NEVER MIND. The last parameter shouldnt be 800, but 800*4... facedesk. [source lang="cpp"]Texture::Texture(ID3D11Device* pDevice, void* data, int width, int height, int rowPitch) { pTextureArray = new ID3D11ShaderResourceView*[2]; D3D11_TEXTURE2D_DESC desc; desc.Width = width; desc.Height = height; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = D3D11_USAGE_DEFAULT; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = 0; desc.MiscFlags = 0; D3D11_SUBRESOURCE_DATA initData; initData.pSysMem = data; initData.SysMemPitch = static_cast<UINT>(rowPitch); initData.SysMemSlicePitch = width*height*4; ID3D11Texture2D* tex = 0; HRESULT hr = pDevice->CreateTexture2D(&desc, &initData, &tex); if (SUCCEEDED(hr) && tex != 0) { if (pTextureArray[0] != 0) { D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; memset(&SRVDesc, 0, sizeof(SRVDesc)); SRVDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; SRVDesc.Texture2D.MipLevels = 1; hr = pDevice->CreateShaderResourceView( tex, &SRVDesc, &pTextureArray[0]); if (FAILED(hr)) { tex->Release(); //return hr; } } } multitextured = false; }[/source]
  22. Hello! I've been looking around searching for a good tutorial or guide on how to implement deferred rendering in DirectX 11. There seems to be some open source engines that use it, but going through a whole framework isn't what I'm looking for. There also seems to be quite a lot for XNA. Is there no good guide for DirectX 11?
  23. The Sams book is a good choise in my opinion, but most beginner books will suffice. Right now, I'd go with the VS2010 IDE (sure, Dreamspark) until VS2012 is released in a bug free version.
  24. SamiHuutoniemi

    3D Game Math Books?

    Is it very OpenGL oriented, or is it perfectly fine to use with DirectX 11 too?
  25. SamiHuutoniemi

    I need a jumpstart

    I would prefer learning DirectX or OpenGL, and start making simple programs, like rendering a cube, a sphere, and so on. In effect, building a very simple game engine. That way you learn extremely much. There are great resources for learning. For example Rastertek has a lot at least for DirectX. Just google it =)
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!