logo
down
shadow

Cannot release Device Context, HWND, and cannot unregister Windows Class(OpenGL) -


Cannot release Device Context, HWND, and cannot unregister Windows Class(OpenGL) -

By : user2948510
Date : November 14 2020, 04:51 PM
this one helps. Probably KillGLWindow is called more than one time, and its not really proper, try this:
code :
GLvoid KillGLWindow(GLvoid){ 
if (fullscreen){
    ChangeDisplaySettings(NULL, 0);
    ShowCursor(true);
}
if (hRC){
    if (!wglMakeCurrent(NULL, NULL)){
        MessageBox(NULL, "Release of DC and RC failed", "Shutdown error", MB_OK | MB_ICONINFORMATION);
    }
    if (!wglDeleteContext(hRC)){
        MessageBox(NULL, "Release of RC failed", "Shutdown error", MB_OK | MB_ICONEXCLAMATION);
    }
}
hRC = NULL;
if (hDC && !ReleaseDC(hWnd, hDC)){
    MessageBox(NULL, "Release of DC failed", "Shutdown error", MB_OK | MB_ICONINFORMATION);
}
hDC = NULL;
if (hWnd && !DestroyWindow(hWnd)){
    MessageBox(NULL, "Release of hWnd failed", "Shutdown error", MB_OK | MB_ICONINFORMATION);
}
hWnd = NULL;
if (hInstance && !UnregisterClass("OpenGL", hInstance)){
    MessageBox(NULL, "Could not unregister window class", "Shutdown error", MB_OK | MB_ICONINFORMATION);
}
hInstance = NULL;
}


Share : facebook icon twitter icon
C/C++ - Windows - how to keep track of HWND context data

C/C++ - Windows - how to keep track of HWND context data


By : user2486437
Date : March 29 2020, 07:55 AM
wish helps you if I'm understanding you correctly, you want to avoid one window to catch the messages from another. One way to avoid this is to use the solution proposed in this thread, which keeps track of the windows that is created by you and makes sure that the correct windows gets the messages associated to it by storing the pointer for the caller in the GWL_USERDATA .
code :
// ...
m_hWnd = CreateWindowEx(0,"Classname","Title",WS_OVERLAPPEDWINDOW,
                        CW_USEDEFAULT,CW_USEDEFAULT,
                        320,200,NULL,NULL,hInstance, /*the magic pointer*/ this);

// ...

