Results 1 to 3 of 3

Thread: ack my reshape function causes my PC to crash please help

  1. #1
    Junior Member Newbie
    Join Date
    May 2003
    Location
    Dundee, Scotland
    Posts
    13

    ack my reshape function causes my PC to crash please help

    yet another question, sorry guys lol

    void reshape(int width, int height)
    {
    if (height==0) // Prevent A Divide By Zero By
    {
    height=1; // Making Height Equal One
    }

    glViewport(0,0,width,height); // Reset The Current Viewport

    ASPECT_RATIO = (float)width/(float)height;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, ASPECT_RATIO, 1.0, 4000.0);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black background
    glutPostRedisplay();
    glutSwapBuffers();
    glMatrixMode(GL_MODELVIEW);
    }

    this seems to be causing my pc to crash horribly when i resize in certain directions, can you spot any obvious discrepancies about what im doing?

    *i feel like im one of those bug busting questions in C++ in 21 days, can you spot the bug *

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: ack my reshape function causes my PC to crash please help

    glutPostRedisplay();
    glutSwapBuffers();


    Shouldn't the glutSwapBuffers be done in the Display function? glutPostRedisplay basically just posts a WM_PAINT message, it doesn't actually call your display function. Your display function will likely not be called until after the reshape is done, when the WM_PAINT message is then picked up.
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: ack my reshape function causes my PC to crash please help

    As the other person posted the glutPostRedisplay and glutswapbuffers should not be in the reshape.

    Also on window reshape, it automatically calls you glutPostRedisplay so you are repeating it twice by puttin it in.

    on the glutswapbuffers sould be called at the end of you display routine.

    Look at my website with glut examples:
    www.angelfire.com/linux/nexusone


    Originally posted by ShinGouki:
    yet another question, sorry guys lol

    void reshape(int width, int height)
    {
    if (height==0) // Prevent A Divide By Zero By
    {
    height=1; // Making Height Equal One
    }

    glViewport(0,0,width,height); // Reset The Current Viewport

    ASPECT_RATIO = (float)width/(float)height;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, ASPECT_RATIO, 1.0, 4000.0);
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Black background
    glutPostRedisplay();
    glutSwapBuffers();
    glMatrixMode(GL_MODELVIEW);
    }

    this seems to be causing my pc to crash horribly when i resize in certain directions, can you spot any obvious discrepancies about what im doing?

    *i feel like im one of those bug busting questions in C++ in 21 days, can you spot the bug *

Similar Threads

  1. Reshape function and multiple viewports
    By Perlice in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-05-2013, 01:28 PM
  2. Texture mapping and reshape function
    By annette in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-12-2012, 10:15 AM
  3. Doubt with reshape function
    By anoop4real in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-04-2011, 03:48 PM
  4. How reshape function should look like for 2D game?
    By Neomex01 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-14-2010, 12:47 PM
  5. reshape function using gluPerspective
    By cpl in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-04-2001, 07:29 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