tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
1
ZUGRIFFE
604
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    WinDWalker WinDWalker ist offline Mitglied
    Registriert seit
    May 2005
    Beiträge
    21
    Hi Leute, ich hätte da gern mal ein kleines Problem.
    Ich habe gerade eben mit GLUT angefangen und möchte eine Bitmap von rechts nach links über den Bildschirm scrollen lassen. (Textscroll mit glutBitmapCharacter)
    Das Problem sieht folgendermassen aus: Immer wenn der linke Rand des Textes den linken Rand des Bildschirms berührt, verschwindet der komplette Text. (Der Text wird nicht langsam aus dem Bild gefahren, sondern verschwindet immer urplötzlich.)

    Soll:
    TestText
    estText
    stText
    tText
    ...

    Ist:
    TestText
    [nichts mehr]


    Ich hoffe ihr könnt mir helfen!
    Vielen Dank im Voraus!

    windwalker

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    
    #include <GL/glut.h>
    #include <iostream.h>
    #include <string.h>
     
    // globale Konstanten
    GLfloat const cLinkerRand = -100.0;
    GLfloat const cRechterRand = 100.0;
     
    // globale Variablen
    GLfloat x1 =0.0;
    GLfloat y1 =0.0;
    GLfloat rSize =25;
     
    GLfloat xStep =1.0;
    GLfloat yStep =1.0;
     
    GLfloat wndHeight;
    GLfloat wndWidth;
     
    GLint timerInterval = 10;
     
    GLint iTextbreite = 0;
     
    // Prototypen
    void renderScene(void);
    void timerFunction(int value);
    void setupRC(void);
    void changeSize(GLsizei w, GLsizei h);
    void drawText(void);
     
    //--- [ Funktionen ] ---
    void main()
    {
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
        glutCreateWindow("Scroll");
        glutDisplayFunc(renderScene);
        glutReshapeFunc(changeSize);
        glutTimerFunc(timerInterval,timerFunction,1);
        setupRC();
     
        glutMainLoop();
     
    }
     
    void renderScene()
    {
        glClear(GL_COLOR_BUFFER_BIT);
        drawText();
        glutSwapBuffers();
     
    }
     
    void timerFunction(int value)
    {
        if (x1 < (cLinkerRand - iTextbreite))
        {
            x1 = cRechterRand - xStep ;
        }
        x1 -= xStep;
     
        // Neuzeichnen und Timer auf 33ms setzen
        glutPostRedisplay();
        glutTimerFunc(timerInterval, timerFunction, 1);
     
    }
     
    void setupRC()
    {
        glClearColor(0.0, 0.0, 0.0, 0.0);
    }
     
     
    void changeSize(GLsizei w, GLsizei h)
    {
        GLfloat seitenverh;
     
        if (h == 0)
            h = 1;
     
        glViewport(0, 0, w, h);
     
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
     
        
        seitenverh = GLfloat(w) / GLfloat(h);
        
        if (w <= h)
        {
            wndWidth = cRechterRand;
            wndHeight = cRechterRand / seitenverh;
            glOrtho(cLinkerRand, cRechterRand, -wndHeight, wndHeight, 1.0, -1.0);
        }
        else
        {
            wndWidth = cRechterRand * seitenverh;
            wndHeight = cRechterRand;
            glOrtho(-wndWidth, wndWidth, cLinkerRand, cRechterRand, 1.0, -1.0);
        }
     
     
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
     
    }
     
    void drawText()
    {
        glColor3f(1.0, 0.0, 0.0);
        glRasterPos3f (x1, y1, 0);
        
        iTextbreite =0;
        char myText[] = "All Hail LST";
        
        for (unsigned int i=0; i<= strlen(myText); i++)
        {
            glutBitmapCharacter (GLUT_BITMAP_TIMES_ROMAN_24, myText[i]);
            iTextbreite += glutBitmapWidth(GLUT_BITMAP_TIMES_ROMAN_24, myText[i]);
        }
     
    }
     

  2. #2
    WinDWalker WinDWalker ist offline Mitglied
    Registriert seit
    May 2005
    Beiträge
    21
    Danke, hat sich erledigt.
     

Ähnliche Themen

  1. MFC SDI | Per GDI in Bitmap zeichnen?
    Von eurostar123 im Forum VisualStudio & MFC
    Antworten: 1
    Letzter Beitrag: 08.03.10, 21:35
  2. Bitmap auf MFC-Fenster zeichnen
    Von Krankfried im Forum C/C++
    Antworten: 1
    Letzter Beitrag: 19.10.08, 21:23
  3. Auto-Textscroll
    Von Sephcom im Forum HTML & XHTML
    Antworten: 1
    Letzter Beitrag: 19.07.08, 23:28
  4. Bitmap auf Desktop zeichnen
    Von Kaiser206 im Forum C/C++
    Antworten: 2
    Letzter Beitrag: 12.07.08, 23:12
  5. Auf Bitmap zeichnen
    Von Mr_P1nk im Forum C/C++
    Antworten: 6
    Letzter Beitrag: 28.02.05, 09:24