Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include "Windows.h"
- #include <memory.h>
- #include "C:/Program Files/Microsoft Visual Studio 12.0/VC/include/GL/gl.h"
- #include"C:/Program Files/Microsoft Visual Studio 12.0/VC/include/GL/glu.h"
- #pragma comment(lib,"C:/lib/opengl32.lib")
- _declspec(dllexport)void initOpengl(
- int colorBits, int depthBits,
- float a,float b,float c,float d
- )
- {
- HGLRC hrc;
- GLuint pixelFormat;
- HWND hWnd = FindWindow(NULL, NULL);
- HWND hwnd = GetNextWindow(hWnd, GW_HWNDPREV);
- PIXELFORMATDESCRIPTOR pfd;
- pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
- pfd.nVersion = 1;
- pfd.dwFlags =
- PFD_DRAW_TO_WINDOW |
- PFD_SUPPORT_OPENGL |
- PFD_DOUBLEBUFFER;
- pfd.iPixelType =PFD_TYPE_RGBA;
- pfd.cColorBits = colorBits;
- pfd.cRedBits = 0;
- pfd.cRedShift = 0;
- pfd.cGreenBits = 0;
- pfd.cGreenShift = 0;
- pfd.cBlueBits = 0;
- pfd.cBlueShift = 0;
- pfd.cAlphaBits = 0;
- pfd.cAlphaShift = 0;
- pfd.cAccumBits = 0;
- pfd.cAccumRedBits = 0;
- pfd.cAccumGreenBits = 0;
- pfd.cAccumBlueBits = 0;
- pfd.cAccumAlphaBits = 0;
- pfd.cDepthBits = depthBits;
- pfd.cStencilBits = 0;
- pfd.cAuxBuffers = 0;
- pfd.iLayerType = PFD_MAIN_PLANE;
- pfd.bReserved = 0;
- pfd.dwLayerMask = 0;
- pfd.dwVisibleMask = 0;
- pfd.dwDamageMask = 0;
- if (false(pfd)){ MessageBox(hwnd, L"нет pixelformatdescriptor", L"нет pixelformatdescriptor", MB_OK); }
- HDC hdc = GetDC(hwnd);
- //if (!(GetDC(hwnd))){ MessageBox(hwnd, L"нет GetDC(hWnd)", L"нет GetDC(hWnd)", MB_OK); }
- //if (!hdc){ MessageBox(hwnd, L"нет hdc", L"нет hdc", MB_OK); }
- //if (hdc){ MessageBox(hWnd, L"есть hdc", L"есть hdc", MB_OK); }
- // MessageBox(hwnd, L"проверка", L"проверка", MB_OK);
- pixelFormat = ChoosePixelFormat(hdc, &pfd);
- if (!(ChoosePixelFormat(hdc, &pfd))){ MessageBox(hwnd, L"нет ChoosePixelFormat(hdc, &pfd)", L"нет ChoosePixelFormat(hdc, &pfd)", MB_OK); }
- SetPixelFormat(hdc, pixelFormat, &pfd);
- //if (!(SetPixelFormat(hdc, pixelFormat, &pfd))){ MessageBox(hwnd, L"нет SetPixelFormat(hdc, pixelFormat, &pfd)", L"нет SetPixelFormat(hdc, pixelFormat, &pfd)", MB_OK); }
- hrc = wglCreateContext(hdc);
- //if (!(wglCreateContext(hdc))){ MessageBox(hwnd, L"нет wglCreateContext(hdc)", L"нет wglCreateContext(hdc)", MB_OK); }
- wglMakeCurrent(hdc, hrc);
- if (!(wglMakeCurrent(hdc, hrc))){ MessageBox(hwnd, L"нет wglMakeCurrent(hdc,hrc)", L"нет wglMakeCurrent(hdc,hrc)", MB_OK); }
- //UpdateWindow(hwnd);
- glClearColor(a, b, c, d);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- SwapBuffers(hdc);
- }
- }
- #include <GL/gl.h>
- #include <GL/glu.h>
- HWND hWnd = FindWindow(NULL, NULL);
- HWND hwnd = GetNextWindow(hWnd, GW_HWNDPREV);
- HWND hwnd = имяОкна->GetSafeHwnd();
Add Comment
Please, Sign In to add comment