Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualslicer4ever

Posted 16 December 2012 - 07:39 AM

it defiantly would be a good point to post in nvidia forums, i'm finding it difficult to successfully follow SDL's init pathways(so many IFDef's for different OS's/config flags =-/) from what i can tell, it's doing pretty much a 1:1(or very near anyways) with my own engine's window creation code, this is assuming that i'm following the correct config flags.

anyway, i'm going to post my window creation code(cleaned up to work as a stand-alone function):


unsigned char CreateVideoContextWindows(unsigned int BorderFlag=WS_OVERLAPPEDWINDOW, unsigned int BorderFlagEx=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE, const char *ClassName, unsigned char StencilBits, unsigned char AccumBits, unsigned char DepthBits, unsigned char ColorBits){
unsigned int PixelFormat=0;
HINSTANCE m_HInstance = GetModuleHandle(0x0);
HWND m_HWnd = 0x0;
HDC m_HDc = 0x0;
HGLRC m_HGlrc = 0x0;
int m_x = 0;
int m_y = 0;
WNDCLASS WndClass={CS_HREDRAW|CS_VREDRAW|CS_OWNDC, QWWindowsProc, 0, 0, m_HInstance, LoadIcon(0x0, IDI_WINLOGO), LoadCursor(0x0, IDC_ARROW),0x0, 0x0, ClassName};
if(!RegisterClass(&WndClass)){
  MessageBox(NULL, "Error: 'RegisterClass'", "ERROR", MB_OK|MB_ICONEXCLAMATION);
  return 0;
}
RECT WndRect={0, 0, m_Width, m_Height};
AdjustWindowRectEx(&WndRect, BorderFlag, 0, BorderFlagEx);
if(!(m_HWnd = CreateWindowEx(BorderFlagEx, ClassName, m_Title, WS_CLIPSIBLINGS|WS_CLIPCHILDREN|BorderFlag, m_x, m_y, WndRect.right-WndRect.left, WndRect.bottom-WndRect.top, 0x0, 0x0, m_HInstance, 0x0))){
  MessageBox(0x0, "Error: 'CreateWindowEx'", "ERROR", MB_OK|MB_ICONINFORMATION);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, ColorBits, 0, 0, 0, 0, 0, 0, 0, 0, AccumBits, 0, 0, 0, 0, DepthBits, StencilBits, 0, 0, 0, 0, 0, 0};
if(!(m_HDc=GetDC(m_HWnd))){
  MessageBox(NULL, "Error: 'GetDC'", "ERROR", MB_OK|MB_ICONINFORMATION);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(PixelFormat=ChoosePixelFormat(m_HDc, &pfd))){
  MessageBox(NULL, "Error: 'ChoosePixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!SetPixelFormat(m_HDc, PixelFormat, &pfd)){
  MessageBox(NULL, "Error: 'SetPixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(m_HGlrc=wglCreateContext(m_HDc))){
  MessageBox(NULL, "Error: 'wglCreateContext'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(wglMakeCurrent(m_HDc, m_HGlrc))){
  MessageBox(NULL, "Error: 'wglMakeCurrent'", "ERROR", MB_OK|MB_ICONINFORMATION);
  wglDeleteContext(m_HGlrc);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
SetForegroundWindow(m_HWnd);
SetFocus(m_HWnd);
return 1;
}

#2slicer4ever

Posted 16 December 2012 - 07:38 AM

it defiantly would be a good point to post in nvidia forums, i'm finding it difficult to successfully follow SDL's init pathways(so many IFDef's for different OS's/config flags =-/) from what i can tell, it's doing pretty much a 1:1(or very near anyways) with my own engine's window creation code, this is assuming that i'm following the correct config flags.

anyway, i'm going to post my window creation code(cleaned up to work as a stand-alone function):


unsigned char CreateVideoContextWindows(unsigned int BorderFlag=WS_OVERLAPPEDWINDOW, unsigned int BorderFlagEx=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE, const char *ClassName, unsigned char StencilBits, unsigned char AccumBits, unsigned char DepthBits, unsigned char ColorBits){
unsigned int PixelFormat=0;
HINSTANCE m_HInstance = GetModuleHandle(0x0);
HWND m_HWnd = 0x0;
HDC m_HDc = 0x0;
HGLRC m_HGlrc = 0x0;
int m_x = 0;
int m_y = 0;
WNDCLASS WndClass={CS_HREDRAW|CS_VREDRAW|CS_OWNDC, QWWindowsProc, 0, 0, m_HInstance, LoadIcon(0x0, IDI_WINLOGO), LoadCursor(0x0, IDC_ARROW),0x0, 0x0, ClassName};
if(!RegisterClass(&WndClass)){
  MessageBox(NULL, "Error: 'RegisterClass'", "ERROR", MB_OK|MB_ICONEXCLAMATION);
  return 0;
}
RECT WndRect={0, 0, m_Width, m_Height};
AdjustWindowRectEx(&WndRect, BorderFlag, 0, BorderFlagEx);
if(!(m_HWnd = CreateWindowEx(BorderFlagEx, ClassName, m_Title, WS_CLIPSIBLINGS|WS_CLIPCHILDREN|BorderFlag, m_x, m_y, WndRect.right-WndRect.left, WndRect.bottom-WndRect.top, 0x0, 0x0, m_HInstance, 0x0))){
  MessageBox(0x0, "Error: 'CreateWindowEx'", "ERROR", MB_OK|MB_ICONINFORMATION);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, ColorBits, 0, 0, 0, 0, 0, 0, 0, 0, AccumBits, 0, 0, 0, 0, DepthBits, StencilBits, 0, 0, 0, 0, 0, 0};
if(!(m_HDc=GetDC(m_HWnd))){
  MessageBox(NULL, "Error: 'GetDC'", "ERROR", MB_OK|MB_ICONINFORMATION);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(PixelFormat=ChoosePixelFormat(m_HDc, &pfd))){
  MessageBox(NULL, "Error: 'ChoosePixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!SetPixelFormat(m_HDc, PixelFormat, &pfd)){
  MessageBox(NULL, "Error: 'SetPixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(m_HGlrc=wglCreateContext(m_HDc))){
  MessageBox(NULL, "Error: 'wglCreateContext'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(wglMakeCurrent(m_HDc, m_HGlrc))){
  MessageBox(NULL, "Error: 'wglMakeCurrent'", "ERROR", MB_OK|MB_ICONINFORMATION);
  wglDeleteContext(m_HGlrc);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
SetForegroundWindow(m_HWnd);
SetFocus(m_HWnd);
return 1;
}

#1slicer4ever

Posted 16 December 2012 - 07:38 AM

it defiantly would be a good point to post in nvidia forums, i'm finding it difficult to successfully follow SDL's init pathways(so many IFDef's for different OS's/config flags =-/) from what i can tell, it's doing pretty much a 1:1(or very near anyways) with my own engine's window creation code, this is assuming that i'm following the correct config flags.

anyway, i'm going to post my window creation code(cleaned up to work as a stand-alone function):


unsigned char Flag = QWWindow::CreateVideoContextWindows(unsigned int BorderFlag=WS_OVERLAPPEDWINDOW, unsigned int BorderFlagEx=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE, const char *ClassName, unsigned char StencilBits, unsigned char AccumBits, unsigned char DepthBits, unsigned char ColorBits){
unsigned int PixelFormat=0;
HINSTANCE m_HInstance = GetModuleHandle(0x0);
HWND m_HWnd = 0x0;
HDC m_HDc = 0x0;
HGLRC m_HGlrc = 0x0;
int m_x = 0;
int m_y = 0;
WNDCLASS WndClass={CS_HREDRAW|CS_VREDRAW|CS_OWNDC, QWWindowsProc, 0, 0, m_HInstance, LoadIcon(0x0, IDI_WINLOGO), LoadCursor(0x0, IDC_ARROW),0x0, 0x0, ClassName};
if(!RegisterClass(&WndClass)){
  MessageBox(NULL, "Error: 'RegisterClass'", "ERROR", MB_OK|MB_ICONEXCLAMATION);
  return 0;
}
RECT WndRect={0, 0, m_Width, m_Height};
AdjustWindowRectEx(&WndRect, BorderFlag, 0, BorderFlagEx);
if(!(m_HWnd = CreateWindowEx(BorderFlagEx, ClassName, m_Title, WS_CLIPSIBLINGS|WS_CLIPCHILDREN|BorderFlag, m_x, m_y, WndRect.right-WndRect.left, WndRect.bottom-WndRect.top, 0x0, 0x0, m_HInstance, 0x0))){
  MessageBox(0x0, "Error: 'CreateWindowEx'", "ERROR", MB_OK|MB_ICONINFORMATION);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, ColorBits, 0, 0, 0, 0, 0, 0, 0, 0, AccumBits, 0, 0, 0, 0, DepthBits, StencilBits, 0, 0, 0, 0, 0, 0};
if(!(m_HDc=GetDC(m_HWnd))){
  MessageBox(NULL, "Error: 'GetDC'", "ERROR", MB_OK|MB_ICONINFORMATION);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(PixelFormat=ChoosePixelFormat(m_HDc, &pfd))){
  MessageBox(NULL, "Error: 'ChoosePixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!SetPixelFormat(m_HDc, PixelFormat, &pfd)){
  MessageBox(NULL, "Error: 'SetPixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(m_HGlrc=wglCreateContext(m_HDc))){
  MessageBox(NULL, "Error: 'wglCreateContext'", "ERROR", MB_OK|MB_ICONINFORMATION);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
if(!(wglMakeCurrent(m_HDc, m_HGlrc))){
  MessageBox(NULL, "Error: 'wglMakeCurrent'", "ERROR", MB_OK|MB_ICONINFORMATION);
  wglDeleteContext(m_HGlrc);
  ReleaseDC(m_HWnd, m_HDc);
  DestroyWindow(m_HWnd);
  UnregisterClass(ClassName, m_HInstance);
  return 0;
}
SetForegroundWindow(m_HWnd);
SetFocus(m_HWnd);
return 1;
}

PARTNERS