Advertisement
Guest User

C++ Link Problem

a guest
Aug 26th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 14.08 KB | None | 0 0
  1. //<-------------OpenGLInit_CPP------------->//
  2.  
  3.  
  4. #include "StdAfx.h"
  5. #include "OpenGLInit.h"
  6.  
  7.  
  8. //<---Funtkionen--->//
  9. //Constructor
  10. OpenGLInit::OpenGLInit(){
  11.  
  12.     fRotateY = 0.0f;
  13.  
  14.     fTransX = 0.0f;
  15.     fTransY = 0.0f;
  16.     fTransZ = 0.0f;
  17.  
  18.     fPi180 = 0.0174532925f;
  19.  
  20.     for(int i = 0; i<256; i++){
  21.  
  22.         bKeys[i] = false;
  23.  
  24.     }
  25.  
  26. }
  27.  
  28.  
  29. //Variablen Funktionen
  30. inline HDC OpenGLInit::get_hDC(){
  31.    
  32.     return this->hDC;
  33.  
  34. }
  35.  
  36.  
  37. inline RECT OpenGLInit::get_rect(){
  38.  
  39.     return this-> rect;
  40.  
  41. }
  42.  
  43.  
  44. inline int OpenGLInit::get_iHoehe(){
  45.  
  46.     //return this->iBreite;
  47.     return 480;
  48.  
  49. }
  50.  
  51.  
  52. inline int OpenGLInit::get_iBreite(){
  53.  
  54.     //return this->iBreite;
  55.     return 640;
  56.  
  57. }
  58.  
  59.  
  60. void OpenGLInit::set_rect(int iWidth, int iHeight, bool bFullscreen){
  61.  
  62.     if(bFullscreen){
  63.  
  64.         HWND hWndDesktop = GetDesktopWindow();
  65.         GetWindowRect(hWndDesktop, &rect);
  66.         dwStyle = WS_POPUP;
  67.  
  68.     }
  69.     else{
  70.  
  71.         rect.top = 0;
  72.         rect.bottom = 0;
  73.         rect.right = iWidth;
  74.         rect.left = iHeight;
  75.         dwStyle = WS_OVERLAPPEDWINDOW;
  76.  
  77.     }
  78.  
  79. }
  80.  
  81.  
  82. //Generelle Funktionen
  83. LRESULT CALLBACK OpenGLInit::WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
  84.  
  85.     switch(msg){
  86.  
  87.         case WM_DESTROY:
  88.             PostQuitMessage(0);
  89.             break;
  90.        
  91.         case WM_QUIT:
  92.             MessageBox(NULL, "Programm wird beendet", "Programm Ende", MB_ICONINFORMATION | MB_OK);
  93.             break;
  94.  
  95.         case WM_SIZE:
  96.             opengl_resize_scene(LOWORD(lParam), HIWORD(lParam));
  97.             break;
  98.        
  99.         default:
  100.             return DefWindowProc(hWnd, msg, wParam, lParam);
  101.             break;
  102.  
  103.     }
  104.  
  105.     return 0;
  106.  
  107. }
  108.  
  109.  
  110. LRESULT CALLBACK OpenGLInit::StaticWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
  111.  
  112.     OpenGLInit* pOGlInit;
  113.  
  114.     if(msg == WM_CREATE){
  115.  
  116.         pOGlInit = (OpenGLInit*) (((LPCREATESTRUCT) lParam)->lpCreateParams);
  117.         SetWindowLongPtr(hWnd, GWL_USERDATA,  (LONG_PTR) pOGlInit);
  118.  
  119.     }
  120.     else{
  121.  
  122.         pOGlInit = (OpenGLInit*)GetWindowLongPtr(hWnd, GWL_USERDATA);
  123.  
  124.     }
  125.  
  126.     return pOGlInit->WndProc(hWnd, msg, wParam, lParam);
  127.  
  128. }
  129.  
  130.  
  131. bool OpenGLInit::screen_setup(HINSTANCE hInst, int iCmdShow, int iHoehe, int iBreite){
  132.  
  133.     strcpy_s(szClassName, "MyWndClass");
  134.     strcpy_s(szWindowTitle, "OpenGl");
  135.     this->iHoehe            = iHoehe;
  136.     this->iBreite           = iBreite;
  137.  
  138.     //Registrieren
  139.     this->WndClassEx.cbSize         = sizeof(WndClassEx);
  140.     this->WndClassEx.cbClsExtra     = NULL;
  141.     this->WndClassEx.cbWndExtra     = NULL;
  142.     this->WndClassEx.hInstance      = hInst;
  143.     this->WndClassEx.hbrBackground  = (HBRUSH) GetStockObject(BLACK_BRUSH);
  144.     this->WndClassEx.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
  145.     this->WndClassEx.hCursor        = LoadCursor(NULL, IDC_ARROW);
  146.     this->WndClassEx.hIconSm        = NULL;
  147.     this->WndClassEx.lpfnWndProc    = StaticWndProc;
  148.     this->WndClassEx.style          = CS_OWNDC;
  149.     this->WndClassEx.lpszMenuName   = NULL;
  150.     this->WndClassEx.lpszClassName  = szClassName;
  151.  
  152.     if(!RegisterClassEx(&WndClassEx)){
  153.  
  154.         MessageBox(NULL, "Fehler beim Registrieren des Fensters", "Error!", MB_ICONERROR | MB_OK);
  155.         return false;
  156.  
  157.     }
  158.  
  159.     hWnd = CreateWindow(szClassName, szWindowTitle, dwStyle | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, this->iBreite, this->iHoehe, NULL, NULL, hInst, NULL);
  160.  
  161.     if(!hWnd){
  162.  
  163.         MessageBox(NULL, "Fehler beim Erstellen des Fensters!", "Error!", MB_ICONERROR | MB_OK);
  164.         return false;
  165.  
  166.     }
  167.  
  168.     ShowWindow(hWnd, iCmdShow);
  169.     UpdateWindow(hWnd);
  170.  
  171.     return true;
  172.  
  173. }
  174.  
  175.  
  176. void OpenGLInit::opengl_setup(){
  177.  
  178.     //Rest
  179.     memset(&pfd, 0, sizeof(pfd));
  180.     pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
  181.     pfd.nVersion = 1;
  182.     pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
  183.     pfd.iPixelType = PFD_TYPE_RGBA;
  184.     pfd.cColorBits = 32;
  185.     pfd.cDepthBits = 32;
  186.     pfd.cAlphaBits = 8;
  187.  
  188.     //Fullscreen
  189.     memset(&dmSettings, 0, sizeof(dmSettings));
  190.     dmSettings.dmSize = sizeof(dmSettings);
  191.     dmSettings.dmPelsHeight = rect.bottom;
  192.     dmSettings.dmPelsWidth = rect.right;
  193.     dmSettings.dmBitsPerPel = 32;
  194.     dmSettings.dmFields = DM_PELSHEIGHT | DM_PELSWIDTH | DM_BITSPERPEL;
  195.  
  196.     ChangeDisplaySettings(&dmSettings, CDS_FULLSCREEN);
  197.  
  198.     //Rest
  199.     hDC = GetDC(hWnd);
  200.     iFormat = ChoosePixelFormat(hDC, &pfd);
  201.     SetPixelFormat(hDC, iFormat, &pfd);
  202.  
  203.     hGLRC = wglCreateContext(hDC);
  204.     wglMakeCurrent(hDC, hGLRC);
  205.  
  206.     glLoadIdentity();
  207.  
  208. }
  209.  
  210.  
  211. unsigned char OpenGLInit::key_pressed(){
  212.  
  213.     if(PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)){
  214.  
  215.         if(msg.message == WM_QUIT){
  216.  
  217.             return 1;
  218.  
  219.         }
  220.         else if(msg.message == WM_KEYDOWN){
  221.  
  222.             bKeys[msg.wParam] = true;
  223.  
  224.             if(msg.wParam == VK_ESCAPE){
  225.  
  226.                 MessageBox(NULL, "Error", "Menu noch nicht implementiert", MB_OK | MB_ICONERROR);
  227.  
  228.             }
  229.  
  230.         }
  231.         else if(msg.message == WM_KEYUP){
  232.  
  233.             bKeys[msg.wParam] = false;
  234.  
  235.         }
  236.  
  237.         TranslateMessage(&msg);
  238.         DispatchMessage(&msg);
  239.  
  240.     }
  241.  
  242.     return 0;
  243.  
  244. }
  245.  
  246.  
  247. void OpenGLInit::HandleKeyboard(){
  248.  
  249.     if(bKeys[VK_UP]){
  250.    
  251.         fTransZ -= cos(fRotateY * fPi180);
  252.         fTransX -= sin(fRotateY * fPi180);
  253.  
  254.     }
  255.     else if(bKeys[VK_DOWN]){
  256.        
  257.         fTransZ += cos(fRotateY * fPi180);
  258.         fTransX += sin(fRotateY * fPi180);
  259.  
  260.     }
  261.  
  262. }
  263.  
  264.  
  265. void OpenGLInit::HandleMouse(){
  266.  
  267.  
  268.  
  269. }
  270.  
  271.  
  272. //OpenGl
  273. void OpenGLInit::opengl_reset_scene(){
  274.  
  275.     if(this->iBreite == 0 || this->iHoehe == 0){
  276.  
  277.         this->iBreite = 1;
  278.         this->iHoehe = 1;
  279.  
  280.     }
  281.  
  282.     glViewport(0, 0, this->iBreite, this->iHoehe);
  283.     glMatrixMode(GL_PROJECTION);
  284.     glLoadIdentity();
  285.     gluPerspective( 45.0f, this->iBreite/this->iHoehe, 1.0f, 100.0f);
  286.  
  287.     glMatrixMode(GL_MODELVIEW);
  288.     glLoadIdentity();
  289.  
  290.     glEnable(GL_DEPTH_TEST);
  291.     glClearColor(0.0f, 0.3f, 0.8, 1.0f);
  292.  
  293. }
  294.  
  295.  
  296. void OpenGLInit::opengl_resize_scene( int iBreite, int iHoehe){
  297.  
  298.     if(iBreite == 0 || iHoehe == 0){
  299.  
  300.         iBreite = 1;
  301.         iHoehe = 1;
  302.  
  303.     }
  304.  
  305.     glViewport(0, 0, iBreite, iHoehe);
  306.     glMatrixMode(GL_PROJECTION);
  307.     glLoadIdentity();
  308.     gluPerspective( 45.0f, iBreite/iHoehe, 1.0f, 100.0f);
  309.  
  310.     glMatrixMode(GL_MODELVIEW);
  311.     glLoadIdentity();
  312.  
  313. }
  314.  
  315.  
  316. void OpenGLInit::opengl_draw_house(float fX, float fZ, float fY, float fR, float fG, float fB){
  317.  
  318.     glColor3f(0.5f, 0.5f, 0.0f);
  319.  
  320.     glBegin(GL_QUADS); 
  321.  
  322.         //<---Haus-Grundgerüst--->//
  323.         //Front
  324.         glColor3f(1.0f, 0.0f, 0.0f);
  325.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+1.0f);
  326.         glVertex3f(fX-1.0f, fZ-1.0f, fZ+1.0f);
  327.         glVertex3f(fX+1.0f, fZ-1.0f, fZ+1.0f);
  328.         glVertex3f(fX+1.0f, fZ+1.0f, fZ+1.0f);
  329.  
  330.         //Right
  331.         glColor3f(0.0f, 1.0f, 0.0f);
  332.         glVertex3f(fX+1.0f, fZ+1.0f, fZ+1.0f);
  333.         glVertex3f(fX+1.0f, fZ-1.0f, fZ+1.0f);
  334.         glVertex3f(fX+1.0f, fZ-1.0f, fZ-1.0f);
  335.         glVertex3f(fX+1.0f, fZ+1.0f, fZ-1.0f);
  336.  
  337.         //Back
  338.         glColor3f(1.0f, 0.0f, 0.0f);
  339.         glVertex3f(fX+1.0f, fZ+1.0f, fZ-1.0f);
  340.         glVertex3f(fX+1.0f, fZ-1.0f, fZ-1.0f);
  341.         glVertex3f(fX-1.0f, fZ-1.0f, fZ-1.0f);
  342.         glVertex3f(fX-1.0f, fZ+1.0f, fZ-1.0f);
  343.  
  344.         //Left
  345.         glColor3f(0.0f, 1.0f, 0.0f);
  346.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+1.0f);
  347.         glVertex3f(fX-1.0f, fZ+1.0f, fZ-1.0f);
  348.         glVertex3f(fX-1.0f, fZ-1.0f, fZ-1.0f);
  349.         glVertex3f(fX-1.0f, fZ-1.0f, fZ+1.0f);
  350.  
  351.         //Top
  352.         glColor3f(0.0f, 0.0f, 1.0f);
  353.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+1.0f);
  354.         glVertex3f(fX+1.0f, fZ+1.0f, fZ+1.0f);
  355.         glVertex3f(fX+1.0f, fZ+1.0f, fZ-1.0f);
  356.         glVertex3f(fX-1.0f, fZ+1.0f, fZ-1.0f);
  357.  
  358.         //Bottom
  359.         glColor3f(0.0f, 0.0f, 1.0f);
  360.         glVertex3f(fX-1.0f, fZ-1.0f, fZ+1.0f);
  361.         glVertex3f(fX+1.0f, fZ-1.0f, fZ+1.0f);
  362.         glVertex3f(fX+1.0f, fZ-1.0f, fZ-1.0f);
  363.         glVertex3f(fX-1.0f, fZ-1.0f, fZ-1.0f);
  364.  
  365.  
  366.         //<---Dach--->//
  367.         //Teil 1
  368.         glColor3f(0.7f, 0.0f, 0.3f);
  369.         glVertex3f(fX+0.0f, fZ+4.0f, fZ+0.0f);
  370.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+0.0f);
  371.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+1.0f);
  372.         glVertex3f(fX+0.0f, fZ+1.0f, fZ+0.0f);
  373.  
  374.         //Teil 2
  375.         glColor3f(0.7f, 0.0f, 0.3f);
  376.         glVertex3f(fX+0.0f, fZ+4.0f, fZ+0.0f);
  377.         glVertex3f(fX+1.0f, fZ+1.0f, fZ+0.0f);
  378.         glVertex3f(fX+1.0f, fZ+1.0f, fZ-1.0f);
  379.         glVertex3f(fX+0.0f, fZ+1.0f, fZ+0.0f);
  380.  
  381.         //Teil 3
  382.         glColor3f(0.7f, 0.0f, 0.3f);
  383.         glVertex3f(fX+0.0f, fZ+4.0f, fZ+0.0f);
  384.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+0.0f);
  385.         glVertex3f(fX-1.0f, fZ+1.0f, fZ+1.0f);
  386.         glVertex3f(fX+0.0f, fZ-1.0f, fZ+0.0f);
  387.  
  388.         //Teil 4
  389.         glColor3f(0.7f, 0.0f, 0.3f);
  390.         glVertex3f(fX+0.0f, fZ+4.0f, fZ+0.0f);
  391.         glVertex3f(fX+1.0f, fZ+1.0f, fZ+0.0f);
  392.         glVertex3f(fX+1.0f, fZ+1.0f, fZ+-1.0f);
  393.         glVertex3f(fX+0.0f, fZ-1.0f, fZ+0.0f);
  394.  
  395.     glEnd();
  396.  
  397. }
  398.  
  399.  
  400. void OpenGLInit::opengl_draw_tower(float fX, float fZ, float fY, float fR, float fG, float fB){
  401.  
  402.         glBegin(GL_QUADS); 
  403.  
  404.         //<---Tower-Grundgerüst--->//
  405.         //Front
  406.         glColor3f(1.0f, 0.0f, 0.0f);
  407.         glVertex3f(fX-1.0f, fZ+20.0f, fZ+1.0f);
  408.         glVertex3f(fX-1.0f, fZ+19.0f, fZ+1.0f);
  409.         glVertex3f(fX+1.0f, fZ+19.0f, fZ+1.0f);
  410.         glVertex3f(fX+1.0f, fZ+20.0f, fZ+1.0f);
  411.  
  412.         //Right
  413.         glColor3f(0.0f, 1.0f, 0.0f);
  414.         glVertex3f(fX+1.0f, fZ+20.0f, fZ+1.0f);
  415.         glVertex3f(fX+1.0f, fZ+19.0f, fZ+1.0f);
  416.         glVertex3f(fX+1.0f, fZ+19.0f, fZ-1.0f);
  417.         glVertex3f(fX+1.0f, fZ+20.0f, fZ-1.0f);
  418.  
  419.         //Back
  420.         glColor3f(1.0f, 0.0f, 0.0f);
  421.         glVertex3f(fX+1.0f, fZ+20.0f, fZ-1.0f);
  422.         glVertex3f(fX+1.0f, fZ-20.0f, fZ-1.0f);
  423.         glVertex3f(fX-1.0f, fZ-20.0f, fZ-1.0f);
  424.         glVertex3f(fX-1.0f, fZ+20.0f, fZ-1.0f);
  425.  
  426.         //Left
  427.         glColor3f(0.0f, 1.0f, 0.0f);
  428.         glVertex3f(fX-1.0f, fZ+20.0f, fZ+1.0f);
  429.         glVertex3f(fX-1.0f, fZ+20.0f, fZ-1.0f);
  430.         glVertex3f(fX-1.0f, fZ-20.0f, fZ-1.0f);
  431.         glVertex3f(fX-1.0f, fZ-20.0f, fZ+1.0f);
  432.  
  433.         //Top
  434.         glColor3f(0.0f, 0.0f, 1.0f);
  435.         glVertex3f(fX-1.0f, fZ+20.0f, fZ+1.0f);
  436.         glVertex3f(fX+1.0f, fZ+20.0f, fZ+1.0f);
  437.         glVertex3f(fX+1.0f, fZ+20.0f, fZ-1.0f);
  438.         glVertex3f(fX-1.0f, fZ+20.0f, fZ-1.0f);
  439.  
  440.         //Bottom
  441.         glColor3f(0.0f, 0.0f, 1.0f);
  442.         glVertex3f(fX-1.0f, fZ+19.0f, fZ+1.0f);
  443.         glVertex3f(fX+1.0f, fZ+19.0f, fZ+1.0f);
  444.         glVertex3f(fX+1.0f, fZ+19.0f, fZ-1.0f);
  445.         glVertex3f(fX-1.0f, fZ+19.0f, fZ-1.0f);
  446.  
  447.  
  448.         //<---Dach--->//
  449.         //Teil 1
  450.         glColor3f(0.7f, 0.0f, 0.3f);
  451.         glVertex3f(fX-1.0f, fZ+19.0f, fZ+1.0f);
  452.         glVertex3f(fX+1.0f, fZ+19.0f, fZ+1.0f);
  453.         glVertex3f(fX+1.0f, fZ+19.0f, fZ-1.0f);
  454.         glVertex3f(fX-1.0f, fZ+19.0f, fZ-1.0f);
  455.  
  456.     glEnd();
  457.  
  458.  
  459. }
  460.  
  461.  
  462. void OpenGLInit::opengl_draw_ground(float fR, float fG, float fB){
  463.  
  464.     glColor3f(fR, fG, fB);
  465.  
  466.     glBegin(GL_QUADS);
  467.  
  468.         glVertex3f(-125.0f, 0.0f, -125.0f);
  469.         glVertex3f(-125.0f, 0.0f, 125.0f);
  470.         glVertex3f(125.0f, 0.0f, 125.0f);
  471.         glVertex3f(125.0f, 0.0f, -125.0f);
  472.  
  473.     glEnd();
  474.  
  475.  
  476. }
  477.  
  478.  
  479. bool OpenGLInit::opengl_draw_scene(){
  480.  
  481.     //Allgemein
  482.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  483.     glColor3f(1.0f, 1.0f, 1.0f);
  484.  
  485.     glMatrixMode(GL_MODELVIEW);
  486.     glLoadIdentity();
  487.  
  488.     glRotatef(360 - fRotateY, 0.0f, 1.0f, 0.0f);
  489.     glTranslatef( -fTransX, fTransY, -fTransZ);
  490.  
  491.     opengl_draw_ground(0.4f, 0.3f, 0.3f);
  492.  
  493.     opengl_draw_house(0.0f, 1.0f, -20.0f, 0.0f, 0.0f, 0.0f);
  494.     opengl_draw_house(4.0f, 1.0f, -40.0f, 0.0f, 0.0f, 0.0f);
  495.     opengl_draw_house(-7.0f, 1.0f, -35.0f, 0.0f, 0.0f, 0.0f);
  496.     opengl_draw_tower(-15.0f, 1.0f, -15.0f, 0.0f, 0.0f, 0.0f);
  497.     opengl_draw_tower(-12.0f, 1.0f, -19.0f, 0.0f, 0.0f, 0.0f);
  498.    
  499.     return true;
  500.  
  501. }
  502.  
  503.  
  504.  
  505.  
  506. //<-------------OpenGLInit_H------------->//
  507.  
  508.  
  509. //<---Class--->//
  510. class OpenGLInit{
  511.  
  512.     private:
  513.         //Generell
  514.         HWND        hWnd;
  515.         WNDCLASSEX  WndClassEx;
  516.         char        szClassName[30];
  517.         char        szWindowTitle[30];
  518.         int         iHoehe;
  519.         int         iBreite;
  520.         MSG         msg;
  521.         bool        bKeys[256];
  522.  
  523.         //OpenGl
  524.         HDC                     hDC;
  525.         HGLRC                   hGLRC;
  526.         PIXELFORMATDESCRIPTOR   pfd;
  527.         int                     iFormat;
  528.         DEVMODE                 dmSettings;
  529.         RECT                    rect;
  530.         DWORD                   dwStyle;
  531.         float                   fRotateY;
  532.         float                   fTransX;
  533.         float                   fTransY;
  534.         float                   fTransZ;
  535.         float                   fPi180;
  536.  
  537.     public:
  538.         //Constructor
  539.         OpenGLInit();
  540.  
  541.         //Variablen Funktionen
  542.         inline HDC get_hDC();
  543.         inline RECT get_rect();
  544.         inline int get_iHoehe();
  545.         inline int get_iBreite();
  546.         void set_rect(int iWidth, int iHeight, bool bFullscreen);
  547.  
  548.  
  549.         //Generelle Funktionen
  550.         LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  551.         static LRESULT CALLBACK StaticWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  552.         bool screen_setup(HINSTANCE hInst, int iCmdShow, int iHoehe, int iBreite);
  553.         void opengl_setup();
  554.         unsigned char key_pressed();
  555.         void HandleKeyboard();
  556.         void HandleMouse();
  557.  
  558.         //OpenGl
  559.         void opengl_reset_scene();
  560.         void opengl_resize_scene( int iBreite, int iHoehe);
  561.         void opengl_draw_house(float fX, float fZ, float fY, float fR, float fG, float fB);
  562.         void opengl_draw_tower(float fX, float fZ, float fY, float fR, float fG, float fB);
  563.         void opengl_draw_ground(float fR, float fG, float fB);
  564.         bool opengl_draw_scene();
  565.  
  566. };
  567.  
  568.  
  569.  
  570.  
  571. //<-------------STDAFX_H------------->//
  572.  
  573. #ifndef STDAFX_H
  574. #define STDAFX_H
  575.  
  576.  
  577. //<---Includes--->//
  578. #include <Windows.h>
  579. #include <gl\gl.h>
  580. #include <gl\glu.h>
  581. #include <math.h>
  582. //<---Pragmas--->//
  583. #pragma comment(lib, "opengl.lib")
  584. #pragma comment(lib, "glu.lib")
  585. //#pragma comment(lib, "glut32.lib")
  586.  
  587.  
  588. //<---Variablen--->//
  589. /*char      "Error!"[] = "Error!";
  590. char        "Fehler beim Setup des Fensters!"[] = "Fehler beim Setup des Fensters!";
  591. char        "Fehler beim Setup von OpenGl!"[] = "Fehler beim Setup von OpenGl!";
  592. char        "Fehler beim Registrieren des Fensters"[] = "Fehler beim erstellen des Fensters";
  593. char        "Fehler beim Erstellen des Fensters!"[] = "Fehler beim erstellen des Fensters!";*/
  594.  
  595. #endif
  596.  
  597.  
  598.  
  599.  
  600. //<-------------MAIN_CPP------------->//
  601.  
  602.  
  603. #include "StdAfx.h"
  604. #include "OpenGLInit.h"
  605.  
  606.  
  607. int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int iCmdShow){
  608.  
  609.     OpenGLInit OpenGL_Start;
  610.  
  611.     //Fullscreen?
  612.     if(MessageBox(NULL, "Programm in Fullscreen?", "Fullscreen?", MB_YESNO | MB_ICONINFORMATION) == IDNO){
  613.  
  614.         OpenGL_Start.set_rect(OpenGL_Start.get_iHoehe(), OpenGL_Start.get_iBreite(), false);
  615.  
  616.     }
  617.     else{
  618.  
  619.         OpenGL_Start.set_rect(0, 0, true);
  620.  
  621.     }
  622.  
  623.  
  624.     //<---Fenster+OpenGl--->//
  625.     //Fenster+OpenGl Setup
  626.     if(!OpenGL_Start.screen_setup(hInst, iCmdShow, OpenGL_Start.get_rect().right, OpenGL_Start.get_rect().bottom)){
  627.  
  628.         MessageBox(NULL, "Error!", "Fehler beim Setup des Fensters!", MB_ICONERROR | MB_OK);
  629.         return false;
  630.  
  631.     }
  632.  
  633.     OpenGL_Start.opengl_setup();
  634.  
  635.     OpenGL_Start.opengl_reset_scene();
  636.  
  637.     //Fenster ausgeben
  638.     while(true){
  639.  
  640.         if(OpenGL_Start.key_pressed()){
  641.  
  642.             break;
  643.            
  644.         }
  645.         else{
  646.  
  647.             OpenGL_Start.HandleKeyboard();
  648.             if(!OpenGL_Start.opengl_draw_scene()){
  649.            
  650.                 break;
  651.  
  652.             }
  653.             else{
  654.  
  655.                 SwapBuffers(OpenGL_Start.get_hDC());
  656.  
  657.             }
  658.  
  659.         }
  660.  
  661.     }
  662.  
  663.    
  664.     //<---Ende--->//
  665.     MessageBox(NULL, "Programm wird beendet", "Programm Ende", MB_ICONINFORMATION | MB_OK);
  666.  
  667.     return 0;
  668.    
  669. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement