/************************************************************* Create the geometry **************************************************************/ void MakeGeometry(void) { int i; double radius = 0.5; static double theta = 0; GLfloat mshin1[] = {5.0}; /* For the sphere */ GLfloat mspec1[] = {0.5,0.5,0.5,1.0}; GLfloat mdiff1[] = {0.6,0.0,0.6,1.0}; GLfloat mamb1[] = {0.1,0.0,0.1,1.0}; GLfloat mdiff2[] = {0.0,1.0,0.0,1.0}; /* Green plane */ GLfloat mamb2[] = {0.0,0.2,0.0,1.0}; drawAxises(500, 2.0); drawGrayBox(200); drawGrid(1000); drawSomething(); // yellow square drawSomething2(); // small purple square drawSomething3(); // two chads near the origin drawBresenhamCircle(); // drawDetector(); }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);//initialization of about box break; case IDM_INPUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_INPUT), hWnd, Input);//initialization of input box break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MOUSEMOVE: if ((wParam & MK_LBUTTON) | (wParam & MK_RBUTTON))//describing reaction to a click or a move of left and right mousebuttons and mouse { int x, y; HDC hDC; hDC = GetDC(hWnd); x = LOWORD(lParam); y = HIWORD(lParam); DWORD err; HINSTANCE hDll = LoadLibrary(L"Bresenham_circle.dll");//Loads library if (hDll != NULL)//sucessful loading { //MessageBox(NULL, L"Library was loaded", L"Не ошибка", MB_OK); } else { //error case err = GetLastError(); char buf[MAX_LOADSTRING]; wsprintf((LPWSTR)buf, L"%d", err); MessageBox(NULL, (LPWSTR)buf, L"ошибка", MB_OK); } TESTFUNCTION lpTestFunction; lpTestFunction = (TESTFUNCTION)GetProcAddress(hDll, "drawBresenhamCircle");//getting required fuction from the library if (lpTestFunction != NULL) { (*lpTestFunction) (hWnd, x, y, 100); } FreeLibrary(hDll); } break; case WM_MY_MSG: { int* ptr = (int*)wParam; //input box function drawBresenhamCircle(hWnd, ptr[0], ptr[1], ptr[2]); break; } case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }