• 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.

exextatic

Members
  • Content count

    78
  • Joined

  • Last visited

Community Reputation

111 Neutral

About exextatic

  • Rank
    Member
  1. Perfect, this fixed it, many thanks :)   I feel that part of the horrible quality it was producing was due to it being a JPG (tried PNG, looks better), but it turns out the actual issue was the data type that the intensity was using. Many thanks for the help though :)
  2. Not sure if it's better to post in here or the DirectX forums, but I digress.   Just starting out with using FreeType for my font system under DirectX9, and am having horrible results - the output characters look worse than the regular D3DXCreateFont / DrawText methods, for example: Lower-case 'k':   Lower-case 'w': Currently, all that's happening is the font is being loaded through TrueType, and I'm taking the bitmap it generates and putting it into an IDirect3DTexture9 struct, and then writing it to a file as a jpg. Here is the code currently in use to do this (non-interesting bits removed, apologies for the generally atrocious code): CFont::CFont(char* face, int height, int width, bool italic) { FT_Init_FreeType(&library); FT_New_Face(library, face, NULL, &fFace); FT_Set_Char_Size(fFace, width, height, 300, 300); FT_Set_Pixel_Sizes(fFace, 0, 16); //ToDo: Fix this } void SetPixel(D3DLOCKED_RECT* rect, int x, int y, D3DCOLOR col) { unsigned char *bits = (unsigned char *)rect->pBits; memcpy(&bits[rect->Pitch * y + 4 * x], &col, 4); } HRESULT CFont::Draw(char* text, int count, D3DCOLOR colour, DWORD format) { FT_GlyphSlot slot = fFace->glyph; for(int n = 0; n < count; n++) { FT_Set_Char_Size(fFace, 24 << 6, 24 << 6, 300, 300); FT_UInt glyph_index = FT_Get_Char_Index(fFace, text[n]); if(FT_Load_Glyph(fFace, glyph_index, FT_LOAD_DEFAULT)) continue; if(FT_Render_Glyph(fFace->glyph, FT_RENDER_MODE_NORMAL)) continue; LPDIRECT3DTEXTURE9 tmp; FT_Bitmap *ftBitmap = &fFace->glyph->bitmap; const int height = ftBitmap->rows; const int width = ftBitmap->width; D3DXCreateTexture(Renderer().GetD3DDev(), width, height, D3DX_DEFAULT, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tmp); D3DLOCKED_RECT tmp2; tmp->LockRect(0, &tmp2, NULL, D3DLOCK_DISCARD); FillMemory(tmp2.pBits, width*height*tmp2.Pitch, 255); //Code from: http://www.gamedev.net/topic/545202-freetype/ for(int y = 0; y < height; ++y) { for(int x = 0; x < width; ++x) { byte intensity = ftBitmap->buffer[y * ftBitmap->pitch + x]; byte r = (byte)(0 * intensity); byte g = (byte)(255 * intensity); byte b = (byte)(0 * intensity); SetPixel(&tmp2, x, y, D3DCOLOR_ARGB(255/*intensity*/, r, g, b)); } } tmp->UnlockRect(0); char finalName[6]; sprintf(finalName, "%c.jpg", text[n]); D3DXSaveTextureToFile(finalName, D3DXIFF_JPG, tmp, NULL); } return S_OK; }   My question is, how can I improve the output from this code? I've also attached the whole alphabet's images.   Many thanks in advance,
  3. [quote name='Bacterius' timestamp='1331502807' post='4921196'] [quote]I never call CreateWindow(). The windows are managed by the Managed C++ code that handles the forms (one of the reasons all the rendering code is in an unmanaged DLL). I just take the window sizes given (and the hWnd of each window). Would that affect it?[/quote] You should still make sure the client size (i.e. excluding titlebar and borders) is equal to your backbuffer, otherwise you will get some ugly downsampling and messed up picking as Evil Steve noted. I'm not sure what you would use in C++ but it should be something like "yourwindow.ClientSize = (800, 600)" in pseudocode. [/quote] When the 'window' is resized, the managed C++ code puts the new size (excluding bars) into the directx code to resize window.. I think it always has the correct window size.
  4. I think its been 24 hours so bump? Edit: 1 hour out sorry...
  5. [quote name='Evil Steve' timestamp='1331203891' post='4920385'] You still want to use AdjustWindowRect() when creating the window. It's usually done something like (semi-psuedo-code): [code] void initWindow(int width, int height) { // Get window dimensions that will give a client area of width x height RECT rcWindow; rcWindow.left = 0; rcWindow.top = 0; rcWindow.right = width; rcWindow.bottom = height; AdjustWindowRect(&rcWindow, WS_OVERLAPPEDWINDOW, FALSE); // Create window with adjusted dimensions int windowW = rcWindow.right - rcWindow.left; int windowH = rcWindow.bottom - rcWindow.top; HWND hWnd = CreateWindow(..., windowW, windowH, ...); // [D3D setup code here] // Setup backbuffer with client area width and height presentParams.BackBufferWidth = width; presentParams.BackBufferWidth = height; pD3D->CreateDevice(...) } [/code] And similarly for resizing the window. If it's working correctly, then GetClientRect() will give you a RECT with the exact same dimensions as your backbuffer. [/quote] I never call CreateWindow(). The windows are managed by the Managed C++ code that handles the forms (one of the reasons all the rendering code is in an unmanaged DLL). I just take the window sizes given (and the hWnd of each window). Would that affect it?
  6. [quote name='Evil Steve' timestamp='1331120317' post='4920035'] 1. AdjustWindowRect() returns the window size for a given client area size. But it's the client area size you need for the backbuffer dimensions. What you're doing is asking for a e.g. 800x600 client area, and then setting the backbuffer size to e.g. 808x642. [/quote] Okay, so I only need that value when resizing the backbuffer? [quote name='Evil Steve' timestamp='1331120317' post='4920035']2. You can't just use the right and bottom edges of the RECT updated by AdjustWindowRect - you need to do right-left and bottom-top, since the top and left values are also updated (And can contain negative values).[/quote] This ones easy Edit: Still not working with this code: Window Update function: [CODE]void Editor::doWindowUpdate() { invalidateDeviceObjects(); RECT wr = {0, 0, screenSize[0].x, screenSize[0].y}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); d3dpp.BackBufferHeight = wr.bottom - wr.top; d3dpp.BackBufferWidth = wr.right - wr.left; d3dpp.hDeviceWindow = hWnd[0]; HRESULT hr = d3ddev->Reset(&d3dpp); if(hr != D3D_OK) { MessageBox(NULL, "Call to Reset() failed!", "ERROR", MB_OK | MB_ICONEXCLAMATION); } restoreDeviceObjects(); hasWindowResized = false; }[/CODE] Backbuffer update code: [CODE]void Editor::updateBackBuffer(int width, int height, short which) { screenSize[which].x = width;// = wr.right; screenSize[which].y = height;// = wr.bottom; RECT wr = {0, 0, screenSize[which].x, screenSize[which].y}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); d3dpp.BackBufferHeight = wr.bottom - wr.top; d3dpp.BackBufferWidth = wr.right - wr.left; d3dpp.hDeviceWindow = hWnd[which]; hasWindowResized = true; }[/CODE] Swap chain initialization code: [CODE] for(int i = 0; i < 4; i++) { HRESULT hr; RECT wr = {0, 0, screenSize[i].x, screenSize[i].y}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); d3dpp.BackBufferHeight = wr.bottom - wr.top; d3dpp.BackBufferWidth = wr.right - wr.left; d3dpp.hDeviceWindow = hWnd[i]; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; if(i > 0) hr = d3ddev->CreateAdditionalSwapChain(&d3dpp, &swapchains[i]); }[/CODE] Window size code (at start) [CODE] screenSize[0].x = windowWidths[0]; screenSize[0].y = windowHeights[0]; screenSize[1].x = windowWidths[1]; screenSize[1].y = windowHeights[1]; screenSize[2].x = windowWidths[2]; screenSize[2].y = windowHeights[2]; screenSize[3].x = windowWidths[3]; screenSize[3].y = windowHeights[3];[/CODE]
  7. [quote name='Evil Steve' timestamp='1331120317' post='4920035'] 1. AdjustWindowRect() returns the window size for a given client area size. But it's the client area size you need for the backbuffer dimensions. What you're doing is asking for a e.g. 800x600 client area, and then setting the backbuffer size to e.g. 808x642. 2. You can't just use the right and bottom edges of the RECT updated by AdjustWindowRect - you need to do right-left and bottom-top, since the top and left values are also updated (And can contain negative values). 3. Please leave at least 24 hours between bumps of a thread. [/quote] Ok, I'll remember not to bump so often. I'll take a look into this later as I've got to go out now.
  8. Ok I managed to get the BackBuffers size with the following code: [CODE]D3DSURFACE_DESC tempDesc; pBackBuffer->GetDesc(&tempDesc);[/CODE] Unluckily, they had the right size so its not an issue with the BackBuffer size.
  9. All the swap chain window sizes are converted and stored like so: [CODE]RECT wr = {0, 0, windowWidths[0], windowHeights[0]}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); screenSize[0].x = wr.right; screenSize[0].y = wr.bottom; wr.right = windowWidths[1]; wr.bottom = windowHeights[1]; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); screenSize[1].x = wr.right; screenSize[1].y = wr.bottom; wr.right = windowWidths[2]; wr.bottom = windowHeights[2]; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); screenSize[2].x = wr.right; screenSize[2].y = wr.bottom; wr.right = windowWidths[3]; wr.bottom = windowHeights[3]; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); screenSize[3].x = wr.right; screenSize[3].y = wr.bottom;[/CODE] All the windows are initialised like so: [CODE]for(int i = 0; i < 4; i++) { HRESULT hr; d3dpp.BackBufferHeight = screenSize[i].y; d3dpp.BackBufferWidth = screenSize[i].x; d3dpp.hDeviceWindow = hWnd[i]; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; if(i > 0) hr = d3ddev->CreateAdditionalSwapChain(&d3dpp, &swapchains[i]); }[/CODE] Heres what happens when one of the windows resizes: [CODE]void Editor::updateBackBuffer(int width, int height, short which) { RECT wr = {0, 0, width, height}; AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); screenSize[which].x = wr.right; screenSize[which].y = wr.bottom; d3dpp.BackBufferHeight = screenSize[which].y; d3dpp.BackBufferWidth = screenSize[which].x; d3dpp.hDeviceWindow = hWnd[which]; hasWindowResized = true; }[/CODE] hasWindowResized basically tells it to call this: [CODE]void Editor::doWindowUpdate() { invalidateDeviceObjects(); d3dpp.BackBufferHeight = screenSize[0].y; d3dpp.BackBufferWidth = screenSize[0].x; d3dpp.hDeviceWindow = hWnd[0]; HRESULT hr = d3ddev->Reset(&d3dpp); if(hr != D3D_OK) { MessageBox(NULL, "Call to Reset() failed!", "ERROR", MB_OK | MB_ICONEXCLAMATION); } restoreDeviceObjects(); hasWindowResized = false; }[/CODE] Is there a way to check the backbuffer size while the app is running?