Guest User

Untitled

a guest
Aug 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. #include "Windows.h"
  4.  
  5.  
  6. #include <memory.h>
  7.  
  8. #include "C:/Program Files/Microsoft Visual Studio 12.0/VC/include/GL/gl.h"
  9. #include"C:/Program Files/Microsoft Visual Studio 12.0/VC/include/GL/glu.h"
  10. #pragma comment(lib,"C:/lib/opengl32.lib")
  11.  
  12.  
  13.  
  14. _declspec(dllexport)void initOpengl(
  15.  
  16. int colorBits, int depthBits,
  17. float a,float b,float c,float d
  18.  
  19.  
  20.  
  21. )
  22. {
  23.  
  24.  
  25. HGLRC hrc;
  26.  
  27.  
  28. GLuint pixelFormat;
  29. HWND hWnd = FindWindow(NULL, NULL);
  30. HWND hwnd = GetNextWindow(hWnd, GW_HWNDPREV);
  31.  
  32.  
  33. PIXELFORMATDESCRIPTOR pfd;
  34.  
  35. pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
  36. pfd.nVersion = 1;
  37. pfd.dwFlags =
  38. PFD_DRAW_TO_WINDOW |
  39. PFD_SUPPORT_OPENGL |
  40. PFD_DOUBLEBUFFER;
  41. pfd.iPixelType =PFD_TYPE_RGBA;
  42. pfd.cColorBits = colorBits;
  43. pfd.cRedBits = 0;
  44. pfd.cRedShift = 0;
  45. pfd.cGreenBits = 0;
  46. pfd.cGreenShift = 0;
  47. pfd.cBlueBits = 0;
  48. pfd.cBlueShift = 0;
  49. pfd.cAlphaBits = 0;
  50. pfd.cAlphaShift = 0;
  51. pfd.cAccumBits = 0;
  52. pfd.cAccumRedBits = 0;
  53. pfd.cAccumGreenBits = 0;
  54. pfd.cAccumBlueBits = 0;
  55. pfd.cAccumAlphaBits = 0;
  56. pfd.cDepthBits = depthBits;
  57. pfd.cStencilBits = 0;
  58. pfd.cAuxBuffers = 0;
  59. pfd.iLayerType = PFD_MAIN_PLANE;
  60. pfd.bReserved = 0;
  61. pfd.dwLayerMask = 0;
  62. pfd.dwVisibleMask = 0;
  63. pfd.dwDamageMask = 0;
  64.  
  65. if (false(pfd)){ MessageBox(hwnd, L"нет pixelformatdescriptor", L"нет pixelformatdescriptor", MB_OK); }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. HDC hdc = GetDC(hwnd);
  72.  
  73.  
  74. //if (!(GetDC(hwnd))){ MessageBox(hwnd, L"нет GetDC(hWnd)", L"нет GetDC(hWnd)", MB_OK); }
  75. //if (!hdc){ MessageBox(hwnd, L"нет hdc", L"нет hdc", MB_OK); }
  76. //if (hdc){ MessageBox(hWnd, L"есть hdc", L"есть hdc", MB_OK); }
  77. // MessageBox(hwnd, L"проверка", L"проверка", MB_OK);
  78. pixelFormat = ChoosePixelFormat(hdc, &pfd);
  79.  
  80. if (!(ChoosePixelFormat(hdc, &pfd))){ MessageBox(hwnd, L"нет ChoosePixelFormat(hdc, &pfd)", L"нет ChoosePixelFormat(hdc, &pfd)", MB_OK); }
  81. SetPixelFormat(hdc, pixelFormat, &pfd);
  82. //if (!(SetPixelFormat(hdc, pixelFormat, &pfd))){ MessageBox(hwnd, L"нет SetPixelFormat(hdc, pixelFormat, &pfd)", L"нет SetPixelFormat(hdc, pixelFormat, &pfd)", MB_OK); }
  83. hrc = wglCreateContext(hdc);
  84. //if (!(wglCreateContext(hdc))){ MessageBox(hwnd, L"нет wglCreateContext(hdc)", L"нет wglCreateContext(hdc)", MB_OK); }
  85. wglMakeCurrent(hdc, hrc);
  86. if (!(wglMakeCurrent(hdc, hrc))){ MessageBox(hwnd, L"нет wglMakeCurrent(hdc,hrc)", L"нет wglMakeCurrent(hdc,hrc)", MB_OK); }
  87. //UpdateWindow(hwnd);
  88.  
  89.  
  90. glClearColor(a, b, c, d);
  91. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  92.  
  93.  
  94. SwapBuffers(hdc);
  95.  
  96. }
  97. }
  98.  
  99. #include <GL/gl.h>
  100. #include <GL/glu.h>
  101.  
  102. HWND hWnd = FindWindow(NULL, NULL);
  103. HWND hwnd = GetNextWindow(hWnd, GW_HWNDPREV);
  104.  
  105. HWND hwnd = имяОкна->GetSafeHwnd();
Add Comment
Please, Sign In to add comment