#include <windows.h>#include "shared.h"#include "vector.h"#include "vertex.h"#include "quat.h"#include "matrix.h"#include "texture.h"#include "general.h"#include "object.h"#include "camera.h"#include "polygon.h"#include "locmath.h"#include "console.h"#include "log.h"#include "mmgr.h"#include "resource.rh"Go to the source code of this file.
Compounds | |
| struct | CHILD |
Typedefs | |
| typedef CHILD | CHILD |
Functions | |
| void | SetTextures () |
| void | SetVertices () |
| void | SetPolygons () |
| void | InitGL () |
| void | Set3DProjection (int iWidth, int iHeight) |
| void | Set2DProjection (int iWidth, int iHeight) |
| void | Draw3DScene (void) |
| void | Draw2DSceneFront (HWND hWnd) |
| void | Draw2DSceneTop (HWND hWnd) |
| void | Draw2DSceneLeft (HWND hWnd) |
| LRESULT CALLBACK | WndProc (HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) |
| LRESULT CALLBACK | Child3DWndProc (HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) |
| void | DrawWin32Text (HDC hDC, int right, int bottom, int x, int y) |
| LRESULT CALLBACK | Child2DWndProc (HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) |
| int WINAPI | WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) |
Variables | |
| float | pi = 3.141592 |
| float | radians = pi / 180 |
| COLORREF | colorRGB |
| RECT | MainRect |
| LOGFONT | LogFont |
| HFONT | hFont |
| HFONT | hOldFont |
| TEXTURE * | texture = new TEXTURE[1] |
| VERTEX * | vertex = new VERTEX[8] |
| POLYGON * | polygon = new POLYGON[12] |
| char | g_szMainClassName [] = "MainWindow" |
| char | g_szChild3DClassName [] = "3DOpenGL" |
| char | g_szChild2DClassName [] = "2DOpenGL" |
| HINSTANCE | g_hInst |
| HWND | g_hMDIClient |
| HWND | g_hMainWindow |
| RECT | g_rectChild |
| float | g_fCubeRotationX |
| float | g_fCubeRotationY |
| float | Zoom = 0.025 |
| bool | key [256] |
| bool | released_key [256] |
| int | VerticalShift = 0 |
| int | HorizontalShift = 0 |
| bool | g_bMouseDrag = 0 |
| int | g_iMouseLastX |
| int | g_iMouseLastY |
| int | g_iMouseDeltaX |
| int | g_iMouseDeltaY |
| int | VertexNumber |
| int | ShortestDistance = 10000 |
| int | MouseX |
| int | MouseY |
| float | FrontDepth = 90 |
| float | TopDepth = -90 |
| float | LeftDepth = -90 |
| GLUquadricObj * | sphere = gluNewQuadric() |
| bool | g_bMouseDrag2 = 0 |
| int | g_iMouseLastX2 |
| int | g_iMouseLastY2 |
| int | g_iMouseDeltaX2 |
| int | g_iMouseDeltaY2 |
| int | g_iMaxChild = 50 |
| int | g_iNumChild = 0 |
| CHILD * | g_child = new CHILD[g_iMaxChild] |
|
|
|
|
||||||||||||||||||||
|
Definition at line 1300 of file Oglmdi2.cpp. References FALSE, FrontDepth, g_bMouseDrag2, g_hMainWindow, g_iMouseDeltaX2, g_iMouseDeltaY2, g_iMouseLastX2, g_iMouseLastY2, g_iNumChild, CHILD::iType, key, LeftDepth, MouseX, MouseY, SetPolygons(), ShortestDistance, TopDepth, TRUE, VertexNumber, VERTEX::x, VERTEX::y, and VERTEX::z. Referenced by WinMain().
01301 {
01302 switch(uMessage)
01303 {
01304 case WM_SIZE:
01305 {
01306 if(wParam != SIZE_MINIMIZED)
01307 {
01308 RECT WindowRect;
01309 GetClientRect(hWnd, &WindowRect);
01310 int iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01311 if(g_child[iThisChild].iType == 2)
01312 {
01313 TopDepth = -0.5 * WindowRect.bottom + 10;
01314 LeftDepth = -0.5 * WindowRect.right + 10;
01315 }
01316 if(g_child[iThisChild].iType == 3)
01317 {
01318 FrontDepth = 0.5 * WindowRect.bottom - 10;
01319 LeftDepth = -0.5 * WindowRect.right + 10;
01320 }
01321 if(g_child[iThisChild].iType == 4)
01322 {
01323 FrontDepth = -0.5 * WindowRect.right + 10;
01324 TopDepth = -0.5 * WindowRect.bottom + 10;
01325 }
01326 }
01327 }
01328 break;
01329
01330 case WM_KEYDOWN:
01331 key[wParam] = TRUE;
01332 break;
01333
01334 case WM_KEYUP:
01335 key[wParam] = FALSE;
01336 break;
01337
01338 case WM_LBUTTONDOWN:
01339 g_bMouseDrag2 = 1; // Set mouse flag
01340 g_iMouseLastX2 = LOWORD(lParam); // Get mouse position
01341 g_iMouseLastY2 = HIWORD(lParam);
01342 SetCapture(hWnd); // Capture the mouse
01343 break;
01344
01345 case WM_LBUTTONUP:
01346 g_bMouseDrag2 = 0; // Clear mouse flag
01347 ReleaseCapture(); // Release the mouse capture
01348 break;
01349
01350 case WM_MOUSEMOVE:
01351 {
01352 RECT WindowRect;
01353 GetClientRect(hWnd, &WindowRect);
01354 MouseX = LOWORD(lParam);
01355 MouseY = HIWORD(lParam);
01356 int iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01357 if(g_bMouseDrag2) // If mouse flag set
01358 {
01359 if (MouseX < WindowRect.left || MouseX > WindowRect.right)
01360 {
01361 MouseX = g_iMouseLastX2;
01362 }
01363 if (MouseY < WindowRect.top || MouseY > WindowRect.bottom)
01364 {
01365 MouseY = g_iMouseLastY2;
01366 }
01367 g_iMouseDeltaX2 = MouseX - g_iMouseLastX2; // Get mouse deltas
01368 g_iMouseDeltaY2 = MouseY - g_iMouseLastY2;
01369 g_iMouseLastX2 = MouseX; // Get new mouse position
01370 g_iMouseLastY2 = MouseY;
01371 if(g_child[iThisChild].iType == 2)
01372 {
01373 vertex[VertexNumber].x += (float)g_iMouseDeltaX2 * 1.0; // Apply mouse deltas to cube rotation values
01374 vertex[VertexNumber].y -= (float)g_iMouseDeltaY2 * 1.0;
01375 }
01376 if(g_child[iThisChild].iType == 3)
01377 {
01378 vertex[VertexNumber].x += (float)g_iMouseDeltaX2 * 1.0; // Apply mouse deltas to cube rotation values
01379 vertex[VertexNumber].z += (float)g_iMouseDeltaY2 * 1.0;
01380 }
01381 if(g_child[iThisChild].iType == 4)
01382 {
01383 vertex[VertexNumber].z += (float)g_iMouseDeltaX2 * 1.0; // Apply mouse deltas to cube rotation values
01384 vertex[VertexNumber].y -= (float)g_iMouseDeltaY2 * 1.0;
01385 }
01386 SetPolygons();
01387 }
01388
01389 if(!g_bMouseDrag2)
01390 {
01391 MouseX = (int)(LOWORD(lParam) + (-0.5 * WindowRect.right));
01392 if(g_child[iThisChild].iType == 3)
01393 MouseY = (int)(HIWORD(lParam) + (-0.5 * WindowRect.bottom));
01394 else
01395 MouseY = (int)(-1 * (HIWORD(lParam) + (-0.5 * WindowRect.bottom)));
01396 ShortestDistance = 10000;
01397 int Loop;
01398 int TempX;
01399 int TempY;
01400 for(Loop = 0; Loop < 8; Loop++)
01401 {
01402 iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01403 if(g_child[iThisChild].iType == 2)
01404 {
01405 TempX = (int)(MouseX - vertex[Loop].x);
01406 TempY = (int)(MouseY - vertex[Loop].y);
01407 }
01408 if(g_child[iThisChild].iType == 3)
01409 {
01410 TempX = (int)(MouseX - vertex[Loop].x);
01411 TempY = (int)(MouseY - vertex[Loop].z);
01412 }
01413 if(g_child[iThisChild].iType == 4)
01414 {
01415 TempX = (int)(MouseX - vertex[Loop].z);
01416 TempY = (int)(MouseY - vertex[Loop].y);
01417 }
01418 if(sqrt((TempX * TempX) + (TempY * TempY)) < ShortestDistance)
01419 {
01420 ShortestDistance = (int)(sqrt((TempX * TempX) + (TempY * TempY)));
01421 VertexNumber = Loop;
01422 }
01423 }
01424
01425 //int iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01426 //DrawWin32Text(g_child[iThisChild].hDC, WindowRect.right, WindowRect.bottom, 1, 1);
01427 }
01428 }
01429 break;
01430
01431 case WM_CLOSE:
01432 g_iNumChild--; // Decrement the number of child windows
01433 if(g_iNumChild == 0) // If this is the last child window then just free the DC and RC
01434 {
01435 wglMakeCurrent( NULL, NULL );
01436 ReleaseDC(g_child[0].hWnd, g_child[0].hDC);
01437 wglDeleteContext(g_child[0].hRC);
01438 }
01439 else
01440 {
01441 int iLoop;
01442 int iThisChild;
01443 char szWindowTitle[20];
01444 iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01445 ReleaseDC(g_child[iThisChild].hWnd, g_child[iThisChild].hDC); // Free this childs DC and RC
01446 wglDeleteContext(g_child[iThisChild].hRC);
01447 if(iThisChild != g_iNumChild) // If this child isn't the last in the array of children
01448 {
01449 for (iLoop = iThisChild; iLoop < (g_iNumChild); iLoop++) // Loop from this child to the end of the array
01450 {
01451 g_child[iLoop] = g_child[iLoop + 1]; // Shift the children forward in the array
01452 sprintf(szWindowTitle, "%d", iLoop);
01453 SetWindowText(g_child[iLoop].hWnd, szWindowTitle); // Renumber the children
01454 }
01455 }
01456 }
01457 break;
01458
01459 case WM_MDIACTIVATE:
01460 {
01461 HMENU hMenu, hFileMenu;
01462 UINT uEnableFlag;
01463
01464 hMenu = GetMenu(g_hMainWindow);
01465 if(hWnd == (HWND)lParam) //being activated
01466 {
01467 uEnableFlag = MF_ENABLED;
01468 }
01469 else
01470 {
01471 uEnableFlag = MF_GRAYED; //being de-activated
01472 }
01473 EnableMenuItem(hMenu, 1, MF_BYPOSITION | uEnableFlag);
01474 EnableMenuItem(hMenu, 2, MF_BYPOSITION | uEnableFlag);
01475
01476 hFileMenu = GetSubMenu(hMenu, 0);
01477 EnableMenuItem(hFileMenu, CM_FILE_SAVE, MF_BYCOMMAND | uEnableFlag);
01478 EnableMenuItem(hFileMenu, CM_FILE_SAVEAS, MF_BYCOMMAND | uEnableFlag);
01479
01480 DrawMenuBar(g_hMainWindow);
01481 }
01482 break;
01483
01484 case WM_COMMAND:
01485 switch(LOWORD(wParam))
01486 {
01487 // case CM_FILE_SAVE: etc
01488 }
01489 return 0;
01490 }
01491 return DefMDIChildProc(hWnd, uMessage, wParam, lParam);
01492 }
|
|
||||||||||||||||||||
|
Definition at line 1131 of file Oglmdi2.cpp. References FALSE, g_bMouseDrag, g_hMainWindow, g_iMouseDeltaX, g_iMouseDeltaY, g_iMouseLastX, g_iMouseLastY, g_iNumChild, key, and TRUE. Referenced by WinMain().
01132 {
01133 switch(uMessage)
01134 {
01135 case WM_KEYDOWN:
01136 key[wParam] = TRUE;
01137 break;
01138
01139 case WM_KEYUP:
01140 key[wParam] = FALSE;
01141 break;
01142 case WM_LBUTTONDOWN:
01143 g_bMouseDrag = 1; // Set mouse flag
01144 g_iMouseLastX = LOWORD(lParam); // Get mouse position
01145 g_iMouseLastY = HIWORD(lParam);
01146 SetCapture(hWnd); // Capture the mouse
01147 break;
01148
01149 case WM_MOUSEMOVE:
01150 if(g_bMouseDrag) // If mouse flag set
01151 {
01152 g_iMouseDeltaX = LOWORD(lParam) - g_iMouseLastX; // Get mouse deltas
01153 g_iMouseDeltaY = HIWORD(lParam) - g_iMouseLastY;
01154 g_iMouseLastX = LOWORD(lParam); // Get new mouse position
01155 g_iMouseLastY = HIWORD(lParam);
01156 }
01157 break;
01158
01159 case WM_LBUTTONUP:
01160 g_bMouseDrag = 0; // Clear mouse flag
01161 ReleaseCapture(); // Release the mouse capture
01162 break;
01163
01164 /*
01165 //This msg isn't posted if the mouse is captured
01166 case WM_NCMOUSEMOVE:
01167 {
01168 POINTS pts;
01169 if(g_bMouseDrag)
01170 {
01171 pts = MAKEPOINTS(lParam);
01172 g_iMouseDeltaX = pts.x - g_iMouseLastX;
01173 g_iMouseDeltaY = pts.y - g_iMouseLastY;
01174 g_iMouseLastX = pts.x;
01175 g_iMouseLastY = pts.y;
01176 }
01177 }
01178 break;
01179 //*/
01180
01181 /* The following code paints the child window when necessary but isn't needed as we
01182 repaint all of them each frame. */
01183
01184 /*
01185 case WM_PAINT:
01186 {
01187 int iThisChild;
01188 PAINTSTRUCT ps;
01189 BeginPaint(hWnd, &ps);
01190 iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01191 wglMakeCurrent(g_child[iThisChild].hDC, g_child[iThisChild].hRC);
01192 GetClientRect(hWnd, &g_rectChild);
01193 if(g_rectChild.right > 0 && g_rectChild.bottom > 0)
01194 SetProjection(g_rectChild.right, g_rectChild.bottom);
01195 DrawGLScene();
01196 glFlush();
01197 SwapBuffers(hDC);
01198 EndPaint(hWnd, &ps);
01199 }
01200 break;
01201 //*/
01202 case WM_CLOSE:
01203 g_iNumChild--; // Decrement the number of child windows
01204 if(g_iNumChild == 0) // If this is the last child window then just free the DC and RC
01205 {
01206 wglMakeCurrent( NULL, NULL );
01207 ReleaseDC(g_child[0].hWnd, g_child[0].hDC);
01208 wglDeleteContext(g_child[0].hRC);
01209 }
01210 else
01211 {
01212 int iLoop;
01213 int iThisChild;
01214 char szWindowTitle[20];
01215 iThisChild = GetDlgCtrlID(hWnd) - ID_MDI_FIRSTCHILD;
01216 ReleaseDC(g_child[iThisChild].hWnd, g_child[iThisChild].hDC); // Free this childs DC and RC
01217 wglDeleteContext(g_child[iThisChild].hRC);
01218 if(iThisChild != g_iNumChild) // If this child isn't the last in the array of children
01219 {
01220 for (iLoop = iThisChild; iLoop < (g_iNumChild); iLoop++) // Loop from this child to the end of the array
01221 {
01222 g_child[iLoop] = g_child[iLoop + 1]; // Shift the children forward in the array
01223 sprintf(szWindowTitle, "%d", iLoop);
01224 SetWindowText(g_child[iLoop].hWnd, szWindowTitle); // Renumber the children
01225 }
01226 }
01227 }
01228 break;
01229
01230 case WM_MDIACTIVATE:
01231 {
01232 HMENU hMenu, hFileMenu;
01233 UINT uEnableFlag;
01234
01235 hMenu = GetMenu(g_hMainWindow);
01236 if(hWnd == (HWND)lParam) //being activated
01237 {
01238 uEnableFlag = MF_ENABLED;
01239 }
01240 else
01241 {
01242 uEnableFlag = MF_GRAYED; //being de-activated
01243 }
01244 EnableMenuItem(hMenu, 1, MF_BYPOSITION | uEnableFlag);
01245 EnableMenuItem(hMenu, 2, MF_BYPOSITION | uEnableFlag);
01246
01247 hFileMenu = GetSubMenu(hMenu, 0);
01248 EnableMenuItem(hFileMenu, CM_FILE_SAVE, MF_BYCOMMAND | uEnableFlag);
01249 EnableMenuItem(hFileMenu, CM_FILE_SAVEAS, MF_BYCOMMAND | uEnableFlag);
01250
01251 DrawMenuBar(g_hMainWindow);
01252 }
01253 break;
01254
01255 case WM_COMMAND:
01256 switch(LOWORD(wParam))
01257 {
01258 // case CM_FILE_SAVE: etc
01259 }
01260 return 0;
01261 }
01262 return DefMDIChildProc(hWnd, uMessage, wParam, lParam);
01263 }
|
|
|
Definition at line 346 of file Oglmdi2.cpp. References sphere, and VertexNumber. Referenced by WinMain().
00347 {
00348 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00349 glMatrixMode(GL_MODELVIEW);
00350 glLoadIdentity();
00351 RECT WindowRect;
00352 GetClientRect(hWnd, &WindowRect);
00353 /*
00354 glDisable(GL_TEXTURE_2D);
00355 glDisable(GL_LIGHTING);
00356 glColor4f(0.0, 1.0, 0.0, 1.0);
00357 glPushMatrix();
00358 glBegin(GL_LINES);
00359 glVertex3f(-0.5 * WindowRect.right, TopDepth, 0);
00360 glVertex3f(0.5 * WindowRect.right, TopDepth, 0);
00361 glEnd();
00362 glPopMatrix();
00363 glEnable(GL_LIGHTING);
00364 glEnable(GL_TEXTURE_2D);
00365
00366 glDisable(GL_TEXTURE_2D);
00367 glDisable(GL_LIGHTING);
00368 glColor4f(0.0, 0.0, 1.0, 1.0);
00369 glPushMatrix();
00370 glBegin(GL_LINES);
00371 glVertex3f(LeftDepth, 0.5 * WindowRect.bottom, 0);
00372 glVertex3f(LeftDepth, -0.5 * WindowRect.bottom, 0);
00373 glEnd();
00374 glPopMatrix();
00375 glEnable(GL_LIGHTING);
00376 glEnable(GL_TEXTURE_2D);
00377 */
00378 glDisable(GL_TEXTURE_2D);
00379 glDisable(GL_LIGHTING);
00380 glColor4f(1.0, 0.0, 0.0, 1.0);
00381 glPushMatrix();
00382 glBegin(GL_LINES);
00383 // Front Face
00384 glNormal3fv(&polygon[0].Vertex[0].nx);
00385 glVertex3fv(&polygon[0].Vertex[0].x);
00386 glVertex3fv(&polygon[0].Vertex[1].x);
00387 glVertex3fv(&polygon[0].Vertex[1].x);
00388 glVertex3fv(&polygon[0].Vertex[2].x);
00389 glVertex3fv(&polygon[0].Vertex[2].x);
00390 glVertex3fv(&polygon[0].Vertex[0].x);
00391
00392 glVertex3fv(&polygon[1].Vertex[0].x);
00393 glVertex3fv(&polygon[1].Vertex[1].x);
00394 glVertex3fv(&polygon[1].Vertex[1].x);
00395 glVertex3fv(&polygon[1].Vertex[2].x);
00396 glVertex3fv(&polygon[1].Vertex[2].x);
00397 glVertex3fv(&polygon[1].Vertex[0].x);
00398 // Back Face
00399 glNormal3fv(&polygon[2].Vertex[0].nx);
00400 glVertex3fv(&polygon[2].Vertex[0].x);
00401 glVertex3fv(&polygon[2].Vertex[1].x);
00402 glVertex3fv(&polygon[2].Vertex[1].x);
00403 glVertex3fv(&polygon[2].Vertex[2].x);
00404 glVertex3fv(&polygon[2].Vertex[2].x);
00405 glVertex3fv(&polygon[2].Vertex[0].x);
00406
00407 glVertex3fv(&polygon[3].Vertex[0].x);
00408 glVertex3fv(&polygon[3].Vertex[1].x);
00409 glVertex3fv(&polygon[3].Vertex[1].x);
00410 glVertex3fv(&polygon[3].Vertex[2].x);
00411 glVertex3fv(&polygon[3].Vertex[2].x);
00412 glVertex3fv(&polygon[3].Vertex[0].x);
00413 // Top Face
00414 glNormal3fv(&polygon[4].Vertex[0].nx);
00415 glVertex3fv(&polygon[4].Vertex[0].x);
00416 glVertex3fv(&polygon[4].Vertex[1].x);
00417 glVertex3fv(&polygon[4].Vertex[1].x);
00418 glVertex3fv(&polygon[4].Vertex[2].x);
00419 glVertex3fv(&polygon[4].Vertex[2].x);
00420 glVertex3fv(&polygon[4].Vertex[0].x);
00421
00422 glVertex3fv(&polygon[5].Vertex[0].x);
00423 glVertex3fv(&polygon[5].Vertex[1].x);
00424 glVertex3fv(&polygon[5].Vertex[1].x);
00425 glVertex3fv(&polygon[5].Vertex[2].x);
00426 glVertex3fv(&polygon[5].Vertex[2].x);
00427 glVertex3fv(&polygon[5].Vertex[0].x);
00428 // Bottom Face
00429 glNormal3fv(&polygon[6].Vertex[0].nx);
00430 glVertex3fv(&polygon[6].Vertex[0].x);
00431 glVertex3fv(&polygon[6].Vertex[1].x);
00432 glVertex3fv(&polygon[6].Vertex[1].x);
00433 glVertex3fv(&polygon[6].Vertex[2].x);
00434 glVertex3fv(&polygon[6].Vertex[2].x);
00435 glVertex3fv(&polygon[6].Vertex[0].x);
00436
00437 glVertex3fv(&polygon[7].Vertex[0].x);
00438 glVertex3fv(&polygon[7].Vertex[1].x);
00439 glVertex3fv(&polygon[7].Vertex[1].x);
00440 glVertex3fv(&polygon[7].Vertex[2].x);
00441 glVertex3fv(&polygon[7].Vertex[2].x);
00442 glVertex3fv(&polygon[7].Vertex[0].x);
00443 // Right face
00444 glNormal3fv(&polygon[8].Vertex[0].nx);
00445 glVertex3fv(&polygon[8].Vertex[0].x);
00446 glVertex3fv(&polygon[8].Vertex[1].x);
00447 glVertex3fv(&polygon[8].Vertex[1].x);
00448 glVertex3fv(&polygon[8].Vertex[2].x);
00449 glVertex3fv(&polygon[8].Vertex[2].x);
00450 glVertex3fv(&polygon[8].Vertex[0].x);
00451
00452 glVertex3fv(&polygon[9].Vertex[0].x);
00453 glVertex3fv(&polygon[9].Vertex[1].x);
00454 glVertex3fv(&polygon[9].Vertex[1].x);
00455 glVertex3fv(&polygon[9].Vertex[2].x);
00456 glVertex3fv(&polygon[9].Vertex[2].x);
00457 glVertex3fv(&polygon[9].Vertex[0].x);
00458 // Left Face
00459 glNormal3fv(&polygon[10].Vertex[0].nx);
00460 glVertex3fv(&polygon[10].Vertex[0].x);
00461 glVertex3fv(&polygon[10].Vertex[1].x);
00462 glVertex3fv(&polygon[10].Vertex[1].x);
00463 glVertex3fv(&polygon[10].Vertex[2].x);
00464 glVertex3fv(&polygon[10].Vertex[2].x);
00465 glVertex3fv(&polygon[10].Vertex[0].x);
00466
00467 glVertex3fv(&polygon[11].Vertex[0].x);
00468 glVertex3fv(&polygon[11].Vertex[1].x);
00469 glVertex3fv(&polygon[11].Vertex[1].x);
00470 glVertex3fv(&polygon[11].Vertex[2].x);
00471 glVertex3fv(&polygon[11].Vertex[2].x);
00472 glVertex3fv(&polygon[11].Vertex[0].x);
00473 glEnd();
00474 glPopMatrix();
00475 glEnable(GL_LIGHTING);
00476 glEnable(GL_TEXTURE_2D);
00477
00478 float mat_ambient[] = { 0.8, 0.5, 0.1, 1.0 };
00479 float mat_diffuse[] = { 0.8, 0.5, 0.1, 1.0 };
00480 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
00481 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
00482 glDisable(GL_TEXTURE_2D);
00483 glPushMatrix();
00484 glTranslatef(vertex[VertexNumber].x, vertex[VertexNumber].y, vertex[VertexNumber].z);
00485 gluQuadricOrientation(sphere, GLU_OUTSIDE);
00486 gluSphere(sphere,10.0,20,20);
00487 glPopMatrix();
00488 glEnable(GL_TEXTURE_2D);
00489
00490 }
|
|
|
Definition at line 639 of file Oglmdi2.cpp. References sphere, and VertexNumber. Referenced by WinMain().
00640 {
00641 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00642 glMatrixMode(GL_MODELVIEW);
00643 glLoadIdentity();
00644 glRotatef(90, 0, 1, 0);
00645 RECT WindowRect;
00646 GetClientRect(hWnd, &WindowRect);
00647 /*
00648 glDisable(GL_TEXTURE_2D);
00649 glDisable(GL_LIGHTING);
00650 glColor4f(1.0, 0.0, 0.0, 1.0);
00651 glPushMatrix();
00652 glBegin(GL_LINES);
00653 glVertex3f(0, -0.5 * WindowRect.bottom, FrontDepth);
00654 glVertex3f(0, 0.5 * WindowRect.bottom, FrontDepth);
00655 glEnd();
00656 glPopMatrix();
00657 glEnable(GL_LIGHTING);
00658 glEnable(GL_TEXTURE_2D);
00659
00660 glDisable(GL_TEXTURE_2D);
00661 glDisable(GL_LIGHTING);
00662 glColor4f(0.0, 1.0, 0.0, 1.0);
00663 glPushMatrix();
00664 glBegin(GL_LINES);
00665 glVertex3f(0, TopDepth, -0.5 * WindowRect.right);
00666 glVertex3f(0, TopDepth, 0.5 * WindowRect.right);
00667 glEnd();
00668 glPopMatrix();
00669 glEnable(GL_LIGHTING);
00670 glEnable(GL_TEXTURE_2D);
00671 */
00672 glDisable(GL_TEXTURE_2D);
00673 glDisable(GL_LIGHTING);
00674 glColor4f(0.0, 0.0, 1.0, 1.0);
00675 glPushMatrix();
00676 glBegin(GL_LINES);
00677 // Front Face
00678 glNormal3fv(&polygon[0].Vertex[0].nx);
00679 glVertex3fv(&polygon[0].Vertex[0].x);
00680 glVertex3fv(&polygon[0].Vertex[1].x);
00681 glVertex3fv(&polygon[0].Vertex[1].x);
00682 glVertex3fv(&polygon[0].Vertex[2].x);
00683 glVertex3fv(&polygon[0].Vertex[2].x);
00684 glVertex3fv(&polygon[0].Vertex[0].x);
00685
00686 glVertex3fv(&polygon[1].Vertex[0].x);
00687 glVertex3fv(&polygon[1].Vertex[1].x);
00688 glVertex3fv(&polygon[1].Vertex[1].x);
00689 glVertex3fv(&polygon[1].Vertex[2].x);
00690 glVertex3fv(&polygon[1].Vertex[2].x);
00691 glVertex3fv(&polygon[1].Vertex[0].x);
00692 // Back Face
00693 glNormal3fv(&polygon[2].Vertex[0].nx);
00694 glVertex3fv(&polygon[2].Vertex[0].x);
00695 glVertex3fv(&polygon[2].Vertex[1].x);
00696 glVertex3fv(&polygon[2].Vertex[1].x);
00697 glVertex3fv(&polygon[2].Vertex[2].x);
00698 glVertex3fv(&polygon[2].Vertex[2].x);
00699 glVertex3fv(&polygon[2].Vertex[0].x);
00700
00701 glVertex3fv(&polygon[3].Vertex[0].x);
00702 glVertex3fv(&polygon[3].Vertex[1].x);
00703 glVertex3fv(&polygon[3].Vertex[1].x);
00704 glVertex3fv(&polygon[3].Vertex[2].x);
00705 glVertex3fv(&polygon[3].Vertex[2].x);
00706 glVertex3fv(&polygon[3].Vertex[0].x);
00707 // Top Face
00708 glNormal3fv(&polygon[4].Vertex[0].nx);
00709 glVertex3fv(&polygon[4].Vertex[0].x);
00710 glVertex3fv(&polygon[4].Vertex[1].x);
00711 glVertex3fv(&polygon[4].Vertex[1].x);
00712 glVertex3fv(&polygon[4].Vertex[2].x);
00713 glVertex3fv(&polygon[4].Vertex[2].x);
00714 glVertex3fv(&polygon[4].Vertex[0].x);
00715
00716 glVertex3fv(&polygon[5].Vertex[0].x);
00717 glVertex3fv(&polygon[5].Vertex[1].x);
00718 glVertex3fv(&polygon[5].Vertex[1].x);
00719 glVertex3fv(&polygon[5].Vertex[2].x);
00720 glVertex3fv(&polygon[5].Vertex[2].x);
00721 glVertex3fv(&polygon[5].Vertex[0].x);
00722 // Bottom Face
00723 glNormal3fv(&polygon[6].Vertex[0].nx);
00724 glVertex3fv(&polygon[6].Vertex[0].x);
00725 glVertex3fv(&polygon[6].Vertex[1].x);
00726 glVertex3fv(&polygon[6].Vertex[1].x);
00727 glVertex3fv(&polygon[6].Vertex[2].x);
00728 glVertex3fv(&polygon[6].Vertex[2].x);
00729 glVertex3fv(&polygon[6].Vertex[0].x);
00730
00731 glVertex3fv(&polygon[7].Vertex[0].x);
00732 glVertex3fv(&polygon[7].Vertex[1].x);
00733 glVertex3fv(&polygon[7].Vertex[1].x);
00734 glVertex3fv(&polygon[7].Vertex[2].x);
00735 glVertex3fv(&polygon[7].Vertex[2].x);
00736 glVertex3fv(&polygon[7].Vertex[0].x);
00737 // Right face
00738 glNormal3fv(&polygon[8].Vertex[0].nx);
00739 glVertex3fv(&polygon[8].Vertex[0].x);
00740 glVertex3fv(&polygon[8].Vertex[1].x);
00741 glVertex3fv(&polygon[8].Vertex[1].x);
00742 glVertex3fv(&polygon[8].Vertex[2].x);
00743 glVertex3fv(&polygon[8].Vertex[2].x);
00744 glVertex3fv(&polygon[8].Vertex[0].x);
00745
00746 glVertex3fv(&polygon[9].Vertex[0].x);
00747 glVertex3fv(&polygon[9].Vertex[1].x);
00748 glVertex3fv(&polygon[9].Vertex[1].x);
00749 glVertex3fv(&polygon[9].Vertex[2].x);
00750 glVertex3fv(&polygon[9].Vertex[2].x);
00751 glVertex3fv(&polygon[9].Vertex[0].x);
00752 // Left Face
00753 glNormal3fv(&polygon[10].Vertex[0].nx);
00754 glVertex3fv(&polygon[10].Vertex[0].x);
00755 glVertex3fv(&polygon[10].Vertex[1].x);
00756 glVertex3fv(&polygon[10].Vertex[1].x);
00757 glVertex3fv(&polygon[10].Vertex[2].x);
00758 glVertex3fv(&polygon[10].Vertex[2].x);
00759 glVertex3fv(&polygon[10].Vertex[0].x);
00760
00761 glVertex3fv(&polygon[11].Vertex[0].x);
00762 glVertex3fv(&polygon[11].Vertex[1].x);
00763 glVertex3fv(&polygon[11].Vertex[1].x);
00764 glVertex3fv(&polygon[11].Vertex[2].x);
00765 glVertex3fv(&polygon[11].Vertex[2].x);
00766 glVertex3fv(&polygon[11].Vertex[0].x);
00767 glEnd();
00768 glPopMatrix();
00769 glEnable(GL_LIGHTING);
00770 glEnable(GL_TEXTURE_2D);
00771
00772 float mat_ambient[] = { 0.8, 0.5, 0.1, 1.0 };
00773 float mat_diffuse[] = { 0.8, 0.5, 0.1, 1.0 };
00774 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
00775 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
00776 glDisable(GL_TEXTURE_2D);
00777 glPushMatrix();
00778 glTranslatef(vertex[VertexNumber].x, vertex[VertexNumber].y, vertex[VertexNumber].z);
00779 gluQuadricOrientation(sphere, GLU_OUTSIDE);
00780 gluSphere(sphere,10.0,20,20);
00781 glPopMatrix();
00782 glEnable(GL_TEXTURE_2D);
00783
00784 }
|
|
|
Definition at line 492 of file Oglmdi2.cpp. References sphere, and VertexNumber. Referenced by WinMain().
00493 {
00494 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00495 glMatrixMode(GL_MODELVIEW);
00496 glLoadIdentity();
00497 glRotatef(90, 1, 0, 0);
00498 RECT WindowRect;
00499 GetClientRect(hWnd, &WindowRect);
00500 /*
00501 glDisable(GL_TEXTURE_2D);
00502 glDisable(GL_LIGHTING);
00503 glColor4f(1.0, 0.0, 0.0, 1.0);
00504 glPushMatrix();
00505 glBegin(GL_LINES);
00506 glVertex3f(-0.5 * WindowRect.right, 0, FrontDepth);
00507 glVertex3f(0.5 * WindowRect.right, 0, FrontDepth);
00508 glEnd();
00509 glPopMatrix();
00510 glEnable(GL_LIGHTING);
00511 glEnable(GL_TEXTURE_2D);
00512
00513 glDisable(GL_TEXTURE_2D);
00514 glDisable(GL_LIGHTING);
00515 glColor4f(0.0, 0.0, 1.0, 1.0);
00516 glPushMatrix();
00517 glBegin(GL_LINES);
00518 glVertex3f(LeftDepth, 0, 0.5 * WindowRect.bottom);
00519 glVertex3f(LeftDepth, 0, -0.5 * WindowRect.bottom);
00520 glEnd();
00521 glPopMatrix();
00522 glEnable(GL_LIGHTING);
00523 glEnable(GL_TEXTURE_2D);
00524 */
00525 glDisable(GL_TEXTURE_2D);
00526 glDisable(GL_LIGHTING);
00527 glColor4f(0.0, 1.0, 0.0, 1.0);
00528 glPushMatrix();
00529 glBegin(GL_LINES);
00530 // Front Face
00531 glNormal3fv(&polygon[0].Vertex[0].nx);
00532 glVertex3fv(&polygon[0].Vertex[0].x);
00533 glVertex3fv(&polygon[0].Vertex[1].x);
00534 glVertex3fv(&polygon[0].Vertex[1].x);
00535 glVertex3fv(&polygon[0].Vertex[2].x);
00536 glVertex3fv(&polygon[0].Vertex[2].x);
00537 glVertex3fv(&polygon[0].Vertex[0].x);
00538
00539 glVertex3fv(&polygon[1].Vertex[0].x);
00540 glVertex3fv(&polygon[1].Vertex[1].x);
00541 glVertex3fv(&polygon[1].Vertex[1].x);
00542 glVertex3fv(&polygon[1].Vertex[2].x);
00543 glVertex3fv(&polygon[1].Vertex[2].x);
00544 glVertex3fv(&polygon[1].Vertex[0].x);
00545 // Back Face
00546 glNormal3fv(&polygon[2].Vertex[0].nx);
00547 glVertex3fv(&polygon[2].Vertex[0].x);
00548 glVertex3fv(&polygon[2].Vertex[1].x);
00549 glVertex3fv(&polygon[2].Vertex[1].x);
00550 glVertex3fv(&polygon[2].Vertex[2].x);
00551 glVertex3fv(&polygon[2].Vertex[2].x);
00552 glVertex3fv(&polygon[2].Vertex[0].x);
00553
00554 glVertex3fv(&polygon[3].Vertex[0].x);
00555 glVertex3fv(&polygon[3].Vertex[1].x);
00556 glVertex3fv(&polygon[3].Vertex[1].x);
00557 glVertex3fv(&polygon[3].Vertex[2].x);
00558 glVertex3fv(&polygon[3].Vertex[2].x);
00559 glVertex3fv(&polygon[3].Vertex[0].x);
00560 // Top Face
00561 glNormal3fv(&polygon[4].Vertex[0].nx);
00562 glVertex3fv(&polygon[4].Vertex[0].x);
00563 glVertex3fv(&polygon[4].Vertex[1].x);
00564 glVertex3fv(&polygon[4].Vertex[1].x);
00565 glVertex3fv(&polygon[4].Vertex[2].x);
00566 glVertex3fv(&polygon[4].Vertex[2].x);
00567 glVertex3fv(&polygon[4].Vertex[0].x);
00568
00569 glVertex3fv(&polygon[5].Vertex[0].x);
00570 glVertex3fv(&polygon[5].Vertex[1].x);
00571 glVertex3fv(&polygon[5].Vertex[1].x);
00572 glVertex3fv(&polygon[5].Vertex[2].x);
00573 glVertex3fv(&polygon[5].Vertex[2].x);
00574 glVertex3fv(&polygon[5].Vertex[0].x);
00575 // Bottom Face
00576 glNormal3fv(&polygon[6].Vertex[0].nx);
00577 glVertex3fv(&polygon[6].Vertex[0].x);
00578 glVertex3fv(&polygon[6].Vertex[1].x);
00579 glVertex3fv(&polygon[6].Vertex[1].x);
00580 glVertex3fv(&polygon[6].Vertex[2].x);
00581 glVertex3fv(&polygon[6].Vertex[2].x);
00582 glVertex3fv(&polygon[6].Vertex[0].x);
00583
00584 glVertex3fv(&polygon[7].Vertex[0].x);
00585 glVertex3fv(&polygon[7].Vertex[1].x);
00586 glVertex3fv(&polygon[7].Vertex[1].x);
00587 glVertex3fv(&polygon[7].Vertex[2].x);
00588 glVertex3fv(&polygon[7].Vertex[2].x);
00589 glVertex3fv(&polygon[7].Vertex[0].x);
00590 // Right face
00591 glNormal3fv(&polygon[8].Vertex[0].nx);
00592 glVertex3fv(&polygon[8].Vertex[0].x);
00593 glVertex3fv(&polygon[8].Vertex[1].x);
00594 glVertex3fv(&polygon[8].Vertex[1].x);
00595 glVertex3fv(&polygon[8].Vertex[2].x);
00596 glVertex3fv(&polygon[8].Vertex[2].x);
00597 glVertex3fv(&polygon[8].Vertex[0].x);
00598
00599 glVertex3fv(&polygon[9].Vertex[0].x);
00600 glVertex3fv(&polygon[9].Vertex[1].x);
00601 glVertex3fv(&polygon[9].Vertex[1].x);
00602 glVertex3fv(&polygon[9].Vertex[2].x);
00603 glVertex3fv(&polygon[9].Vertex[2].x);
00604 glVertex3fv(&polygon[9].Vertex[0].x);
00605 // Left Face
00606 glNormal3fv(&polygon[10].Vertex[0].nx);
00607 glVertex3fv(&polygon[10].Vertex[0].x);
00608 glVertex3fv(&polygon[10].Vertex[1].x);
00609 glVertex3fv(&polygon[10].Vertex[1].x);
00610 glVertex3fv(&polygon[10].Vertex[2].x);
00611 glVertex3fv(&polygon[10].Vertex[2].x);
00612 glVertex3fv(&polygon[10].Vertex[0].x);
00613
00614 glVertex3fv(&polygon[11].Vertex[0].x);
00615 glVertex3fv(&polygon[11].Vertex[1].x);
00616 glVertex3fv(&polygon[11].Vertex[1].x);
00617 glVertex3fv(&polygon[11].Vertex[2].x);
00618 glVertex3fv(&polygon[11].Vertex[2].x);
00619 glVertex3fv(&polygon[11].Vertex[0].x);
00620 glEnd();
00621 glPopMatrix();
00622 glEnable(GL_LIGHTING);
00623 glEnable(GL_TEXTURE_2D);
00624
00625 float mat_ambient[] = { 0.8, 0.5, 0.1, 1.0 };
00626 float mat_diffuse[] = { 0.8, 0.5, 0.1, 1.0 };
00627 glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
00628 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
00629 glDisable(GL_TEXTURE_2D);
00630 glPushMatrix();
00631 glTranslatef(vertex[VertexNumber].x, vertex[VertexNumber].y, vertex[VertexNumber].z);
00632 gluQuadricOrientation(sphere, GLU_OUTSIDE);
00633 gluSphere(sphere,10.0,20,20);
00634 glPopMatrix();
00635 glEnable(GL_TEXTURE_2D);
00636
00637 }
|
|
|
Definition at line 263 of file Oglmdi2.cpp. References g_fCubeRotationX, g_fCubeRotationY, g_iMouseDeltaX, and g_iMouseDeltaY. Referenced by WinMain().
00264 {
00265 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00266 glMatrixMode(GL_MODELVIEW);
00267 glLoadIdentity();
00268
00269 if(g_bMouseDrag) // If left mouse button is down
00270 {
00271 g_fCubeRotationX += (float)g_iMouseDeltaY * 0.5; // Apply mouse deltas to cube rotation values
00272 g_fCubeRotationY += (float)g_iMouseDeltaX * 0.5;
00273 }
00274
00275 glTranslatef(0.0,0.0,-500.0);
00276 glRotatef(g_fCubeRotationX,1.0,0.0,0.0);
00277 glRotatef(g_fCubeRotationY,0.0,1.0,0.0);
00278
00279 glBindTexture(GL_TEXTURE_2D, texture[0].TexID);
00280 glPushMatrix();
00281 glBegin(GL_TRIANGLES);
00282 // Front Face
00283 glNormal3fv(&polygon[0].Vertex[0].nx);
00284 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[0].Vertex[0].x);
00285 glTexCoord2f(1.0f, 0.0f); glVertex3fv(&polygon[0].Vertex[1].x);
00286 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[0].Vertex[2].x);
00287
00288 glNormal3fv(&polygon[1].Vertex[0].nx);
00289 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[1].Vertex[0].x);
00290 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[1].Vertex[1].x);
00291 glTexCoord2f(0.0f, 1.0f); glVertex3fv(&polygon[1].Vertex[2].x);
00292 // Back Face
00293 glNormal3fv(&polygon[2].Vertex[0].nx);
00294 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[2].Vertex[0].x);
00295 glTexCoord2f(1.0f, 0.0f); glVertex3fv(&polygon[2].Vertex[1].x);
00296 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[2].Vertex[2].x);
00297
00298 glNormal3fv(&polygon[3].Vertex[0].nx);
00299 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[3].Vertex[0].x);
00300 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[3].Vertex[1].x);
00301 glTexCoord2f(0.0f, 1.0f); glVertex3fv(&polygon[3].Vertex[2].x);
00302 // Top Face
00303 glNormal3fv(&polygon[4].Vertex[0].nx);
00304 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[4].Vertex[0].x);
00305 glTexCoord2f(1.0f, 0.0f); glVertex3fv(&polygon[4].Vertex[1].x);
00306 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[4].Vertex[2].x);
00307
00308 glNormal3fv(&polygon[5].Vertex[0].nx);
00309 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[5].Vertex[0].x);
00310 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[5].Vertex[1].x);
00311 glTexCoord2f(0.0f, 1.0f); glVertex3fv(&polygon[5].Vertex[2].x);
00312 // Bottom Face
00313 glNormal3fv(&polygon[6].Vertex[0].nx);
00314 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[6].Vertex[0].x);
00315 glTexCoord2f(1.0f, 0.0f); glVertex3fv(&polygon[6].Vertex[1].x);
00316 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[6].Vertex[2].x);
00317
00318 glNormal3fv(&polygon[7].Vertex[0].nx);
00319 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[7].Vertex[0].x);
00320 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[7].Vertex[1].x);
00321 glTexCoord2f(0.0f, 1.0f); glVertex3fv(&polygon[7].Vertex[2].x);
00322 // Right face
00323 glNormal3fv(&polygon[8].Vertex[0].nx);
00324 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[8].Vertex[0].x);
00325 glTexCoord2f(1.0f, 0.0f); glVertex3fv(&polygon[8].Vertex[1].x);
00326 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[8].Vertex[2].x);
00327
00328 glNormal3fv(&polygon[9].Vertex[0].nx);
00329 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[9].Vertex[0].x);
00330 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[9].Vertex[1].x);
00331 glTexCoord2f(0.0f, 1.0f); glVertex3fv(&polygon[9].Vertex[2].x);
00332 // Left Face
00333 glNormal3fv(&polygon[10].Vertex[0].nx);
00334 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[10].Vertex[0].x);
00335 glTexCoord2f(1.0f, 0.0f); glVertex3fv(&polygon[10].Vertex[1].x);
00336 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[10].Vertex[2].x);
00337
00338 glNormal3fv(&polygon[11].Vertex[0].nx);
00339 glTexCoord2f(0.0f, 0.0f); glVertex3fv(&polygon[11].Vertex[0].x);
00340 glTexCoord2f(1.0f, 1.0f); glVertex3fv(&polygon[11].Vertex[1].x);
00341 glTexCoord2f(0.0f, 1.0f); glVertex3fv(&polygon[11].Vertex[2].x);
00342 glEnd();
00343 glPopMatrix();
00344 }
|
|
||||||||||||||||||||||||
|
Definition at line 1265 of file Oglmdi2.cpp. References colorRGB, hFont, hOldFont, LogFont, MainRect, and MouseX.
01266 {
01267 colorRGB = RGB(255, 255, 255);
01268 SetTextColor(hDC, colorRGB); // Sets the text color
01269 SetBkMode(hDC, TRANSPARENT); // Sets the text background to transparent
01270 MainRect.left = 0; // Set the whole screen as the drawing area
01271 MainRect.top = 0;
01272 MainRect.bottom = bottom;
01273 MainRect.right = right;
01274 ZeroMemory(&LogFont, sizeof(LogFont));
01275 LogFont.lfHeight = 14; // Font height
01276 LogFont.lfWidth = 8; // Font width
01277 LogFont.lfEscapement = 0; // Text rotation for true type fonts. If this one is set then also set the next line to the same value
01278 LogFont.lfOrientation = 0;
01279 LogFont.lfWeight = FW_NORMAL;
01280 LogFont.lfItalic = 0;
01281 LogFont.lfUnderline = 0;
01282 LogFont.lfStrikeOut = 0;
01283 LogFont.lfCharSet = DEFAULT_CHARSET;
01284 LogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
01285 LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
01286 LogFont.lfQuality = DEFAULT_QUALITY;
01287 LogFont.lfPitchAndFamily = DEFAULT_PITCH;
01288 sprintf(LogFont.lfFaceName, "%s", "Arial");
01289 hFont = CreateFontIndirect(&LogFont);
01290 SaveDC(hDC);
01291 hOldFont = (HFONT)SelectObject(hDC, (HFONT)hFont);
01292 char tempstring[20];
01293 sprintf(tempstring, "%d", MouseX);
01294 DrawText(hDC, tempstring, 11, &MainRect, DT_NOCLIP | DT_LEFT | DT_BOTTOM | DT_WORDBREAK | DT_EDITCONTROL);
01295 SelectObject(hDC, (HFONT)hOldFont);
01296 DeleteObject(hFont);
01297 RestoreDC(hDC, -1);
01298 }
|
|
|
Definition at line 201 of file Oglmdi2.cpp. References SetTextures(). Referenced by WndProc().
00202 {
00203 glCullFace(GL_BACK);
00204 glEnable(GL_CULL_FACE);
00205 glClearColor(0.0, 0.0, 0.0, 0.0);
00206 glClearDepth(1.0);
00207 glDepthFunc(GL_LESS);
00208 glEnable(GL_DEPTH_TEST);
00209 glShadeModel(GL_SMOOTH);
00210 glEnable(GL_NORMALIZE);
00211
00212 float fMatAmbient[] = {0.8, 0.8, 0.8, 1.0};
00213 float fMatDiffuse[] = {0.8, 0.8, 0.8, 1.0};
00214 float fMatSpecular[] = {0.9, 0.9, 0.9, 1.0};
00215 float fMatEmmision[] = {0.0, 0.0, 0.0, 1.0};
00216 float fMatShininess[] = {100.0};
00217
00218 glMaterialfv(GL_FRONT, GL_AMBIENT, fMatAmbient);
00219 glMaterialfv(GL_FRONT, GL_DIFFUSE, fMatDiffuse);
00220 glMaterialfv(GL_FRONT, GL_SPECULAR, fMatSpecular);
00221 glMaterialfv(GL_FRONT, GL_EMISSION, fMatEmmision);
00222 glMaterialfv(GL_FRONT, GL_SHININESS, fMatShininess);
00223
00224 float fLightAmbient[] = {0.2, 0.2, 0.2, 1.0};
00225 glLightfv(GL_LIGHT0, GL_AMBIENT, fLightAmbient);
00226 float fLightPosition[] = {200.0, 0.0, 0.0, 1.0};
00227 glLightfv(GL_LIGHT0, GL_POSITION, fLightPosition);
00228
00229 glEnable(GL_LIGHTING);
00230 glEnable(GL_LIGHT0);
00231
00232 SetTextures();
00233
00234 glEnable(GL_TEXTURE_2D);
00235 }
|
|
||||||||||||
|
Definition at line 251 of file Oglmdi2.cpp. Referenced by WinMain().
00252 {
00253 if(iHeight == 0)
00254 {
00255 iHeight = 1;
00256 }
00257 glViewport(0, 0, iWidth, iHeight);
00258 glMatrixMode(GL_PROJECTION);
00259 glLoadIdentity();
00260 glOrtho(-iWidth * 0.5, iWidth * 0.5, -iHeight * 0.5, iHeight * 0.5, -2000, 2000);
00261 }
|
|
||||||||||||
|
Definition at line 238 of file Oglmdi2.cpp. Referenced by WinMain().
00239 {
00240 if(iHeight == 0)
00241 {
00242 iHeight = 1;
00243 }
00244 glViewport(0, 0, iWidth, iHeight);
00245 glMatrixMode(GL_PROJECTION);
00246 glLoadIdentity();
00247 gluPerspective(45.0,(float)iWidth/(float)iHeight, 1, 1000.0);
00248 }
|
|
|
Definition at line 133 of file Oglmdi2.cpp. References POLYGON::SetNormal(), and POLYGON::Vertex. Referenced by Child2DWndProc(), and WinMain().
00134 {
00135 // Set cubes polygons
00136
00137 //Front
00138 polygon[0].Vertex[0] = vertex[0];
00139 polygon[0].Vertex[1] = vertex[1];
00140 polygon[0].Vertex[2] = vertex[2];
00141
00142 polygon[1].Vertex[0] = vertex[0];
00143 polygon[1].Vertex[1] = vertex[2];
00144 polygon[1].Vertex[2] = vertex[3];
00145 //Back
00146 polygon[2].Vertex[0] = vertex[5];
00147 polygon[2].Vertex[1] = vertex[4];
00148 polygon[2].Vertex[2] = vertex[7];
00149
00150 polygon[3].Vertex[0] = vertex[5];
00151 polygon[3].Vertex[1] = vertex[7];
00152 polygon[3].Vertex[2] = vertex[6];
00153 //Left
00154 polygon[4].Vertex[0] = vertex[4];
00155 polygon[4].Vertex[1] = vertex[0];
00156 polygon[4].Vertex[2] = vertex[3];
00157
00158 polygon[5].Vertex[0] = vertex[4];
00159 polygon[5].Vertex[1] = vertex[3];
00160 polygon[5].Vertex[2] = vertex[7];
00161 //Right
00162 polygon[6].Vertex[0] = vertex[1];
00163 polygon[6].Vertex[1] = vertex[5];
00164 polygon[6].Vertex[2] = vertex[6];
00165
00166 polygon[7].Vertex[0] = vertex[1];
00167 polygon[7].Vertex[1] = vertex[6];
00168 polygon[7].Vertex[2] = vertex[2];
00169 //Top
00170 polygon[8].Vertex[0] = vertex[3];
00171 polygon[8].Vertex[1] = vertex[2];
00172 polygon[8].Vertex[2] = vertex[6];
00173
00174 polygon[9].Vertex[0] = vertex[3];
00175 polygon[9].Vertex[1] = vertex[6];
00176 polygon[9].Vertex[2] = vertex[7];
00177 //Bottom
00178 polygon[10].Vertex[0] = vertex[5];
00179 polygon[10].Vertex[1] = vertex[1];
00180 polygon[10].Vertex[2] = vertex[0];
00181
00182 polygon[11].Vertex[0] = vertex[5];
00183 polygon[11].Vertex[1] = vertex[0];
00184 polygon[11].Vertex[2] = vertex[4];
00185
00186 polygon[0].SetNormal();
00187 polygon[1].SetNormal();
00188 polygon[2].SetNormal();
00189 polygon[3].SetNormal();
00190 polygon[4].SetNormal();
00191 polygon[5].SetNormal();
00192 polygon[6].SetNormal();
00193 polygon[7].SetNormal();
00194 polygon[8].SetNormal();
00195 polygon[9].SetNormal();
00196 polygon[10].SetNormal();
00197 polygon[11].SetNormal();
00198 }
|
|
|
Definition at line 90 of file Oglmdi2.cpp. References TEXTURE::LoadTGA(). Referenced by InitGL().
|
|
|
Definition at line 96 of file Oglmdi2.cpp. References VERTEX::x, VERTEX::y, and VERTEX::z. Referenced by WinMain().
00097 {
00098 // Set cubes vertices
00099
00100 vertex[0].x = -100;
00101 vertex[0].y = -100;
00102 vertex[0].z = 100;
00103
00104 vertex[1].x = 100;
00105 vertex[1].y = -100;
00106 vertex[1].z = 100;
00107
00108 vertex[2].x = 100;
00109 vertex[2].y = 100;
00110 vertex[2].z = 100;
00111
00112 vertex[3].x = -100;
00113 vertex[3].y = 100;
00114 vertex[3].z = 100;
00115
00116 vertex[4].x = -100;
00117 vertex[4].y = -100;
00118 vertex[4].z = -100;
00119
00120 vertex[5].x = 100;
00121 vertex[5].y = -100;
00122 vertex[5].z = -100;
00123
00124 vertex[6].x = 100;
00125 vertex[6].y = 100;
00126 vertex[6].z = -100;
00127
00128 vertex[7].x = -100;
00129 vertex[7].y = 100;
00130 vertex[7].z = -100;
00131 }
|
|
||||||||||||||||||||
|
Definition at line 1494 of file Oglmdi2.cpp. References Child2DWndProc(), Child3DWndProc(), Draw2DSceneFront(), Draw2DSceneLeft(), Draw2DSceneTop(), Draw3DScene(), FALSE, g_hInst, g_hMainWindow, g_hMDIClient, g_iNumChild, g_rectChild, g_szChild2DClassName, g_szChild3DClassName, g_szMainClassName, HorizontalShift, CHILD::iType, key, Set2DProjection(), Set3DProjection(), SetPolygons(), SetVertices(), VerticalShift, WndProc(), and Zoom.
01495 {
01496 MSG Msg;
01497 WNDCLASSEX wc;
01498 g_hInst = hInstance;
01499
01500 // Create an OpenGL compatible window class
01501 wc.cbSize = sizeof(WNDCLASSEX);
01502 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
01503 wc.lpfnWndProc = (WNDPROC)Child3DWndProc;
01504 wc.cbClsExtra = 0;
01505 wc.cbWndExtra = 0;
01506 wc.hInstance = hInstance;
01507 wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CHILDICON));
01508 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
01509 wc.hbrBackground = (HBRUSH)(COLOR_3DSHADOW+1); // Background color (Only seen if OGL fails)
01510 wc.lpszMenuName = NULL;
01511 wc.lpszClassName = g_szChild3DClassName;
01512 wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CHILDICON));
01513
01514 if(!RegisterClassEx(&wc))
01515 {
01516 MessageBox(NULL,"Failed to register the child window.","Error",MB_OK|MB_ICONEXCLAMATION);
01517 return FALSE;
01518 }
01519
01520 // Create an OpenGL compatible window class
01521 wc.cbSize = sizeof(WNDCLASSEX);
01522 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
01523 wc.lpfnWndProc = (WNDPROC)Child2DWndProc;
01524 wc.cbClsExtra = 0;
01525 wc.cbWndExtra = 0;
01526 wc.hInstance = hInstance;
01527 wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CHILDICON));
01528 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
01529 wc.hbrBackground = (HBRUSH)(COLOR_3DSHADOW+1); // Background color (Only seen if OGL fails)
01530 wc.lpszMenuName = NULL;
01531 wc.lpszClassName = g_szChild2DClassName;
01532 wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CHILDICON));
01533
01534 if(!RegisterClassEx(&wc))
01535 {
01536 MessageBox(NULL,"Failed to register the child window.","Error",MB_OK|MB_ICONEXCLAMATION);
01537 return FALSE;
01538 }
01539
01540 // Create the frame window
01541 wc.cbSize = sizeof(WNDCLASSEX);
01542 wc.style = CS_HREDRAW | CS_VREDRAW;
01543 wc.lpfnWndProc = (WNDPROC)WndProc;
01544 wc.cbClsExtra = 0;
01545 wc.cbWndExtra = 0;
01546 wc.hInstance = hInstance;
01547 wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
01548 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
01549 wc.hbrBackground = (HBRUSH)(COLOR_3DSHADOW+1);
01550 wc.lpszMenuName = "MAIN";
01551 wc.lpszClassName = g_szMainClassName;
01552 wc.hIconSm = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
01553
01554 if(!RegisterClassEx(&wc))
01555 {
01556 MessageBox(0, "Failed to register the main window.", "Error",
01557 MB_ICONEXCLAMATION | MB_OK);
01558 return -1;
01559 }
01560
01561 g_hMainWindow = CreateWindowEx(WS_EX_LEFT, g_szMainClassName, "Al's OpenGL MDI Example",
01562 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
01563 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
01564 NULL, NULL, hInstance, NULL);
01565
01566 if(g_hMainWindow == NULL)
01567 {
01568 MessageBox(0, "Failed to create window.", "ERROR", MB_ICONEXCLAMATION | MB_OK);
01569 return -1;
01570 }
01571
01572 ShowWindow(g_hMainWindow, nCmdShow);
01573 UpdateWindow(g_hMainWindow);
01574 SetVertices();
01575 SetPolygons();
01576
01577 int iLoop;
01578 while(GetMessage(&Msg, NULL, 0, 0))
01579 {
01580 if(!TranslateMDISysAccel(g_hMDIClient, &Msg))
01581 {
01582 TranslateMessage(&Msg);
01583 DispatchMessage(&Msg);
01584 }
01585
01586 if(g_iNumChild) // If we have some children
01587 {
01588 for(iLoop = 0; iLoop < g_iNumChild; iLoop++) // Loop through all children
01589 {
01590 if(!IsIconic(g_child[iLoop].hWnd)) // If child isn't iconic (minimized)
01591 {
01592 wglMakeCurrent(g_child[iLoop].hDC, g_child[iLoop].hRC); // Make them the current DC and RC
01593 GetClientRect(g_child[iLoop].hWnd, &g_rectChild);
01594 if(g_rectChild.right > 0 && g_rectChild.bottom > 0)
01595 {
01596 if(g_child[iLoop].iType == 1)
01597 {
01598 Set3DProjection(g_rectChild.right, g_rectChild.bottom);// Set the childs projection matrix
01599 Draw3DScene();
01600 }
01601 else
01602 {
01603 Set2DProjection(g_rectChild.right, g_rectChild.bottom);// Set the childs projection matrix
01604 switch(g_child[iLoop].iType)
01605 {
01606 case 2:
01607 Draw2DSceneFront(g_child[iLoop].hWnd);
01608 break;
01609
01610 case 3:
01611 Draw2DSceneTop(g_child[iLoop].hWnd);
01612 break;
01613
01614 case 4:
01615 Draw2DSceneLeft(g_child[iLoop].hWnd);
01616 break;
01617 }
01618 }
01619 }
01620 glFlush();
01621 SwapBuffers(g_child[iLoop].hDC);
01622
01623 if (key[49])
01624 {
01625 if (Zoom < 1)
01626 Zoom += 0.001;
01627 }
01628
01629 if (key[50])
01630 {
01631 if (Zoom > 0)
01632 Zoom -= 0.001;
01633 }
01634
01635 if (key[51])
01636 {
01637 VerticalShift += 1;
01638 }
01639
01640 if (key[52])
01641 {
01642 VerticalShift -= 1;
01643 }
01644
01645 if (key[53])
01646 {
01647 HorizontalShift += 1;
01648 }
01649
01650 if (key[54])
01651 {
01652 HorizontalShift -= 1;
01653 }
01654
01655 if (key[VK_SPACE])
01656 {
01657 SetVertices();
01658 SetPolygons();
01659 }
01660
01661 }
01662 }
01663 }
01664 }
01665 return Msg.wParam;
01666 }
|
|
||||||||||||||||||||
|
Definition at line 786 of file Oglmdi2.cpp. References g_hInst, g_hMDIClient, g_iMaxChild, g_iNumChild, g_szChild2DClassName, g_szChild3DClassName, and InitGL(). Referenced by WinMain().
00787 {
00788 switch(uMessage)
00789 {
00790 case WM_CREATE:
00791 {
00792 CLIENTCREATESTRUCT ccs;
00793 // Find window menu where children will be listed
00794 ccs.hWindowMenu = NULL;
00795 // If the menus document list for more than 9 children didn't upset the child ID then I would use the line below
00796 //ccs.hWindowMenu = (HMENU)GetSubMenu(GetMenu(hWnd), 2); // if you use less than 10 windows then use this line
00797 ccs.idFirstChild = ID_MDI_FIRSTCHILD;
00798
00799 g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "MDICLIENT", NULL,
00800 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, //WS_VSCROLL and WS_HSCROLL do not work properly yet
00801 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
00802 hWnd, (HMENU)ID_MDI_CLIENT, g_hInst, (LPVOID)&ccs);
00803
00804 ShowWindow(g_hMDIClient, SW_SHOW);
00805 return 0;
00806 }
00807 case WM_COMMAND:
00808 {
00809 switch(LOWORD(wParam))
00810 {
00811 case CM_FILE_EXIT:
00812 PostMessage(hWnd, WM_CLOSE, 0, 0);
00813 break;
00814
00815 case CM_FILE_NEW_3D:
00816 {
00817 HWND hChild;
00818
00819 if(g_iNumChild < g_iMaxChild) // If the number of children hasn't reached the maximum
00820 g_iNumChild++; // Increment the number of children
00821 else
00822 break; // Otherwise break out of the routine
00823
00824 char szWindowTitle[] = "3D";
00825 //sprintf(szWindowTitle, "%d", g_iNumChild - 1);
00826
00827 /* One way to create a child window is to send a WM_MDICREATE message to the client
00828 window and pass it a pointer to a MDICREATESTRUCT. */
00829
00830 /*
00831 MDICREATESTRUCT mcs;
00832 mcs.szTitle = szWindowTitle;
00833 mcs.szClass = g_szChildClassName;
00834 mcs.hOwner = g_hInst;
00835 mcs.x = mcs.cx = CW_USEDEFAULT;
00836 mcs.y = mcs.cy = CW_USEDEFAULT;
00837 mcs.style = MDIS_ALLCHILDSTYLES;
00838
00839 hChild = (HWND)SenduMessage(g_hMDIClient, WM_MDICREATE, 0, (LONG)&mcs);
00840 //*/
00841
00842 /* Another way to create a child window is to use CreateWindowEx and set the extended
00843 windows style to WS_EX_MDICHILD. I prefer this method as it will allow each child to be created in
00844 seperate threads in the future. */
00845
00846 //*
00847 CREATESTRUCT cs;
00848 ZeroMemory(&cs, sizeof(CREATESTRUCT));
00849
00850 hChild = CreateWindowEx(
00851 WS_EX_MDICHILD,
00852 g_szChild3DClassName,
00853 szWindowTitle,
00854 WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
00855 CW_USEDEFAULT,
00856 CW_USEDEFAULT,
00857 CW_USEDEFAULT,
00858 CW_USEDEFAULT,
00859 g_hMDIClient,
00860 NULL,
00861 g_hInst,
00862 &cs
00863 );
00864 //*/
00865 if(!hChild)
00866 {
00867 MessageBox(NULL, "3D Child creation failed.", "Error",
00868 MB_ICONEXCLAMATION | MB_OK);
00869 }
00870
00871 g_child[g_iNumChild - 1].iType = 1; // Set child windows type
00872 g_child[g_iNumChild - 1].hWnd = hChild; // Set child windows handle
00873 g_child[g_iNumChild - 1].hDC = GetDC(hChild); // Set child windows device context
00874
00875 PIXELFORMATDESCRIPTOR pfd;
00876 ZeroMemory(&pfd, sizeof(pfd));
00877 pfd.nSize = sizeof(pfd);
00878 pfd.nVersion = 1;
00879 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
00880 pfd.iPixelType = PFD_TYPE_RGBA;
00881 pfd.cColorBits = 24;
00882 pfd.cDepthBits = 16;
00883 pfd.iLayerType = PFD_MAIN_PLANE;
00884 int iFormat = ChoosePixelFormat(g_child[g_iNumChild - 1].hDC, &pfd);
00885 SetPixelFormat(g_child[g_iNumChild - 1].hDC, iFormat, &pfd); // Set pixel format for this child
00886
00887 g_child[g_iNumChild - 1].hRC = wglCreateContext(g_child[g_iNumChild - 1].hDC); // Set childs rendering context
00888 wglMakeCurrent(g_child[g_iNumChild - 1].hDC, g_child[g_iNumChild - 1].hRC); // Make this child the current DC and RC
00889 InitGL(); // Initialize the rendering defaults for this child
00890 }
00891 break;
00892
00893 case CM_FILE_NEW_FRONT:
00894 {
00895 HWND hChild;
00896
00897 if(g_iNumChild < g_iMaxChild) // If the number of children hasn't reached the maximum
00898 g_iNumChild++; // Increment the number of children
00899 else
00900 break; // Otherwise break out of the routine
00901
00902 char szWindowTitle[] = "Front";
00903 //sprintf(szWindowTitle, "%d", g_iNumChild - 1);
00904
00905 CREATESTRUCT cs;
00906 ZeroMemory(&cs, sizeof(CREATESTRUCT));
00907
00908 hChild = CreateWindowEx(
00909 WS_EX_MDICHILD,
00910 g_szChild2DClassName,
00911 szWindowTitle,
00912 WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
00913 CW_USEDEFAULT,
00914 CW_USEDEFAULT,
00915 CW_USEDEFAULT,
00916 CW_USEDEFAULT,
00917 g_hMDIClient,
00918 NULL,
00919 g_hInst,
00920 &cs
00921 );
00922
00923 if(!hChild)
00924 {
00925 MessageBox(NULL, "2D Child creation failed.", "Error",
00926 MB_ICONEXCLAMATION | MB_OK);
00927 }
00928
00929 g_child[g_iNumChild - 1].iType = 2; // Set child windows type
00930 g_child[g_iNumChild - 1].hWnd = hChild; // Set child windows handle
00931 g_child[g_iNumChild - 1].hDC = GetDC(hChild); // Set child windows device context
00932
00933 PIXELFORMATDESCRIPTOR pfd;
00934 ZeroMemory(&pfd, sizeof(pfd));
00935 pfd.nSize = sizeof(pfd);
00936 pfd.nVersion = 1;
00937 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
00938 pfd.iPixelType = PFD_TYPE_RGBA;
00939 pfd.cColorBits = 24;
00940 pfd.cDepthBits = 16;
00941 pfd.iLayerType = PFD_MAIN_PLANE;
00942 int iFormat = ChoosePixelFormat(g_child[g_iNumChild - 1].hDC, &pfd);
00943 SetPixelFormat(g_child[g_iNumChild - 1].hDC, iFormat, &pfd); // Set pixel format for this child
00944
00945 g_child[g_iNumChild - 1].hRC = wglCreateContext(g_child[g_iNumChild - 1].hDC); // Set childs rendering context
00946 wglMakeCurrent(g_child[g_iNumChild - 1].hDC, g_child[g_iNumChild - 1].hRC); // Make this child the current DC and RC
00947 InitGL(); // Initialize the rendering defaults for this child
00948 }
00949 break;
00950
00951 case CM_FILE_NEW_TOP:
00952 {
00953 HWND hChild;
00954
00955 if(g_iNumChild < g_iMaxChild) // If the number of children hasn't reached the maximum
00956 g_iNumChild++; // Increment the number of children
00957 else
00958 break; // Otherwise break out of the routine
00959
00960 char szWindowTitle[] = "Top";
00961 //sprintf(szWindowTitle, "%d", g_iNumChild - 1);
00962
00963 CREATESTRUCT cs;
00964 ZeroMemory(&cs, sizeof(CREATESTRUCT));
00965
00966 hChild = CreateWindowEx(
00967 WS_EX_MDICHILD,
00968 g_szChild2DClassName,
00969 szWindowTitle,
00970 WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
00971 CW_USEDEFAULT,
00972 CW_USEDEFAULT,
00973 CW_USEDEFAULT,
00974 CW_USEDEFAULT,
00975 g_hMDIClient,
00976 NULL,
00977 g_hInst,
00978 &cs
00979 );
00980
00981 if(!hChild)
00982 {
00983 MessageBox(NULL, "2D Child creation failed.", "Error",
00984 MB_ICONEXCLAMATION | MB_OK);
00985 }
00986
00987 g_child[g_iNumChild - 1].iType = 3; // Set child windows type
00988 g_child[g_iNumChild - 1].hWnd = hChild; // Set child windows handle
00989 g_child[g_iNumChild - 1].hDC = GetDC(hChild); // Set child windows device context
00990
00991 PIXELFORMATDESCRIPTOR pfd;
00992 ZeroMemory(&pfd, sizeof(pfd));
00993 pfd.nSize = sizeof(pfd);
00994 pfd.nVersion = 1;
00995 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
00996 pfd.iPixelType = PFD_TYPE_RGBA;
00997 pfd.cColorBits = 24;
00998 pfd.cDepthBits = 16;
00999 pfd.iLayerType = PFD_MAIN_PLANE;
01000 int iFormat = ChoosePixelFormat(g_child[g_iNumChild - 1].hDC, &pfd);
01001 SetPixelFormat(g_child[g_iNumChild - 1].hDC, iFormat, &pfd); // Set pixel format for this child
01002
01003 g_child[g_iNumChild - 1].hRC = wglCreateContext(g_child[g_iNumChild - 1].hDC); // Set childs rendering context
01004 wglMakeCurrent(g_child[g_iNumChild - 1].hDC, g_child[g_iNumChild - 1].hRC); // Make this child the current DC and RC
01005 InitGL(); // Initialize the rendering defaults for this child
01006 }
01007 break;
01008
01009 case CM_FILE_NEW_LEFT:
01010 {
01011 HWND hChild;
01012
01013 if(g_iNumChild < g_iMaxChild) // If the number of children hasn't reached the maximum
01014 g_iNumChild++; // Increment the number of children
01015 else
01016 break; // Otherwise break out of the routine
01017
01018 char szWindowTitle[] = "Left";
01019 //sprintf(szWindowTitle, "%d", g_iNumChild - 1);
01020
01021 CREATESTRUCT cs;
01022 ZeroMemory(&cs, sizeof(CREATESTRUCT));
01023
01024 hChild = CreateWindowEx(
01025 WS_EX_MDICHILD,
01026 g_szChild2DClassName,
01027 szWindowTitle,
01028 WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
01029 CW_USEDEFAULT,
01030 CW_USEDEFAULT,
01031 CW_USEDEFAULT,
01032 CW_USEDEFAULT,
01033 g_hMDIClient,
01034 NULL,
01035 g_hInst,
01036 &cs
01037 );
01038
01039 if(!hChild)
01040 {
01041 MessageBox(NULL, "2D Child creation failed.", "Error",
01042 MB_ICONEXCLAMATION | MB_OK);
01043 }
01044
01045 g_child[g_iNumChild - 1].iType = 4; // Set child windows type
01046 g_child[g_iNumChild - 1].hWnd = hChild; // Set child windows handle
01047 g_child[g_iNumChild - 1].hDC = GetDC(hChild); // Set child windows device context
01048
01049 PIXELFORMATDESCRIPTOR pfd;
01050 ZeroMemory(&pfd, sizeof(pfd));
01051 pfd.nSize = sizeof(pfd);
01052 pfd.nVersion = 1;
01053 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
01054 pfd.iPixelType = PFD_TYPE_RGBA;
01055 pfd.cColorBits = 24;
01056 pfd.cDepthBits = 16;
01057 pfd.iLayerType = PFD_MAIN_PLANE;
01058 int iFormat = ChoosePixelFormat(g_child[g_iNumChild - 1].hDC, &pfd);
01059 SetPixelFormat(g_child[g_iNumChild - 1].hDC, iFormat, &pfd); // Set pixel format for this child
01060
01061 g_child[g_iNumChild - 1].hRC = wglCreateContext(g_child[g_iNumChild - 1].hDC); // Set childs rendering context
01062 wglMakeCurrent(g_child[g_iNumChild - 1].hDC, g_child[g_iNumChild - 1].hRC); // Make this child the current DC and RC
01063 InitGL(); // Initialize the rendering defaults for this child
01064 }
01065 break;
01066
01067 case CM_WINDOW_TILEHORZ:
01068 PostMessage(g_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0);
01069 break;
01070
01071 case CM_WINDOW_TILEVERT:
01072 PostMessage(g_hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0);
01073 break;
01074
01075 case CM_WINDOW_CASCADE:
01076 PostMessage(g_hMDIClient, WM_MDICASCADE, 0, 0);
01077 break;
01078
01079 case CM_WINDOW_ARRANGE:
01080 PostMessage(g_hMDIClient, WM_MDIICONARRANGE, 0, 0);
01081 break;
01082
01083 default:
01084 {
01085 if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
01086 {
01087 DefFrameProc(hWnd, g_hMDIClient, uMessage, wParam, lParam);
01088 }
01089 else
01090 {
01091 HWND hChild;
01092 hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE, 0, 0);
01093 if(hChild)
01094 {
01095 SendMessage(hChild, WM_COMMAND, wParam, lParam);
01096 }
01097 }
01098 }
01099 }
01100 }
01101 break;
01102
01103 case WM_CLOSE:
01104 {
01105 int iLoop;
01106 if(g_iNumChild) // If there are any children
01107 {
01108 for(iLoop = 0; iLoop < g_iNumChild; iLoop++) // Send all children the WM_CLOSE to free up their DC and RC
01109 {
01110 SendMessage(g_child[iLoop].hWnd, WM_CLOSE, 0, 0);
01111 }
01112 }
01113 delete[] g_child; // Delete the array of children
01114 delete[] texture;
01115 delete[] vertex;
01116 delete[] polygon;
01117 DestroyWindow(hWnd);
01118 }
01119 break;
01120
01121 case WM_DESTROY:
01122 PostQuitMessage(0);
01123 break;
01124
01125 default:
01126 return DefFrameProc(hWnd, g_hMDIClient, uMessage, wParam, lParam);
01127 }
01128 return 0;
01129 }
|
|
|
Definition at line 29 of file Oglmdi2.cpp. Referenced by DrawWin32Text(). |
|
|
Definition at line 67 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 58 of file Oglmdi2.cpp. Referenced by Child3DWndProc(). |
|
|
Definition at line 72 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 88 of file Oglmdi2.cpp. |
|
|
Definition at line 52 of file Oglmdi2.cpp. Referenced by Draw3DScene(). |
|
|
Definition at line 52 of file Oglmdi2.cpp. Referenced by Draw3DScene(). |
|
|
Definition at line 47 of file Oglmdi2.cpp. |
|
|
Definition at line 49 of file Oglmdi2.cpp. Referenced by Child2DWndProc(), Child3DWndProc(), and WinMain(). |
|
|
Definition at line 48 of file Oglmdi2.cpp. |
|
|
Definition at line 86 of file Oglmdi2.cpp. Referenced by WndProc(). |
|
|
Definition at line 61 of file Oglmdi2.cpp. Referenced by Child3DWndProc(), and Draw3DScene(). |
|
|
Definition at line 75 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 62 of file Oglmdi2.cpp. Referenced by Child3DWndProc(), and Draw3DScene(). |
|
|
Definition at line 76 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 59 of file Oglmdi2.cpp. Referenced by Child3DWndProc(). |
|
|
Definition at line 73 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 60 of file Oglmdi2.cpp. Referenced by Child3DWndProc(). |
|
|
Definition at line 74 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 87 of file Oglmdi2.cpp. Referenced by Child2DWndProc(), Child3DWndProc(), WinMain(), and WndProc(). |
|
|
Definition at line 50 of file Oglmdi2.cpp. Referenced by WinMain(). |
|
|
Definition at line 46 of file Oglmdi2.cpp. |
|
|
Definition at line 45 of file Oglmdi2.cpp. |
|
|
Definition at line 44 of file Oglmdi2.cpp. Referenced by WinMain(). |
|
|
Definition at line 32 of file Oglmdi2.cpp. Referenced by DrawWin32Text(). |
|
|
Definition at line 33 of file Oglmdi2.cpp. Referenced by DrawWin32Text(). |
|
|
Definition at line 57 of file Oglmdi2.cpp. Referenced by WinMain(). |
|
|
Definition at line 54 of file Oglmdi2.cpp. Referenced by Child2DWndProc(), Child3DWndProc(), and WinMain(). |
|
|
Definition at line 69 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 31 of file Oglmdi2.cpp. Referenced by DrawWin32Text(). |
|
|
Definition at line 30 of file Oglmdi2.cpp. Referenced by DrawWin32Text(). |
|
|
Definition at line 65 of file Oglmdi2.cpp. Referenced by Child2DWndProc(), and DrawWin32Text(). |
|
|
Definition at line 66 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 25 of file Oglmdi2.cpp. Referenced by OBJECT::GetXUnit(), OBJECT::GetYUnit(), OBJECT::MoveX(), and OBJECT::MoveY(). |
|
|
Definition at line 42 of file Oglmdi2.cpp. |
|
|
Definition at line 26 of file Oglmdi2.cpp. Referenced by OBJECT::Rotate(). |
|
|
Definition at line 55 of file Oglmdi2.cpp. |
|
|
Definition at line 64 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 70 of file Oglmdi2.cpp. Referenced by Draw2DSceneFront(), Draw2DSceneLeft(), and Draw2DSceneTop(). |
|
|
Definition at line 36 of file Oglmdi2.cpp. Referenced by LoadTGA(). |
|
|
Definition at line 68 of file Oglmdi2.cpp. Referenced by Child2DWndProc(). |
|
|
Definition at line 39 of file Oglmdi2.cpp. |
|
|
Definition at line 63 of file Oglmdi2.cpp. Referenced by Child2DWndProc(), Draw2DSceneFront(), Draw2DSceneLeft(), and Draw2DSceneTop(). |
|
|
Definition at line 56 of file Oglmdi2.cpp. Referenced by WinMain(). |
|
|
Definition at line 53 of file Oglmdi2.cpp. Referenced by WinMain(). |
1.2.15