108 break; |
108 break; |
109 case gl::RenderStyle::Wireframe: |
109 case gl::RenderStyle::Wireframe: |
110 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
110 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
111 break; |
111 break; |
112 } |
112 } |
113 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
|
114 glMatrixMode(GL_MODELVIEW); |
113 glMatrixMode(GL_MODELVIEW); |
115 // clear the drawing buffer. |
|
116 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
114 glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
117 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
115 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
118 glEnable(GL_DEPTH_TEST); |
116 glEnable(GL_DEPTH_TEST); |
119 glEnable(GL_LIGHTING); |
117 glEnable(GL_LIGHTING); |
120 // clear the identity matrix. |
|
121 glLoadIdentity(); |
118 glLoadIdentity(); |
122 // traslate the draw by z = -4.0 |
|
123 // Note this when you decrease z like -8.0 the drawing will looks far , or smaller. |
|
124 glTranslatef(0.0, 0.0, -4.5 * this->compiler->modelDistance()); |
119 glTranslatef(0.0, 0.0, -4.5 * this->compiler->modelDistance()); |
125 glMultMatrixf(padMatrix(this->rotation.toRotationMatrix()).constData()); |
120 glMultMatrixf(padMatrix(this->rotation.toRotationMatrix()).constData()); |
126 xyz(glTranslatef, -this->compiler->modelCenter()); |
121 xyz(glTranslatef, -this->compiler->modelCenter()); |
127 glEnableClientState(GL_NORMAL_ARRAY); |
122 glEnableClientState(GL_NORMAL_ARRAY); |
128 glEnableClientState(GL_VERTEX_ARRAY); |
123 glEnableClientState(GL_VERTEX_ARRAY); |
143 } |
138 } |
144 glBindBuffer(GL_ARRAY_BUFFER, 0); |
139 glBindBuffer(GL_ARRAY_BUFFER, 0); |
145 glDisableClientState(GL_NORMAL_ARRAY); |
140 glDisableClientState(GL_NORMAL_ARRAY); |
146 glDisableClientState(GL_VERTEX_ARRAY); |
141 glDisableClientState(GL_VERTEX_ARRAY); |
147 glDisableClientState(GL_COLOR_ARRAY); |
142 glDisableClientState(GL_COLOR_ARRAY); |
148 //glFlush(); |
|
149 const GLenum glError = this->glGetError(); |
143 const GLenum glError = this->glGetError(); |
150 if (glError != GL_NO_ERROR) |
144 if (glError != GL_NO_ERROR) |
151 { |
145 { |
152 const QString glErrorString = QString::fromLatin1(reinterpret_cast<const char*>(::gluErrorString(glError))); |
146 const QString glErrorString = QString::fromLatin1(reinterpret_cast<const char*>(::gluErrorString(glError))); |
153 QMessageBox::critical( |
147 QMessageBox::critical( |