1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include "test.h"
#pragma comment (lib, "Opengl32.lib")
#pragma comment (lib, "Glu32.lib")
#pragma comment (lib, "classtest.lib")
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void DrawGLScene(GLvoid);
HWND main;
test newtest;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszClassName = L"WindowClass";
RegisterClassEx(&wc);
main = CreateWindowEx(NULL,
L"WindowClass",
L"Editor",
WS_OVERLAPPEDWINDOW,
300, 300,
500, 500,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(main, nCmdShow);
int d=newtest.set();
if (d==10)
{
MessageBox(NULL,L"set working!",L"INFO",MB_OK|MB_ICONEXCLAMATION);
}
ShowWindow(main,SW_SHOW); // Show The Window
MSG msg;
while(TRUE)
{
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(msg.message == WM_QUIT)
break;
DrawGLScene();
}
return msg.wParam;
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
case WM_SIZING:
{
//if to comment this out-error is gone!
DrawGLScene();
} break;
case WM_SIZE:
{
//if to comment this out-error is gone!
DrawGLScene();
} break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
void DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
int c=newtest.take();
if (c==10)
{
MessageBox(NULL,L"take from gl working!",L"INFO",MB_OK|MB_ICONEXCLAMATION);
}
glFlush();
}
|