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

Humblest

Members
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

102 Neutral

About Humblest

  • Rank
    Newbie
  1. For each thread, there's one dedicated OpenGL context and only one wglMakeCurrent(). This is a server rendering program rather than a desktop application, each thread is responding to one client request and doing its own job. No OpenGL context is shared among them. The maximum number of concurrency won't be high, but concurrency is required.
  2. Hi, all: I've been programming server-side offscreen rendering with OpenGL under MS Windows. The workflow consists of the following steps: 1. A client sends a request for volume rendering. 2. Server receives the request, forks a worker thread to do some ray-casting with parameters contained in the request. 3. Server retrieves the rendered image, sends it to the client and terminates the worker thread. It works fine at first. However, after 10,000 requests, wglMakeCurrent() will fail and significant memory leak can be detected. So I make a simplified test program which contains only OpenGL context creation and deletion. It's shown below. wglMakeCurrent() always fails after about 10,000 loops. Can somebody tell me if there's anything wrong with the code? I'm using Nvidia Quadro GPU, the driver version is 307.45, OS is Windows 7 64-bit.     #include <cstdio> #include <windows.h> #include <tchar.h> #include <process.h> LRESULT CALLBACK WndProc_GL(HWND handle, UINT message, WPARAM w_param, LPARAM l_param) {   return DefWindowProc(handle, message, w_param, l_param); }//------------------------------------------------------- unsigned int __stdcall OpenglThreadProc(void *ptr_input) {   HINSTANCE inst_handle = GetModuleHandle(NULL);   WNDCLASS wnd_class = {CS_HREDRAW | CS_VREDRAW | CS_OWNDC,     (WNDPROC)WndProc_GL,     0, 0, inst_handle, NULL, NULL, NULL, NULL,     _T("OpenGL Hidden Window Class")   };   if (!RegisterClass(&wnd_class)) return 0;   HWND window_handle = CreateWindow(_T("OpenGL Hidden Window Class"),     _T("Window For OpenGL"),     WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDRE N, 0, 0, 256, 256,     NULL, NULL, inst_handle, NULL);   if (!window_handle) return 0;   HDC dc_handle = GetDC(window_handle);   PIXELFORMATDESCRIPTOR ogl_pfd = {sizeof(PIXELFORMATDESCRIPTOR), 1,     PFD_SUPPORT_OPENGL,     PFD_TYPE_RGBA, 32,     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     24, 8, 0,     PFD_MAIN_PLANE,     0, 0, 0, 0   };   int pixel_format = ChoosePixelFormat(dc_handle, &ogl_pfd);   if (!SetPixelFormat(dc_handle, pixel_format, &ogl_pfd)) return 0;     HGLRC rc_handle = wglCreateContext(dc_handle);   if (!rc_handle || !wglMakeCurrent(dc_handle, rc_handle)) return 0;   _tprintf_s(_T("Executing Thread %d.\n"), *(reinterpret_cast<int*>(ptr_input)) + 1);   // Deletes OpenGL context and destroys window.   wglMakeCurrent(NULL, NULL);   wglDeleteContext(rc_handle);   ReleaseDC(window_handle, dc_handle);   DestroyWindow(window_handle);   UnregisterClass(_T("OpenGL Hidden Window Class"), GetModuleHandle(NULL));   return 1; }//-------- int main (const int argc, TCHAR *argv[]) {   int i = 0;   for (; i < 20000; i++) {     HANDLE running_thread = reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0,       OpenglThreadProc, &i, 0, NULL));     WaitForSingleObject(running_thread, INFINITE);     CloseHandle(running_thread);   }   return 1; }//---------     I found something confusing with this test program. wglMakeCurrent() creates a Windows user object every time it's called, but this object is not released in wglDeleteContext(). It still exists even after the worker is terminated, causing a memory leak. There is a per-process limit of user objects under Windows, so the program will eventually fail. When the code of context creation/deletion is moved to the main thread, wglMakeCurrent() doesn't create new user object after the first invocation. So it seems that wglMakeCurrent() only create new user object in new threads. But since the OpenGL context is explicitly deleted and the thread is terminated, resources associated with that context should be released as well. I'm not sure it's the fault with my code or the driver. Can somebody help me with this?