problem mit erstellen mehrer GL_LINES, brauche hilfe!



  • hi, ich hab da nen problem. und zwar möchte ich den wert den ich aus meiner
    DialogBox gelesen habe in eine GL_LINES packen. klapp im mom auch super.

    int CreateVector( float _p1x, float _p1y, float _p1z, float _p2x, float _p2y,
                      float _p2z ) {
    
        glLineWidth( 5.0f );
    
        glColor3ub( r, g, b1 );
        glBegin( GL_LINES );
    
            glVertex3f( _p1x, _p1y, _p1z );
            glVertex3f( _p2x, _p2y, _p2z );
        glEnd();
    
        glLineWidth( 2.0f );
        glColor3ub( 255, 255, 255 );
        glRasterPos3f( _p1x, _p1y, _p1z );
        glPrint( "P1( %0.1f", a );
        glPrint( " / %0.1f", b);
        glPrint( " / %0.1f", c);
        glPrint( " ) ");
    
        glColor3ub( 255, 0, 0 );
        glBegin( GL_LINES );
    
            glVertex3f( _p1x -2.0f, _p1y, _p1z );
            glVertex3f( _p1x +2.0f, _p1y, _p1z );
    
            glVertex3f( _p1x, _p1y -2.0f, _p1z );
            glVertex3f( _p1x, _p1y +2.0f, _p1z );
    
            glVertex3f( _p1x, _p1y, _p1z -2.0f );
            glVertex3f( _p1x, _p1y, _p1z +2.0f );
        glEnd();
    
        glLineWidth( 2.0f );
        glColor3ub( 255, 255, 255 );
        glRasterPos3f( _p2x, _p2y, _p2z );
        glPrint( "P2( %0.1f", d );
        glPrint( " / %0.1f", e);
        glPrint( " / %0.1f", f);
        glPrint( " ) ");
    
        glColor3ub( 255, 0, 0 );
        glBegin( GL_LINES );
            glVertex3f( _p2x -2.0f, _p2y, _p2z );
            glVertex3f( _p2x +2.0f, _p2y, _p2z );
    
            glVertex3f( _p2x, _p2y -2.0f, _p2z );
            glVertex3f( _p2x, _p2y +2.0f, _p2z );
    
            glVertex3f( _p2x, _p2y, _p2z -2.0f );
            glVertex3f( _p2x, _p2y, _p2z +2.0f );
    
        glEnd();
    
        return 0;
    }
    

    dann wollte ich eine Funktion basteln die immer neue linien zeichnet und nich
    immer die vorhandene aendert.

    int NewVector() {
    
        float *xp1 = new float;
        float *yp1 = new float;
        float *zp1 = new float;
        float *xp2 = new float;
        float *yp2 = new float;
        float *zp2 = new float;
    
        *xp1 = a;
        *yp1 = b;
        *zp1 = c;
        *xp2 = d;
        *yp2 = e;
        *zp2 = f;
    
        return( CreateVector( *xp1, *yp1, *zp1, *xp2, *yp2, *zp2 ) );
    }
    

    aber es klappt nicht, könnte mir hier bei jemand mal helfen. danke!



  • T0bi schrieb:

    int NewVector() {
    
        float *xp1 = new float;
        float *yp1 = new float;
        float *zp1 = new float;
        float *xp2 = new float;
        float *yp2 = new float;
        float *zp2 = new float;
    
        *xp1 = a;
        *yp1 = b;
        *zp1 = c;
        *xp2 = d;
        *yp2 = e;
        *zp2 = f;
    
        return( CreateVector( *xp1, *yp1, *zp1, *xp2, *yp2, *zp2 ) );
    }
    

    Woher kommen a bis d?
    Warum erstellst du floats mit new und verwirfst danach den Zeiger? Das ist ein Speicherleck.
    Warum übergibtst du nicht gleich a bis d an CreateVector?

    mfg.



  • hmm aja jo hehe könnte ich machen gg.... aba ich muesste doch dann
    CreateVector(...) irgendwie mit new return oder? damit ich dann immer eine neue linie zeichne... abe ich weissnet wie



  • T0bi schrieb:

    hmm aja jo hehe könnte ich machen gg....

    Was heißt gg?

    aba ich muesste doch dann
    CreateVector(...) irgendwie mit new return oder? damit ich dann immer eine neue linie zeichne... abe ich weissnet wie

    Hä?

    Also wie sieht denn dein restliches Programm aus? Wo wird NewVector() aufgerufen? Bist du sicher dass du jede Zeile in deinem Programm verstehst???

    mfg.



  • hier der code:

    #include <windows.h>
    #include <GL\gl.h>
    #include <GL\glu.h>
    #include <GL\glaux.h>
    #include <string.h>
    #include <stdio.h>
    #include <stdarg.h>
    #include <conio.h>
    #include <ctime>
    
    const char szAppName[] = "OpenGL";
    
    bool fullscreen = false;
    bool active = true;
    bool keys[256];
    
    unsigned int base; // Base Display List For The Font Set
    void ReSizeGL( GLsizei width, GLsizei height );
    void KillGL();
    void Room( float x, float y, float z );
    
    int InitGL();
    int DrawGL();
    int CreateVector( float _p1x, float _p1y, float _p1z, float _p2x, float _p2y,
                      float _p2z );
    int NewVector();
    
    bool CreateGL( const char *title, int width, int height, int bits, bool mode );
    
    HINSTANCE hInstance;
    HWND hWnd;
    HDC hDC;
    HGLRC hRC;
    
    char p1_x_coor[6];
    char p1_y_coor[6];
    char p1_z_coor[6];
    
    char p2_x_coor[6];
    char p2_y_coor[6];
    char p2_z_coor[6];
    
    static float zoom = -100.0f;
    static float RX =  15.0f;
    static float RY = -15.0f;
    
    float a, b, c, d, e, f;
    
    int r, g, b1;
    
    LRESULT CALLBACK WinProc( HWND, UINT, WPARAM, LPARAM );
    LRESULT CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );
    
    WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
                    int nCmdShow ) {
        srand( time( 0 ) );
        MSG msg;
        r = rand() % 255;
        g = rand() % 255;
        b1 = rand() % 255;
        bool quit = false;
    
        CreateGL( " Objekt im Raum ", 640, 480, 32, fullscreen );
    
        while( !quit ) {
    
            if( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) {
    
                if( msg.message == WM_QUIT ) {
    
                    quit = true;
                }
                else {
    
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
            }
            else {
    
                if( active ) {
    
                    if( keys[VK_ESCAPE] ) {
    
                        quit = true;
                    }
                    else {
    
                        DrawGL();
                        SwapBuffers( hDC );
                    }
    
                    if( keys[VK_F1] ) {
    
                        keys[VK_F1] = false;
                        KillGL();
                        fullscreen = !fullscreen;
    
                        if( fullscreen ) {
    
                            CreateGL( " Objekt im Raum ", 800, 600, 16, fullscreen );
                        }
                        else {
    
                            CreateGL( " Objekt im Raum ", 640, 480, 32, fullscreen );
                        }
                    }
    
                    if( keys[ VK_PRIOR ] ) {
    
                        if( zoom < 0.0f ) {
    
                            zoom += 1.0f;
                        }
                    }
    
                    if( keys[ VK_NEXT ] ) {
    
                        if(  zoom > -500.0f  ) {
    
                            zoom -= 1.0f;
                        }
                    }
    
                    if( keys[ VK_LEFT ] ) {
    
                        RY += 0.01f;
                    }
    
                    if( keys[ VK_RIGHT ] ) {
    
                        RY -= 0.01f;
                    }
    
                    if( keys[ VK_DOWN ] ) {
    
                        RX += 0.01f;
                    }
    
                    if( keys[ VK_UP ] ) {
    
                        RX -= 0.01f;
                    }
                }
            }
        }
        KillGL();
        return msg.wParam;
    }
    
    void BuildFont() {
    
    	[...]
    }
    
    void KillFont() {
    
    	[...]
    }
    
    void ReSizeGL( GLsizei width, GLsizei height ) {
    
    	[...]
    }
    
    int InitGL() {
    
    	[...]
    }
    
    int DrawGL() {
    
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
        glTranslatef( 0.0f, 0.0f, zoom );
        glRotatef( RX, 1.0f, 0.0f, 0.0f );
        glRotatef( RY, 0.0f, 1.0f, 0.0f );
        glColor3ub( 100, 100, 100 );
        glBegin( GL_QUADS );
    
            glVertex3f(  100.0f, -50.0f, -100.0f );
            glVertex3f( -100.0f, -50.0f, -100.0f );
            glVertex3f( -100.0f, -50.0f,  100.0f );
            glVertex3f(  100.0f, -50.0f,  100.0f );
        glEnd();
        Room( 100.f, 50.0f, 100.0f );
    
     //   CreateVector( a, b, c, d, e, f );
        NewVector();
    
        glLoadIdentity();
        return 0;
    }
    
    void KillGL() {
    
    	[...]
    }
    
    bool CreateGL( const char *title, int width, int height, int bits, bool mode ) {
    
    	[...]
    }
    
    LRESULT CALLBACK WinProc( HWND hWnd, UINT message, WPARAM wParam,
                              LPARAM lParam ) {
    
        switch( message ) {
    
    	[...]
        }
        return DefWindowProc( hWnd, message, wParam, lParam );
    }
    
    LRESULT CALLBACK DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
    
        char *end_p ;
    
        switch( msg ) {
    
            case WM_INITDIALOG: {
    
                SetDlgItemText( hWnd, 110, "-10.0" );
                SetDlgItemText( hWnd, 120, "-20.0" );
                SetDlgItemText( hWnd, 130, "-30.0" );
                SetDlgItemText( hWnd, 140, "9.0" );
                SetDlgItemText( hWnd, 150, "10.0" );
                SetDlgItemText( hWnd, 160, "11.0" );
                return true;
            }
            case WM_COMMAND: {
    
                switch( wParam ) {
    
                    case IDOK: {
    
                        GetDlgItemText( hWnd, 110, p1_x_coor, sizeof( p1_x_coor ) );
                        a = (float) strtol (p1_x_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 120, p1_y_coor, sizeof( p1_y_coor ) );
                        b = (float) strtol (p1_y_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 130, p1_z_coor, sizeof( p1_z_coor ) );
                        c = (float) strtol (p1_z_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 140, p2_x_coor, sizeof( p2_x_coor ) );
                        d = (float) strtol (p2_x_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 150, p2_y_coor, sizeof( p2_y_coor ) );
                        e = (float) strtol (p2_y_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 160, p2_z_coor, sizeof( p2_z_coor ) );
                        f = (float) strtol (p2_z_coor , &end_p , 10) ;
                        EndDialog( hWnd, 1 );
                        return true;
                    }
    
                    case IDCANCEL: {
    
                        EndDialog( hWnd, 0 );
                        return true;
                    }
    
                    case IDRETRY: {
    
                        MessageBox( 0,
                                    " HELP:\n\n"
                                    " Empfehlung:\n"
                                    " Es werden Werte der Größe 50.0 bis -50.0 empfohlen.\n\n"
                                    " Tasten:\n"
                                    " ZOOM +          BILD HOCH\n"
                                    " ZOOM -           BILD RUNTER\n"
                                    " Dehen links      Pfeil-Taste-LINKS\n"
                                    " Dehen rechts   Pfeil-Taste-RECHTS\n"
                                    " Drehen hoch    Pfeil-Taste-HOCH\n"
                                    " Drehen runter  Pfeil-Taste-RUNTER\n",
                                    " Help! ", MB_OK | MB_ICONINFORMATION );
                        return true;
                    }
                }
                return true;
            }
        }
        return false;
    }
    
    void Room( float x, float y, float z ) {
    
    	[...]
    
    }
    
    int CreateVector( float _p1x, float _p1y, float _p1z, float _p2x, float _p2y,
                      float _p2z ) {
    
        glLineWidth( 5.0f );
    
        glColor3ub( r, g, b1 );
        glBegin( GL_LINES );
    
            glVertex3f( _p1x, _p1y, _p1z );
            glVertex3f( _p2x, _p2y, _p2z );
        glEnd();
    
        glLineWidth( 2.0f );
        glColor3ub( 255, 255, 255 );
        glRasterPos3f( _p1x, _p1y, _p1z );
        glPrint( "P1( %0.1f", a );
        glPrint( " / %0.1f", b);
        glPrint( " / %0.1f", c);
        glPrint( " ) ");
    
        glColor3ub( 255, 0, 0 );
        glBegin( GL_LINES );
    
            glVertex3f( _p1x -2.0f, _p1y, _p1z );
            glVertex3f( _p1x +2.0f, _p1y, _p1z );
    
            glVertex3f( _p1x, _p1y -2.0f, _p1z );
            glVertex3f( _p1x, _p1y +2.0f, _p1z );
    
            glVertex3f( _p1x, _p1y, _p1z -2.0f );
            glVertex3f( _p1x, _p1y, _p1z +2.0f );
        glEnd();
    
        glLineWidth( 2.0f );
        glColor3ub( 255, 255, 255 );
        glRasterPos3f( _p2x, _p2y, _p2z );
        glPrint( "P2( %0.1f", d );
        glPrint( " / %0.1f", e);
        glPrint( " / %0.1f", f);
        glPrint( " ) ");
    
        glColor3ub( 255, 0, 0 );
        glBegin( GL_LINES );
            glVertex3f( _p2x -2.0f, _p2y, _p2z );
            glVertex3f( _p2x +2.0f, _p2y, _p2z );
    
            glVertex3f( _p2x, _p2y -2.0f, _p2z );
            glVertex3f( _p2x, _p2y +2.0f, _p2z );
    
            glVertex3f( _p2x, _p2y, _p2z -2.0f );
            glVertex3f( _p2x, _p2y, _p2z +2.0f );
    
        glEnd();
    
        return 0;
    }
    
    int NewVector() {
    
        return( CreateVector( a, b, c, d, e, f ) );
    }
    

    und dann will ich bei jedem Mal bei bestätigung der DlgBox einen neunen Vector eingetragen haben.



  • hallo ??? 😕



  • bitte so dass ich das compilieren kann. Wenn's zu viel ist dann lad die Datei hoch oder benutze einen nopaste Service.

    mfg.



  • also die .cpp:

    #include <windows.h>
    #include <GL\gl.h>
    #include <GL\glu.h>
    #include <GL\glaux.h>
    #include <string.h>
    #include <stdio.h>
    #include <stdarg.h>
    #include <conio.h>
    #include <ctime>
    
    const char szAppName[] = "OpenGL";
    
    bool fullscreen = false;
    bool active = true;
    bool keys[256];
    
    unsigned int base; // Base Display List For The Font Set
    void ReSizeGL( GLsizei width, GLsizei height );
    void KillGL();
    void Room( float x, float y, float z );
    
    int InitGL();
    int DrawGL();
    int CreateVector( float _p1x, float _p1y, float _p1z, float _p2x, float _p2y,
                      float _p2z );
    int NewVector();
    
    bool CreateGL( const char *title, int width, int height, int bits, bool mode );
    
    HINSTANCE hInstance;
    HWND hWnd;
    HDC hDC;
    HGLRC hRC;
    
    char p1_x_coor[6];
    char p1_y_coor[6];
    char p1_z_coor[6];
    
    char p2_x_coor[6];
    char p2_y_coor[6];
    char p2_z_coor[6];
    
    static float zoom = -100.0f;
    static float RX =  15.0f;
    static float RY = -15.0f;
    
    float a, b, c, d, e, f;
    
    int r, g, b1;
    
    LRESULT CALLBACK WinProc( HWND, UINT, WPARAM, LPARAM );
    LRESULT CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );
    
    WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
                    int nCmdShow ) {
        srand( time( 0 ) );
        MSG msg;
        r = rand() % 255;
        g = rand() % 255;
        b1 = rand() % 255;
        bool quit = false;
    
        CreateGL( " Objekt im Raum ", 640, 480, 32, fullscreen );
    
        while( !quit ) {
    
            if( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) {
    
                if( msg.message == WM_QUIT ) {
    
                    quit = true;
                }
                else {
    
                    TranslateMessage( &msg );
                    DispatchMessage( &msg );
                }
            }
            else {
    
                if( active ) {
    
                    if( keys[VK_ESCAPE] ) {
    
                        quit = true;
                    }
                    else {
    
                        DrawGL();
                        SwapBuffers( hDC );
                    }
    
                    if( keys[VK_F1] ) {
    
                        keys[VK_F1] = false;
                        KillGL();
                        fullscreen = !fullscreen;
    
                        if( fullscreen ) {
    
                            CreateGL( " Objekt im Raum ", 800, 600, 16, fullscreen );
                        }
                        else {
    
                            CreateGL( " Objekt im Raum ", 640, 480, 32, fullscreen );
                        }
                    }
    
                    if( keys[ VK_PRIOR ] ) {
    
                        if( zoom < 0.0f ) {
    
                            zoom += 1.0f;
                        }
                    }
    
                    if( keys[ VK_NEXT ] ) {
    
                        if(  zoom > -500.0f  ) {
    
                            zoom -= 1.0f;
                        }
                    }
    
                    if( keys[ VK_LEFT ] ) {
    
                        RY += 0.01f;
                    }
    
                    if( keys[ VK_RIGHT ] ) {
    
                        RY -= 0.01f;
                    }
    
                    if( keys[ VK_DOWN ] ) {
    
                        RX += 0.01f;
                    }
    
                    if( keys[ VK_UP ] ) {
    
                        RX -= 0.01f;
                    }
                }
            }
        }
        KillGL();
        return msg.wParam;
    }
    
    void BuildFont() {
    
        HFONT font; // ???
        HFONT oldfont; // ???
        base = glGenLists(96); // 96 Zeichen
        font = CreateFont( 18, // Größe
        0, // Breite
        0, // Buchstaben kippen
        0, // ??? ("Orientation Angle")
        0, // Dicke der Buchstaben, 0 bis 1.000
        FALSE, //kursiv
        FALSE, // unterstreichen
        FALSE, // durchstreichen
        ANSI_CHARSET, // Zeichen- Set
        OUT_TT_PRECIS, // Verhalten bei mehreren Fonts
        CLIP_DEFAULT_PRECIS, // ???
        ANTIALIASED_QUALITY, // Qualität des Schriftzuges
        FF_DONTCARE|DEFAULT_PITCH, // Family und Pitch - Einstellungen
        "Arial Black"); // Font
    
        oldfont = (HFONT)SelectObject(hDC, font); // unser Font
        wglUseFontBitmaps(hDC, 32, 96, base); // 96 Zeichen, gezählt ab dem Leerzeichen (32.)
        SelectObject(hDC, oldfont); // unser Font
        DeleteObject(font); // Font wird gelöscht
    
    }
    
    void KillFont() {
    
        glDeleteLists(base, 96); // alle 96 Zeichen löschen
    }
    
    void glPrint(const char *fmt, ...) {
    
        char text[256]; // Text
        va_list ap; // Pointer für die Variablen
    
        if (fmt == NULL) // kein Text da?
        return; // dann mach nix.
    
        va_start(ap, fmt);
        vsprintf(text, fmt, ap);
        va_end(ap);
    
        glPushAttrib(GL_LIST_BIT); // Beeinflußung
        glListBase(base - 32); // weg mit den Steuerungszeichen
        glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Text zeichnen
        glPopAttrib(); // alles auf Standart zurücksetzen
    
    }
    
    void ReSizeGL( GLsizei width, GLsizei height ) {
    
        if( height == 0 ) {
    
            height = 1;
        }
    
        glViewport( 0, 0, width, height );
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
    
        gluPerspective( 45.0f, (float) width / (float) height, 0.1f, 1000.0f );
    
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();
    }
    
    int InitGL() {
    
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
        glClearDepth( 1.0f );
        glDepthFunc( GL_LEQUAL );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE );
        glShadeModel( GL_SMOOTH );
        glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
    
        glEnable( GL_DEPTH_TEST );
    
        BuildFont();
        return 0;
    }
    
    int DrawGL() {
    
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    
        glTranslatef( 0.0f, 0.0f, zoom );
        glRotatef( RX, 1.0f, 0.0f, 0.0f );
        glRotatef( RY, 0.0f, 1.0f, 0.0f );
        glColor3ub( 100, 100, 100 );
        glBegin( GL_QUADS );
    
            glVertex3f(  100.0f, -50.0f, -100.0f );
            glVertex3f( -100.0f, -50.0f, -100.0f );
            glVertex3f( -100.0f, -50.0f,  100.0f );
            glVertex3f(  100.0f, -50.0f,  100.0f );
        glEnd();
        Room( 100.f, 50.0f, 100.0f );
    
     //   CreateVector( a, b, c, d, e, f );
        NewVector();
    
        glLoadIdentity();
        return 0;
    }
    
    void KillGL() {
    
        KillFont();
    
        if( fullscreen ) {
    
            ChangeDisplaySettings( 0, 0 );
            ShowCursor( true );
        }
    
        wglMakeCurrent( 0, 0 );
        wglDeleteContext( hRC );
        hRC = 0;
    
        ReleaseDC( hWnd, hDC );
        hDC = 0;
    
        DestroyWindow( hWnd );
        hWnd = 0;
    
        UnregisterClass( szAppName, hInstance );
        hInstance = 0;
    }
    
    bool CreateGL( const char *title, int width, int height, int bits, bool mode ) {
    
        unsigned int PixelFormat;
        static RECT wndr;
        DWORD ExStyle;
        DWORD Style;
        WNDCLASS wc;
    
        hInstance = GetModuleHandle( 0 );
        fullscreen = mode;
    
            wndr.left = (long) 0;
            wndr.top = (long) 0;
            wndr.right = (long) width;
            wndr.bottom = (long) height;
    
        wc.lpszClassName = szAppName;
        wc.lpszMenuName = "Userm";
        wc.lpfnWndProc = WinProc;
        wc.hInstance = hInstance;
        wc.hIcon = LoadIcon( 0, IDI_APPLICATION );
        wc.hCursor = LoadCursor( 0, IDC_ARROW );
        wc.hbrBackground = 0;
        wc.cbClsExtra = 0;
        wc.cbWndExtra = 0;
        wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
    
        RegisterClass( &wc );
    
        if( fullscreen ) {
    
            DEVMODE dmSettings;
            memset( &dmSettings, 0, sizeof( dmSettings ) );
    
            dmSettings.dmSize = sizeof( dmSettings );
            dmSettings.dmPelsWidth = width;
            dmSettings.dmPelsHeight = height;
            dmSettings.dmBitsPerPel = bits;
            dmSettings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
    
            ChangeDisplaySettings( &dmSettings, CDS_FULLSCREEN );
        }
    
        if( fullscreen ) {
    
            ExStyle = WS_EX_APPWINDOW;
            Style = WS_POPUP;
            ShowCursor( false );
        }
        else {
    
            ExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
            Style = WS_OVERLAPPEDWINDOW;
        }
    
        hWnd = CreateWindowEx( ExStyle,
                               szAppName,
                               title,
                               WS_CLIPCHILDREN | WS_CLIPSIBLINGS | Style,
                               0, 0,
                               wndr.right - wndr.left, wndr.bottom - wndr.top,
                               0,
                               0,
                               hInstance,
                               0 );
    
        static PIXELFORMATDESCRIPTOR pfd = {
    
            sizeof( PIXELFORMATDESCRIPTOR ),
            1,
            PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
            PFD_TYPE_RGBA,
            bits,
            0, 0, 0, 0, 0, 0,
            0,
            0,
            0,
            0, 0, 0, 0,
            16,
            0,
            0,
            PFD_MAIN_PLANE,
            0,
            0, 0, 0
        };
    
        hDC = GetDC( hWnd );
        PixelFormat = ChoosePixelFormat( hDC, &pfd );
        SetPixelFormat( hDC, PixelFormat, &pfd );
    
        hRC = wglCreateContext( hDC );
        wglMakeCurrent( hDC, hRC );
    
        ShowWindow( hWnd, SW_SHOW );
        UpdateWindow( hWnd );
    
        ReSizeGL( width, height );
        InitGL();
    
        return true;
    }
    
    LRESULT CALLBACK WinProc( HWND hWnd, UINT message, WPARAM wParam,
                              LPARAM lParam ) {
    
        switch( message ) {
    
            case WM_CREATE: {
    
                DialogBox( hInstance , "Dialog", hWnd ,
                           MakeProcInstance( (DLGPROC)DlgProc , hInstance )) ;
                return 0;
            }
    
            case WM_ACTIVATE: {
    
                if( !( HIWORD( wParam ) ) ) {
    
                    active = true;
                }
                else {
    
                    active = false;
                }
                return 0;
            }
    
            case WM_SIZE: {
    
                ReSizeGL( LOWORD( lParam ), HIWORD( lParam ) );
                return 0;
            }
    
            case WM_SYSCOMMAND: {
    
                switch( wParam ) {
    
                    case SC_SCREENSAVE:
                    case SC_MONITORPOWER:
                    return 0;
                }
                break;
            }
    
            case WM_COMMAND: {
    
                switch( LOWORD( wParam ) ) {
    
                    case 1000: {
    
                        SendMessage( hWnd, WM_CLOSE, 0, 0 );
                        return 0;
                    }
                    case 1100: {
    
                        DialogBox( hInstance , "Dialog", hWnd ,
                                   MakeProcInstance( (DLGPROC)DlgProc , hInstance )) ;
                        return 0;
                    }
                }
                return 0;
            }
    
            case WM_KEYDOWN: {
    
                keys[wParam] = true;
                return 0;
            }
    
            case WM_KEYUP: {
    
                keys[wParam] = false;
                return 0;
            }
    
            case WM_CLOSE: {
    
                PostQuitMessage( 0 );
                return 0;
            }
        }
        return DefWindowProc( hWnd, message, wParam, lParam );
    }
    
    LRESULT CALLBACK DlgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
    
        char *end_p ;
    
        switch( msg ) {
    
            case WM_INITDIALOG: {
    
                SetDlgItemText( hWnd, 110, "-10.0" );
                SetDlgItemText( hWnd, 120, "-20.0" );
                SetDlgItemText( hWnd, 130, "-30.0" );
                SetDlgItemText( hWnd, 140, "9.0" );
                SetDlgItemText( hWnd, 150, "10.0" );
                SetDlgItemText( hWnd, 160, "11.0" );
                return true;
            }
            case WM_COMMAND: {
    
                switch( wParam ) {
    
                    case IDOK: {
    
                        GetDlgItemText( hWnd, 110, p1_x_coor, sizeof( p1_x_coor ) );
                        a = (float) strtol (p1_x_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 120, p1_y_coor, sizeof( p1_y_coor ) );
                        b = (float) strtol (p1_y_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 130, p1_z_coor, sizeof( p1_z_coor ) );
                        c = (float) strtol (p1_z_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 140, p2_x_coor, sizeof( p2_x_coor ) );
                        d = (float) strtol (p2_x_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 150, p2_y_coor, sizeof( p2_y_coor ) );
                        e = (float) strtol (p2_y_coor , &end_p , 10) ;
                        GetDlgItemText( hWnd, 160, p2_z_coor, sizeof( p2_z_coor ) );
                        f = (float) strtol (p2_z_coor , &end_p , 10) ;
                        EndDialog( hWnd, 1 );
                        return true;
                    }
    
                    case IDCANCEL: {
    
                        EndDialog( hWnd, 0 );
                        return true;
                    }
    
                    case IDRETRY: {
    
                        MessageBox( 0,
                                    " HELP:\n\n"
                                    " Empfehlung:\n"
                                    " Es werden Werte der Größe 50.0 bis -50.0 empfohlen.\n\n"
                                    " Tasten:\n"
                                    " ZOOM +          BILD HOCH\n"
                                    " ZOOM -           BILD RUNTER\n"
                                    " Dehen links      Pfeil-Taste-LINKS\n"
                                    " Dehen rechts   Pfeil-Taste-RECHTS\n"
                                    " Drehen hoch    Pfeil-Taste-HOCH\n"
                                    " Drehen runter  Pfeil-Taste-RUNTER\n",
                                    " Help! ", MB_OK | MB_ICONINFORMATION );
                        return true;
                    }
                }
                return true;
            }
        }
        return false;
    }
    
    void Room( float x, float y, float z ) {
    
            glColor3ub( 255, 255, 255 );
            glBegin( GL_LINES );
    
                // bottom
                glVertex3f( -x, -y, -z );
                glVertex3f(  x, -y, -z );
                glVertex3f(  x, -y, -z );
                glVertex3f(  x, -y,  z );
                glVertex3f(  x, -y,  z );
                glVertex3f( -x, -y,  z );
                glVertex3f( -x, -y,  z );
                glVertex3f( -x, -y, -z );
    
                // top
                glVertex3f( -x,  y, -z );
                glVertex3f(  x,  y, -z );
                glVertex3f(  x,  y, -z );
                glVertex3f(  x,  y,  z );
                glVertex3f(  x,  y,  z );
                glVertex3f( -x,  y,  z );
                glVertex3f( -x,  y,  z );
                glVertex3f( -x,  y, -z );
    
                // back
                glVertex3f( -x, -y, -z );
                glVertex3f(  x, -y, -z );
                glVertex3f(  x, -y, -z );
                glVertex3f(  x,  y, -z );
                glVertex3f(  x,  y, -z );
                glVertex3f( -x,  y, -z );
                glVertex3f( -x,  y, -z );
                glVertex3f( -x, -y, -z );
    
                // face
                glVertex3f( -x, -y,  z );
                glVertex3f(  x, -y,  z );
                glVertex3f(  x, -y,  z );
                glVertex3f(  x,  y,  z );
                glVertex3f(  x,  y,  z );
                glVertex3f( -x,  y,  z );
                glVertex3f( -x,  y,  z );
                glVertex3f( -x, -y,  z );
    
                // left
                glVertex3f(  x, -y, -z );
                glVertex3f(  x, -y,  z );
                glVertex3f(  x, -y,  z );
                glVertex3f(  x,  y,  z );
                glVertex3f(  x,  y,  z );
                glVertex3f(  x,  y, -z );
                glVertex3f(  x,  y, -z );
                glVertex3f(  x, -y, -z );
    
                // right
                glVertex3f( -x, -y, -z );
                glVertex3f( -x, -y,  z );
                glVertex3f( -x, -y,  z );
                glVertex3f( -x,  y,  z );
                glVertex3f( -x,  y,  z );
                glVertex3f( -x,  y, -z );
                glVertex3f( -x,  y, -z );
                glVertex3f( -x, -y, -z );
            glEnd();
    }
    
    int CreateVector( float _p1x, float _p1y, float _p1z, float _p2x, float _p2y,
                      float _p2z ) {
    
        glLineWidth( 5.0f );
    
        glColor3ub( r, g, b1 );
        glBegin( GL_LINES );
    
            glVertex3f( _p1x, _p1y, _p1z );
            glVertex3f( _p2x, _p2y, _p2z );
        glEnd();
    
        glLineWidth( 2.0f );
        glColor3ub( 255, 255, 255 );
        glRasterPos3f( _p1x, _p1y, _p1z );
        glPrint( "P1( %0.1f", a );
        glPrint( " / %0.1f", b);
        glPrint( " / %0.1f", c);
        glPrint( " ) ");
    
        glColor3ub( 255, 0, 0 );
        glBegin( GL_LINES );
    
            glVertex3f( _p1x -2.0f, _p1y, _p1z );
            glVertex3f( _p1x +2.0f, _p1y, _p1z );
    
            glVertex3f( _p1x, _p1y -2.0f, _p1z );
            glVertex3f( _p1x, _p1y +2.0f, _p1z );
    
            glVertex3f( _p1x, _p1y, _p1z -2.0f );
            glVertex3f( _p1x, _p1y, _p1z +2.0f );
        glEnd();
    
        glLineWidth( 2.0f );
        glColor3ub( 255, 255, 255 );
        glRasterPos3f( _p2x, _p2y, _p2z );
        glPrint( "P2( %0.1f", d );
        glPrint( " / %0.1f", e);
        glPrint( " / %0.1f", f);
        glPrint( " ) ");
    
        glColor3ub( 255, 0, 0 );
        glBegin( GL_LINES );
            glVertex3f( _p2x -2.0f, _p2y, _p2z );
            glVertex3f( _p2x +2.0f, _p2y, _p2z );
    
            glVertex3f( _p2x, _p2y -2.0f, _p2z );
            glVertex3f( _p2x, _p2y +2.0f, _p2z );
    
            glVertex3f( _p2x, _p2y, _p2z -2.0f );
            glVertex3f( _p2x, _p2y, _p2z +2.0f );
    
        glEnd();
    
        return 0;
    }
    
    int NewVector() {
    
        return( CreateVector( a, b, c, d, e, f ) );
    }
    

    und die .rc datei:

    Userm MENU
    BEGIN
    
        POPUP "&File"
        BEGIN
    
            MENUITEM "&Quit", 1000
    
        END
    
        POPUP "&Create"
        BEGIN
    
            MENUITEM "&Create Vector", 1100
    
        END
    END
    
    Dialog DIALOG   10, 10, 210, 70;
    CAPTION         " Create a Vector";
    STYLE           WS_OVERLAPPEDWINDOW;
    {
    LTEXT       "Enter Coordinates:", 100, 5, 5, 100, 20;
    LTEXT       "x Coordinate:", 100, 5, 20, 45, 20;
    LTEXT       "P1", 100, 73, 19, 45, 20;
    EDITTEXT    110, 85, 18, 21, 10;
    LTEXT       "y Coordinate:", 100, 5, 35, 45, 20;
    LTEXT       "P1", 100, 73, 34, 45, 20;
    EDITTEXT    120, 85, 33, 21, 10;
    LTEXT       "z Coordinate:", 100, 5, 50, 45, 20;
    LTEXT       "P1", 100, 73, 49, 45, 20;
    EDITTEXT    130, 85, 48, 21, 10;
    
    LTEXT       ";  P2", 130, 110, 19, 45, 20;
    EDITTEXT    140, 128, 18, 21, 10;
    LTEXT       ";  P2", 130, 110, 34, 45, 20;
    EDITTEXT    150, 128, 33, 21, 10;
    LTEXT       ";  P2", 100, 110, 49, 45, 20;
    EDITTEXT    160, 128, 48, 21, 10;
    
    DEFPUSHBUTTON "OK" , IDOK , 160 , 10 , 40 , 14;
    PUSHBUTTON "Cancel" , IDCANCEL , 160 , 30 , 40 , 14;
    PUSHBUTTON "Help" , IDRETRY , 160 , 50 , 40 , 14;
    }
    

    müsste so eigentlich funzen, waer cool wenn ihr ne lösung findet.



  • please awnser!



  • Am besten lerne vorher C++, sonst wird das nichts.



  • pffff... was glaubst du wieso ich meine Probs hier rein poste, natuerlich nur deswegen damit leute wie du hier immer sone tollen sprüche wie, "lern erst mal C++" oder son mist. echt jedes mal bekomm ich son kack zu hören. sorry, aba ich glaube du hast c++ auch net an einem tag gelernt, oder doch? naja egal, trotzdem danke für dein hilfe.



  • T0bi schrieb:

    naja egal, trotzdem danke für dein hilfe.

    Bitte.

    Hab leider kein Windows deswegen kann ich es nicht kompilieren. Sry mein Fehler.

    mfg.



  • tolle sprüche wie, "lern erst mal C++" oder son mist.
    echt jedes mal bekomm ich son kack zu hören

    Denk mal drueber nach...
    Hoeflicher formuliert zeigen mehrere Deiner Posts erhebliche Defizite im Umgang mit ueblichen Mitteln von Programmiersprachen und waeren in einem anderen, allgemeineren Forum sicher besser aufgehoben.
    Die wenigsten Besucher dieses speziellen Forums werden Lust verspueren, Dir die Grundlagen von Arrays zu erklaeren.


Log in to reply