   directsound and opengl conflict
  I'm having a quite weird problem:I'm using OpenGL for the rendering and DirectSound for Sound output. When I initialize OpenGL I use wglChoosePixelFormatARB to enumerate the pixelformats and on a computer with an ATI Radeon 9700 graphic card it tells me there are 14 formats meeting my specifications.When I initialize DirectSound ,release it and enumerte the Pixel formats again, there are only 2 formats left.Heres a bit of Pseudocode:EnumPixelFormats(); // Gets 14 formatsDirectSoundCreate8(...); // Create Direct Soundm_pDS->Release();   // Release Direct SoundEnumPixelFormats(); // Only 2 left   This is a problem in OGl, because when someone wants to change the resolution I've to create a new window and enumerate the pixel formats again, but at that point I already have initialized Direct Sound and I can't create the new window, because the pixel format I'm searching for isn't listed anymore.On a Geforce Card the problem doesn't occure...Does anyone have an idea, why this happens, and what I can do do, to solve the Problem?Thanks in Advance,Roland    Edit: Graphic Card version corrected[edited by - roland on August 6, 2003 3:38:54 AM]
  Weird I guess the best thing to do will be to enumerate the settings and store them away.  It''s unlikely the list of modes are going to change so you don''t really need to enumerate them twice. ;  Nice idea, but it doesn''t work. I can''t set a Pixel Format, that was enumerated the first time, ans isn''t the second.If I try to do so, there are a lot of Problems: its very slow, stencil and environment mapping don''t work and things like that... ;  Ah.Well, maybe forcing the app to restart would be the cleanest solution.  I can only see this being a driver bug - it works on some systems and not others (unpredictably).  What sound card? What driver versions have you tried? ;  Restarting would be a solution, but its not very elegant.Its an onboard soundcard: Avance AC97 driver version 5.10.0.4010.My first postwas wrong. It is an ATI Radeon 9700 with the newest ATI Catalyst drivers (Version 6.14.10.6360). [edited by - roland on August 4, 2003 9:13:11 AM];  You might want to try the Win32 pixel format functions instead of the wgl stuff just to see what it spits out. ;  You are right. I''ll try tomorrow, to see what happens. But I have to use the wgl ones, because I want to enable antialiasing and thats not possible with the Win32 functions, as far as I know. ;  I''ve tried the Win 32 functions.Normally there are 54 PixelFormats available under win 32. But after I have called wglGetPixelFormatAttribivARB, DescribePixelFormat reports that there are 138 different PixelFormats.After initialising DirectSound there are again 54... ;  Hmm dunno how you do it, but I just create a window, setup OpenGL (normal WGL), check the ARB pixel format extension for additional formats (for antialiasing and such), then reinitialize OpenGL... Not sure why DirectSound would have anything to do with that.  ;  Ok here is a simple test program, that causes the error.It creates a window, initialises the extensions, destroys the window and creates a new one.Then it enumerates the Pixelformats, creates DirectSound, releases it and enumerates again.Thats enough to cause the problem.I think it's not the soundcard driver. I tried the Program on a computer with a Geforce card, but the rest of the components is identical and the problem didn't occure. #include "stdafx.h"#include "enumTest.h"#include "Mmsystem.h"#include "dsound.h"#include "gl/gl.h"#include "gl/glext.h"#include "gl/wglext.h"#define GLH_EXT_SINGLE_FILE#include "glh/glh_extensions.h"LRESULT CALLBACK WindowProc(  HWND hwnd, // handle to window  UINT uMsg, // message identifier  WPARAM wParam,  // first message parameter  LPARAM lParam   // second message parameter){return true;};int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR    lpCmdLine, int  nCmdShow){//Register Window ClassWNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX); wcex.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC ;wcex.lpfnWndProc= WindowProc;wcex.cbClsExtra= 0;wcex.cbWndExtra= 0;wcex.hInstance= hInstance;wcex.hIcon= LoadIcon(hInstance, (LPCTSTR)IDI_ENUMTEST);wcex.hCursor= LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);wcex.lpszMenuName= NULL;wcex.lpszClassName= "MyClass";wcex.hIconSm= NULL;RegisterClassEx(&wcex);// Create WindowHWND hWnd = CreateWindow("MyClass", "test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);if (!hWnd)return 0;// Initialise OpenGlHDC hDC = GetDC(hWnd);SetPixelFormat(hDC,1,NULL);HGLRC hGL = wglCreateContext(hDC);wglMakeCurrent(hDC,hGL);if (!hGL){DestroyWindow(hWnd);return 0;}// Initialise Extensionsif (!glh_init_extensions("WGL_ARB_pixel_format")){DestroyWindow(hWnd);return 0;};// Destroy WinbdowwglDeleteContext(hGL);DeleteDC(hDC);DestroyWindow(hWnd);// Create a new WindowhWnd = CreateWindow("MyClass", "test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);if (!hWnd)return 0;hDC = GetDC(hWnd);// enumerate Pixelformatsint iAttributes[30];int iResults[30] ={0};// Retrieve the number of pixel formats availableiAttributes[0] = WGL_NUMBER_PIXEL_FORMATS_ARB;wglGetPixelFormatAttribivARB(hDC, 0, 0, 1, iAttributes, iResults);int NumVorher = iResults[0];int NumVorherKlassisch = DescribePixelFormat(hDC,0,0,NULL);// create a Direct Sound objectIDirectSound8 *lpDS;DirectSoundCreate8(NULL, &lpDS, NULL);if (!lpDS){wglDeleteContext(hGL);DestroyWindow(hWnd);return 0;};// release it againlpDS->Release();// and enumerate a second timeint NumNachherKlassisch = DescribePixelFormat(hDC,0,0,NULL);iAttributes[0] = WGL_NUMBER_PIXEL_FORMATS_ARB;wglGetPixelFormatAttribivARB(hDC, 0, 0, 1, iAttributes, iResults);int NumNachher = iResults[0];// Show resultschar String[100];sprintf(String,"Windows:\t  Before: %d After: %d\nARB:\t  Before: %d After: %d",NumVorherKlassisch,NumNachherKlassisch,NumVorher,NumNachher);MessageBox(hWnd,String,"Ergebnis",MB_OK);wglDeleteContext(hGL);DeleteDC(hDC);DestroyWindow(hWnd);return 0;} [edited by - roland on August 6, 2003 4:54:56 AM]