if(uMsg == WM_CREATE)
{
    // collected here..
    pParent = (CWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
    // .. and then stored for later lookup
    SetWindowLongPtr(hWnd,GWL_USERDATA,(LONG_PTR)pParent); 
}
// ...
SDL- get HDC device context for OpenGL/OpenCL shared context

SDL- get HDC device context for OpenGL/OpenCL shared context


By : pkamat
Date : March 29 2020, 07:55 AM
around this issue The most portable and framework agnostic method is to use the platform specific WSI functions to query the drawable and OpenGL context. Using a few typedefs you can make portable wrappers which you can then use to query the context and drawable.
code :
#if defined(_WIN32)
typedef HGLRC GLContext;
typedef HDC   GLDrawable;
typedef HWND  GLWindow;

GLContext getCurrentGLContext(void) { return wglGetCurrentContext(); }
GLDrawable getCurrentGLDrawable(void) { return wglGetCurrentDC(); }
GLWindow getCurrentGLWindow(void) { return WindowFromDC(wglGetCurrentDC()); }
#elif defined(__unix__)
/* FIXME: consider Wayland or a EGL environment */
typedef GLXContext GLContext;
typedef GLXDrawable GLDrawable;
typedef Window GLWindow;

GLContext getCurrentGLContext(void) { return glXGetCurrentContext(); }
GLDrawable getCurrentGLDrawable(void) { return glXGetCurrentDrawable(); }
GLWindow getCurrentGLWindow(void) { return glXGetCurrentDrawable(); }
#elif __APPLE__
/* FIXME: Implement this for MacOS X
#endif
Why do GetParent(hwnd) and (HWND)::GetWindow(hwnd, GW_OWNER) for top level windows give different results?

Why do GetParent(hwnd) and (HWND)::GetWindow(hwnd, GW_OWNER) for top level windows give different results?


By : user6688
Date : March 29 2020, 07:55 AM
wish help you to fix your issue A window with a parent but no owner is not a top level window. That is the obvious explanation to the scenario that you describe.
Update
Drawing to a Windows device context (hWnd/hDC) from WPF MediaPlayer/DrawingVisual or convert to System.Drawing.Graphics

Drawing to a Windows device context (hWnd/hDC) from WPF MediaPlayer/DrawingVisual or convert to System.Drawing.Graphics


By : asdfg
Date : March 29 2020, 07:55 AM
will be helpful for those in need I am using Bitmap data copying (LockBits) and it's fast enough. to this answer.
code :
    public Bitmap Render()
    {
        var bitmapRender = this.CreateRenderTargetBitmap();

        using (var drawingContext = this.drawingVisual.RenderOpen())
        {
            drawingContext.DrawVideo(this.MediaPlayer, this.drawingRect);
            drawingContext.Close();
        }   

        bitmapRender.Render(this.drawingVisual);

        var result = new Bitmap(this.Width, this.Height, DrawingPixelFormat);
        var bitmapData = result.LockBits(
            this.renderRect, 
            System.Drawing.Imaging.ImageLockMode.WriteOnly, 
            DrawingPixelFormat);

        bitmapRender.CopyPixels(
            Int32Rect.Empty,
            bitmapData.Scan0,
            bitmapData.Stride * bitmapData.Height,
            bitmapData.Stride);

        result.UnlockBits(bitmapData);

        return result;
    }

    RenderTargetBitmap CreateRenderTargetBitmap() => new RenderTargetBitmap(
            this.Width, this.Height,
            this.Dpi, this.Dpi,
            WpfPixelFormat);
OpenGL context without opening a window - wglMakeCurrent fails with HDC and HGLRC when using HWND made with GetDesktopWi

OpenGL context without opening a window - wglMakeCurrent fails with HDC and HGLRC when using HWND made with GetDesktopWi


By : user3763984
Date : March 29 2020, 07:55 AM
it fixes the issue One must not create a OpenGL context on the desktop window. To create a OpenGL context, one must set the windows's pixelformat, which is strictly forbidden to be done on the desktop window.
If you want to do offscreen rendering, use a PBuffer instead of a window, or create a window you don't make visible and use a Frame Buffer Object (FBO) as render target.
Related Posts Related Posts :
  • Vector of pointers: some clarification needed
  • scaling a bitmap without losing quality
  • How to evaluate a function directly?
  • QNetworkAccessManager: How to change post data at createRequest function
  • Returning std::move of a local variable
  • Is there a fast linear SVM library with a good C++ interface?
  • What is the purpose of name mangling in C++?
  • C++ Why the void function is not working eventhough I called it?
  • How the pointer and the pointer's adress can share the same memory adress?
  • error C2220: warning treated as error - no 'object' file generated
  • exception of strcpy function in c++ console program
  • How to access USB barcode scanner data directly from USB port using C/C++ without driver
  • Under which circumstances will std::vector.clear() call a destructor?
  • Template partial specialisation and dependent names
  • best way to share data between c codes
  • C++ ignores if statement conditions
  • How to set the argv[ ] to be case-insensitive in a Win32 Console Application?
  • How to fix error "clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)"?
  • C++ How do I print a .txt file verbatim?
  • Creating two dimensional array of class
  • How do I correctly use COMMTIMEOUTS with OVERLAPPED IO mode reading from a Serial port
  • An assert macro which expands to static_assert when possible?
  • How to write a copyconstructor for a class which has HANDLE as a member in win32 c++ application?
  • C++ saving info such as tree in a file
  • Transforming an expression template tree
  • How to overload an operator with multiple parameters like a + b + c?
  • C++ 11 with Raspberry Pi performances
  • Make a C++ class look like a numpy array using swig
  • Postfix incrementer overloading for nested enumerated types
  • Is there a tidy way of associating metadata with functions in C++
  • QObject::installEventFilter(): Cannot filter events for objects in a different thread
  • LNK2005 error with Zxing C++
  • C++ Doubly Linked List with Pointers: Object of class isn't constructed properly
  • Using a random string generator in c++ constructor
  • What should I use instead of void as one of the alternative types in an variant?
  • C++ return value from multithreads using reference
  • How to connect multiple TCP IP clients to same server port using c++
  • Defaul compiler generates the reference operator (In C++)?
  • Unable to change directory time stamp after using FILE_FLAG_BACKUP_SEMANTICS
  • vector handling displaying output
  • WSAGetLastError returns WSAENOTSOCK - Cause?
  • C++: How to overload pow for user type?
  • C++ using arrays as multidimensional despite initalising it as 1D with pointer
  • How negate std::is_integral for use in tag dispatch?
  • Retrieve serial number from USB memory (Windows environment c++)
  • g++ error: invalid preprocessing directive #INCLUDE
  • C++ What is the std::for_each() function parameter type?
  • C++: Read individual lines from text file, sort words alphabetically
  • Saving 'this' address into a variable
  • c++ command line arguments in ubuntu terminal
  • Convert "Cartesian coordinates" to "polar coordinates with respect to user specified origin"
  • In what order are local scoped objects destructed?
  • How to use SDL_MapRGB with SDL 2.0
  • how compiler and interpreter work in case of array declaration
  • GSL integration behaves strange
  • Cropping an image with OpenCV and C
  • Find the last line in text file and select the first 10 char and print to a new file?
  • Created many CCSprits but when triggering ccTouchBegan gives the last one allways
  • seekp and seekg don't work with fstream
  • Taking input in Sublime Text 3
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org