Help! Where does it go?

This is a discussion on Help! Where does it go? within the C++ Programming forums, part of the General Programming Boards category; I got this code for making windows: Code: #include <windows.h> #include <gl\gl.h> #include <gl\glu.h> #include <gl\glaux.h> const char g_szClassName[] = ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    40

    Help! Where does it go?

    I got this code for making windows:
    Code:
    #include <windows.h>
    #include <gl\gl.h>
    #include <gl\glu.h>
    #include <gl\glaux.h>
    
    const char g_szClassName[] = "My Window Class";
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    const char icon[] = "icon.ico";
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
       WNDCLASSEX wc;
          wc.cbSize = sizeof(WNDCLASSEX);
          wc.style = 0;
          wc.lpfnWndProc = WndProc;
          wc.cbClsExtra = 0;
          wc.cbWndExtra = 0;
          wc.hInstance = hInstance;
          wc.hIcon = LoadIcon(NULL, icon);
          wc.hCursor = LoadCursor(NULL, IDC_ARROW);
          wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
          wc.lpszMenuName = NULL;
          wc.lpszClassName = g_szClassName;
          wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    
       if(!RegisterClassEx(&wc))
       {
          MessageBox(NULL, "Failed to register window class", "Error", MB_ICONEXCLAMATION | MB_OK);
          return 0;
       }
       HWND hwnd;
       hwnd = CreateWindowEx(
             WS_EX_CLIENTEDGE,
             g_szClassName,
             "My Window Mofo",
             WS_OVERLAPPEDWINDOW,
             CW_USEDEFAULT, CW_USEDEFAULT, 400, 400,
             NULL, NULL,
             hInstance, NULL
          );
    
       if(hwnd == NULL)
       {
          MessageBox(NULL, "Failed to create window", "Error", MB_ICONEXCLAMATION | MB_OK);
          return 0;
       }
       ShowWindow(hwnd, nCmdShow);
       UpdateWindow(hwnd);
          MSG Msg;
          while(GetMessage(&Msg, NULL, 0, 0))
          {
             TranslateMessage(&Msg);
             DispatchMessage(&Msg);
          }
       return Msg.wParam;
    }
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
       switch(msg)
       {
          case WM_CLOSE:
             DestroyWindow(hwnd);
          case WM_DESTROY:
             PostQuitMessage(0);
             break;
          default:
             return DefWindowProc(hwnd, msg, wParam, lParam);
       }
       return 0;
    }
    It works fine. Now, I'm reading the redbook, from which I got this:
    Code:
    glClearColor (0.0, 0.0, 0.0, 0.0);
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 1.0, 1.0);
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glVertex3f (0.25, 0.25, 0.0);
    glVertex3f (0.75, 0.25, 0.0);
    glVertex3f (0.75, 0.75, 0.0);
    glVertex3f (0.25, 0.75, 0.0);
    glEnd();
    glFlush();
    Where in the first code would I put the second in order for it to work?
    Code:
    #include <iostream.h>
    int var;
    int test();
    int main() { 
     cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n";
     cin >> var;
     return test(); }
    int test() {  
     if(var == 1) {
      cout << "Y0u 4r3 t3h 1337\n";
      system("PAUSE");
      return main(); }
     else if(var == 2) {
      cout << "N00B3R!\n";
      system("PAUSE");
      return main(); }
     else if(var == 3) {
      cout << "You were not thought of.\n";
      system("PAUSE");
      return main(); }
     else {      
      return 0; }}

  2. #2
    WDT
    WDT is offline
    Tha 1 Sick RAT
    Join Date
    Dec 2003
    Posts
    271
    take a look at this tutorial and download the pdf from this site. That'll more than solve your problems.
    Last edited by WDT; 03-14-2004 at 10:15 PM.
    A hundred Elephants can knock down the walls of a fortress... One diseased rat can kill everyone inside

  3. #3
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    op, do you have any idea what the hell you are doing??

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21