• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Visje

Members
  • Content count

    21
  • Joined

  • Last visited

Community Reputation

109 Neutral

About Visje

  • Rank
    Member
  1. Thanks Erik, I just came across [url="http://www.gamedev.net/topic/583161-d3d11-creating-a-dynamic-texture/"]this[/url] topic where I found what I was looking for. I'm just trying now to convert Byte into UINT32, if you have an idea on how to do it ?
  2. Hey guys, I'm trying to do a water like effect like this one : (Processing uses a Java-Like langage) [url="http://www.openprocessing.org/sketch/43543"]http://www.openproce...rg/sketch/43543[/url] The thing is that it works by replacing the color of one pixel from the texture on the back by another one when the pointer of the mouse is moved. So my question is, do you know how I can get all the pixels from a texture and change their colors as I like (and not just a single pixel like in the Pixel Shader) ? I have initialized and displayed a "ID3D11Texture2D", so I'm wondering if I can get the pixels from this texture... Thanks [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  3. I'll do that. Thanks
  4. Alright, it works fine ! The game is not lagging and the colors and textures are alright with a mipLevel of 0. Thank you so much Erik !! The only thing remaining is that it's still lagging a bit on the menu where I wanted the mip mapping applied; do I have to call a particular function like GenerateMips on frameTime or I can't do anything about it ?
  5. The textures are static, I'll try this and hope it won't be so laggy, because it's unplayable right now.
  6. Yaaay I just got it to work ! The problem is now that it's incredibly laggy... maybe because I do the UpdateSubresource + generateMips each frame... ?
  7. Ok. First I create the texture with a call to Basic Loader, then I get the size of the texture + texture & textureView into my class : [CODE] BasicLoader^ loader = ref new BasicLoader(m_d3dDevice.Get()); loader->LoadTexture(fileName_, &texture, &textureView); D3D11_TEXTURE2D_DESC textDesc; texture->GetDesc(&textDesc); w = textDesc.Width; h = textDesc.Height; contentSize.width = w; contentSize.height = h; [/CODE] Inside the BasicLoader, this is what I do (important part only) : [CODE] D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory( &textureDesc, sizeof(textureDesc) ); textureDesc.Width = width; textureDesc.Height = height; textureDesc.MipLevels = 0; textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; textureDesc.SampleDesc.Count = 1; textureDesc.Usage = D3D11_USAGE_DEFAULT; textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; textureDesc.CPUAccessFlags = 0; textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; HRESULT hr = m_d3dDevice->CreateTexture2D( &textureDesc, NULL, &texture2D ); [/CODE] And at each frame, I make a call to a function that contains the "updateSubResource" & the GenerateMips: [CODE] D3D11_BOX destBox; destBox.left = 0; destBox.right = this->contentSize.width; destBox.top = 0; destBox.bottom = this->contentSize.height; destBox.front = 0; destBox.back = 1; ComPtr<IWICFormatConverter> formatConverter; Microsoft::WRL::ComPtr<IWICImagingFactory2> m_wicFactory; if (m_wicFactory.Get() == nullptr) { DX::ThrowIfFailed( CoCreateInstance( CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_wicFactory) ) ); } DX::ThrowIfFailed( m_wicFactory->CreateFormatConverter(&formatConverter) ); int taille = this->contentSize.width * this->contentSize.height * 4; std::unique_ptr<byte[]> bitmapPixels(new byte[taille]); // ************* THE PROGRAM IS CRASHING HERE; IF I DON'T PUT THIS, IT'S NOT CRASHING BUT THE TEXTURES ARE NOT DISPLAYED ! ************* DX::ThrowIfFailed( formatConverter->CopyPixels( nullptr, this->contentSize.width * 4, this->contentSize.width * this->contentSize.height * 4, bitmapPixels.get() ) ); // *********************************************************************************************************************************************** m_d3dDeviceContext->UpdateSubresource( this->texture.Get(), // the texture to update 0, // first mip-level &destBox, // position of the pixels to update in the texture bitmapPixels.get(), // image data this->contentSize.width * 4, // row pitch 0 // not used for 2D textures ); m_d3dDeviceContext->GenerateMips(this->textureView.Get()); [/CODE] There's a comment line in CAPITALS for you upward.
  8. So I've managed to get it to work, the code compiles and the app launches but none of my textures are displayed :/ instead I get some weird white squares (the colored background should also be textured): [img]http://tof.canardpc.com/view/0b7c0557-a3a7-4730-aed7-0a199b6484a9.jpg[/img]
  9. Okay, I made this : [CODE] D3D11_BOX destBox; destBox.left = 0; destBox.right = width; destBox.top = 0; destBox.bottom = height; destBox.front = 0; destBox.back = 1; std::unique_ptr<byte[]> bitmapPixels(new byte[width * height * 4]); m_d3dDeviceContext->UpdateSubresource( this->texture.Get(), // the texture to update 0, // first mip-level &destBox, // position of the pixels to update in the texture bitmapPixels.get(), // image data width * 4, // row pitch 0 // not used for 2D textures ); m_d3dDeviceContext->GenerateMips(this->textureView.Get()); [/CODE] It still does'nt work but gives me another error, I'll try to find what's wrong and tell you how it goes.
  10. Wow big answer there, thanks ! "I got the impression that this is what you want, for D3D to automatically generate your mipmaps for you." - Yep that is exactly what I want. "I believe D3DX11CreateTextureFromMemory does this automatically for you" - As I'm doing a Metro application, I can't use this library :/ "The other option is to let D3D generate mipmaps with D3D11_RESOURCE_MISC_GENERATE_MIPS." - I'll try this one because it's not so different from my base code. "Is your goal to do this during a game-frame, and automatically have mipmaps generated for your new texture?" - Yes, as the object get far from the camera I want the mip map to update to a lower resolution texture in the better case I'll try with the UpdateSubresource method and tell you if all works properly. Thanks again mate !
  11. Hi Erik, I passed NULL to CreateTexture2D and all became black as expected, then at each frame I call this codeto render my textures : [CODE] m_d3dDeviceContext->UpdateSubresource( m_constantBuffer.Get(), 0, nullptr, &(m_constantBufferData), 0, 0 ); [/CODE] I don't know if I should put this function just after the createTexture, or if I must change the parameters of it... nvertheless it still is'nt working :/ MJP : I did what you told me but I still got the problem ><, I'm kind of a noob on this one Here's the code if interested : [CODE] D3D11_SUBRESOURCE_DATA* initData(new D3D11_SUBRESOURCE_DATA[3 * 3]); initData[0].pSysMem = bitmapPixels.get(); initData[0].SysMemPitch = width * 4; initData[0].SysMemSlicePitch = 0; initData[1].pSysMem = bitmapPixels.get(); initData[1].SysMemPitch = width * 4; initData[1].SysMemSlicePitch = 0; initData[2].pSysMem = bitmapPixels.get(); initData[2].SysMemPitch = width * 4; initData[2].SysMemSlicePitch = 0; D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory( &textureDesc, sizeof(textureDesc) ); textureDesc.Width = width; textureDesc.Height = height; textureDesc.MipLevels = 0; // PROBLEM WITH THIS textureDesc.ArraySize = 1; textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; textureDesc.SampleDesc.Count = 1; textureDesc.Usage = D3D11_USAGE_IMMUTABLE; // PROBLEM HERE ALSO textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; textureDesc.CPUAccessFlags = 0; textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS; HRESULT hr = m_d3dDevice->CreateTexture2D( &textureDesc, initData, &texture2D ); [/CODE] Thanks again for your help guys
  12. That's how I initialize initialData : [CODE] D3D11_SUBRESOURCE_DATA initialData; ZeroMemory(&initialData, sizeof(initialData)); initialData.pSysMem = bitmapPixels.get(); initialData.SysMemPitch = width * 4; initialData.SysMemSlicePitch = 0; [/CODE] "Skip using initialData and instead upload the first mip-level using UpdateSubResource." humm... how can I do that ? :s
  13. I did this : [CODE] HRESULT hr = m_d3dDevice->CreateTexture2D( &textureDesc, &initialData, &texture2D ); [/CODE] but I get an error inside "CreateTexture2D", thus I cannot check the error code of HRESULT :/
  14. I actually already have the "D3D11_CREATE_DEVICE_BGRA_SUPPORT" flag. I changed the format to R8G8B8A8 and did the quick fix in the Pixel Shader, the game works fine but I still get an error when I set MipLevels to 0, I'll try with the HRESULT. Just for info, I'm working on a Metro app.