Results 1 to 9 of 9

Thread: reshape func problem =(

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    reshape func problem =(

    Hello,
    Help me to understand reshape function plz
    for example in this code
    <div class="ubbcode-block"><div class="ubbcode-header">Click to reveal.. <input type="button" class="form-button" value="Show me!" onclick="toggle_spoiler(this, 'Yikes, my eyes!', 'Show me!')" />]<div style="display: none;">
    #include <GL/glut.h>
    #include <stdio.h>
    #define drawLine(x1,y1,x2,y2) glBegin(GL_LINES); glVertex2f((x1),(y1)); glVertex2f((x2),(y2)); glEnd();

    void init(void){
    glClearColor(1.0,1.0,1.0,0.0);
    glShadeModel(GL_FLAT);
    //glMatrixMode(GL_PROJECTION);
    // glLoadIdentity;
    // gluOrtho2D(0.0, 400.0, 0.0, 150.0);
    printf("init \n");
    }


    void display(void){
    glClear(GL_COLOR_BUFFER_BIT);
    //&amp;#1073;&amp;#1077;&amp;#1083;&amp;#1099;&amp;# 1081; &amp;#1094;&amp;#1074;&amp;#1077;&amp;#1090; &amp;#1074;&amp;#1089;&amp;#1077;&amp;#1093; &amp;#1083;&amp;#1080;&amp;#1085;&amp;#1080;&amp;# 1081;
    glColor3f(0.0,0.0,0.0);
    //3 &amp;#1083;&amp;#1080;&amp;#1085;&amp;#1080;&amp;# 1080; &amp;#1088;&amp;#1072;&amp;#1079;&amp;#1085;&amp;# 1086;&amp;#1075;&amp;#1086; &amp;#1074;&amp;#1080;&amp;#1076;&amp;#1072;
    glEnable(GL_LINE_STIPPLE);
    glLineStipple(1,0x3F07);
    drawLine(0.0,0.0,400.0,150.0);
    glDisable(GL_LINE_STIPPLE);
    glFlush();
    printf("display \n");
    }

    void reshape(int w, int h){
    glViewport(0,0,(GLsizei)w,(GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity;
    gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h);
    printf("reshape \n");
    }



    int main(int argc,char** argv)
    {
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(400,150);
    glutInitWindowPosition(100,100);
    glutCreateWindow(argv[0]);
    init();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();

    return 0;

    }
    [/QUOTE]</div>
    I used printf(); to learn what func works first, what second ...
    at first i saw comment Init, then reshape, then display
    after displaying and drawing line i try to change window size and
    i see a lot of reshape comments
    but suddenly, line, that was drawn disappears(at momment when i started changing windowsize). I cant understand why.
    reshape func had worked before display at first, and then line was drown.After i had changed size of window line wasnt drown again and i saw white window.

    Sorry for my terrible English=(
    Lamer

  2. #2
    Member Contributor
    Join Date
    Sep 2009
    Posts
    55

    Re: reshape func problem =(

    I don't see a glutSwapBuffers() at the end of your display function which would be a problem unless you are drawing to a single-buffered window.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    Re: reshape func problem =(

    i cant understand...There is a problem if there is function glutSwapBuffers() when i draw in single-buffer mode?
    But I havent this func, so there cant be problem with this func,cant it?
    I dont understand why after first reshape func line was drawn(when reshape func works before display func) and then, after reshape func i had the same situation and line wasn't drown.
    May be these situations arent similar?
    display func works again after reshape, why it doesnt draw my line again?=(
    Lamer

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    Re: reshape func problem =(

    or its only possible in double-buffer mode? i Think no. Help me to understand plz)
    Lamer

  5. #5
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: reshape func problem =(

    1) never use single buffer mode. Use only double buffered mode. Otherwise you expose yourself to a lot of problems, as it is less and less supported.
    2) in double buffered mode, you must call glutSwapBuffers() when you want something to appear.

  6. #6
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    Re: reshape func problem =(

    Thank u very much, ill consider this advice
    Lamer

  7. #7
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: reshape func problem =(

    Don't just consider it.

    There are no technical or other reasons to not use double-buffering. It's not more difficult than single-buffering (just one changed flag at startup and an extra function call at the end of each frame), it's a lot more stable, gives a better image, and avoids a lot of headaches in the future.

  8. #8
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    Re: reshape func problem =(

    Ok, thanks=) i meant that i will use it.
    Im bad in Engl sorry=)
    Lamer

  9. #9
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    Re: reshape func problem =(

    I tried double-buff mode, but line wasnt redrawn =)
    where is a problem?
    <div class="ubbcode-block"><div class="ubbcode-header">Click to reveal.. <input type="button" class="form-button" value="Show me!" onclick="toggle_spoiler(this, 'Yikes, my eyes!', 'Show me!')" />]<div style="display: none;">
    #include <GL/glut.h>
    #include <stdio.h>
    #define drawLine(x1,y1,x2,y2) glBegin(GL_LINES); glVertex2f((x1),(y1)); glVertex2f((x2),(y2)); glEnd();

    void init(void){
    glClearColor(1.0,1.0,1.0,0.0);
    glShadeModel(GL_FLAT);
    //glMatrixMode(GL_PROJECTION);
    // glLoadIdentity;
    // gluOrtho2D(0.0, 400.0, 0.0, 150.0);
    printf("init \n");
    }


    void display(void){
    glClear(GL_COLOR_BUFFER_BIT);
    //&amp;#1073;&amp;#1077;&amp;#1083;&amp;#1099;&amp;# 1081; &amp;#1094;&amp;#1074;&amp;#1077;&amp;#1090; &amp;#1074;&amp;#1089;&amp;#1077;&amp;#1093; &amp;#1083;&amp;#1080;&amp;#1085;&amp;#1080;&amp;# 1081;
    glColor3f(0.0,0.0,0.0);
    //3 &amp;#1083;&amp;#1080;&amp;#1085;&amp;#1080;&amp;# 1080; &amp;#1088;&amp;#1072;&amp;#1079;&amp;#1085;&amp;# 1086;&amp;#1075;&amp;#1086; &amp;#1074;&amp;#1080;&amp;#1076;&amp;#1072;
    glEnable(GL_LINE_STIPPLE);
    glLineStipple(1,0x3F07);
    drawLine(0.0,0.0,400.0,150.0);
    glDisable(GL_LINE_STIPPLE);
    glFlush();
    glutSwapBuffers();

    printf("display \n");
    }

    void reshape(int w, int h){
    glViewport(0,0,(GLsizei)w,(GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity;
    gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h);
    printf("reshape \n");
    }



    int main(int argc,char** argv)
    {
    glutInit(&amp;argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
    glutInitWindowSize(400,150);
    glutInitWindowPosition(100,100);
    glutCreateWindow(argv[0]);
    init();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutMainLoop();

    return 0;



    }
    [/QUOTE]</div>

    I think i should find out smth about double-buf mode xD, but if u say me where is problem it will not be bad
    Lamer

Similar Threads

  1. problem with window resizing (function reshape)
    By Rotiv in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-18-2010, 03:30 PM
  2. reshape
    By chign in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-12-2010, 02:32 PM
  3. glut key-down func?
    By mjs1 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-29-2004, 08:15 PM
  4. help with my camera func
    By ShinGouki in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 05-08-2003, 07:22 PM
  5. Problem with mouse func
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-02-2001, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean