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
");
}
void display(void){
glClear(GL_COLOR_BUFFER_BIT);
//белый цвет всех линий
glColor3f(0.0,0.0,0.0);
//3 линии разного вида
glEnable(GL_LINE_STIPPLE);
glLineStipple(1,0x3F07);
drawLine(0.0,0.0,400.0,150.0);
glDisable(GL_LINE_STIPPLE);
glFlush();
printf("display
");
}
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
");
}
int main(int argc,char** argv)
{
glutInit(&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=(