0024252: GCC warnings on breakage of strict-aliasing rules
[occt.git] / src / OpenGl / OpenGl_Workspace.cxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
e276548b 16#ifdef HAVE_CONFIG_H
17 #include <config.h>
18#endif
19
a577aaab 20#include <OpenGl_GlCore15.hxx>
5f8b738e 21
2166f0fa
SK
22#include <InterfaceGraphic.hxx>
23
2166f0fa
SK
24#include <OpenGl_AspectLine.hxx>
25#include <OpenGl_AspectFace.hxx>
26#include <OpenGl_AspectMarker.hxx>
27#include <OpenGl_AspectText.hxx>
bf75be98 28#include <OpenGl_Context.hxx>
a174a3c5 29#include <OpenGl_FrameBuffer.hxx>
bf75be98 30#include <OpenGl_Texture.hxx>
e276548b 31#include <OpenGl_View.hxx>
a174a3c5 32#include <OpenGl_Workspace.hxx>
4269bd1b 33#include <OpenGl_Element.hxx>
2166f0fa 34
bf75be98 35#include <Graphic3d_TextureParams.hxx>
2166f0fa 36
58655684 37#if defined(_WIN32) && defined(HAVE_VIDEOCAPTURE)
a174a3c5 38 #include <OpenGl_AVIWriter.hxx>
39#endif
40
2166f0fa
SK
41IMPLEMENT_STANDARD_HANDLE(OpenGl_Workspace,OpenGl_Window)
42IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,OpenGl_Window)
43
44namespace
45{
0adbd30f 46 static const TEL_COLOUR THE_WHITE_COLOR = { { 1.0f, 1.0f, 1.0f, 1.0f } };
47 static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f);
2166f0fa
SK
48
49 static const OpenGl_AspectLine myDefaultAspectLine;
50 static const OpenGl_AspectFace myDefaultAspectFace;
51 static const OpenGl_AspectMarker myDefaultAspectMarker;
52 static const OpenGl_AspectText myDefaultAspectText;
53
54 static const OpenGl_TextParam myDefaultTextParam =
55 {
56 16, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM
57 };
58
59 static const OpenGl_Matrix myDefaultMatrix =
60 {
61 {{ 1.0F, 0.0F, 0.0F, 0.0F },
62 { 0.0F, 1.0F, 0.0F, 0.0F },
63 { 0.0F, 0.0F, 1.0F, 0.0F },
64 { 0.0F, 0.0F, 0.0F, 1.0F }}
65 };
bf75be98 66
2166f0fa
SK
67};
68
69// =======================================================================
0adbd30f 70// function : Init
71// purpose :
72// =======================================================================
73void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp)
74{
75 // ambient component
76 if (theProp.color_mask & OPENGL_AMBIENT_MASK)
77 {
78 const float* aSrcAmb = theProp.isphysic ? theProp.ambcol.rgb : theProp.matcol.rgb;
79 Ambient = OpenGl_Vec4 (aSrcAmb[0] * theProp.amb,
80 aSrcAmb[1] * theProp.amb,
81 aSrcAmb[2] * theProp.amb,
82 1.0f);
83 }
84 else
85 {
86 Ambient = THE_BLACK_COLOR;
87 }
88
89 // diffusion component
90 if (theProp.color_mask & OPENGL_DIFFUSE_MASK)
91 {
92 const float* aSrcDif = theProp.isphysic ? theProp.difcol.rgb : theProp.matcol.rgb;
93 Diffuse = OpenGl_Vec4 (aSrcDif[0] * theProp.diff,
94 aSrcDif[1] * theProp.diff,
95 aSrcDif[2] * theProp.diff,
96 1.0f);
97 }
98 else
99 {
100 Diffuse = THE_BLACK_COLOR;
101 }
102
103 // specular component
104 if (theProp.color_mask & OPENGL_SPECULAR_MASK)
105 {
106 const float* aSrcSpe = theProp.isphysic ? theProp.speccol.rgb : THE_WHITE_COLOR.rgb;
107 Specular = OpenGl_Vec4 (aSrcSpe[0] * theProp.spec,
108 aSrcSpe[1] * theProp.spec,
109 aSrcSpe[2] * theProp.spec,
110 1.0f);
111 }
112 else
113 {
114 Specular = THE_BLACK_COLOR;
115 }
116
117 // emission component
118 if (theProp.color_mask & OPENGL_EMISSIVE_MASK)
119 {
120 const float* aSrcEms = theProp.isphysic ? theProp.emscol.rgb : theProp.matcol.rgb;
121 Emission = OpenGl_Vec4 (aSrcEms[0] * theProp.emsv,
122 aSrcEms[1] * theProp.emsv,
123 aSrcEms[2] * theProp.emsv,
124 1.0f);
125 }
126 else
127 {
128 Emission = THE_BLACK_COLOR;
129 }
130
131 ChangeShine() = theProp.shine;
132 ChangeTransparency() = theProp.trans;
133}
134
135// =======================================================================
2166f0fa
SK
136// function : OpenGl_Workspace
137// purpose :
138// =======================================================================
139OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
140 const CALL_DEF_WINDOW& theCWindow,
5e27df78 141 Aspect_RenderingContext theGContext,
58655684 142 const Handle(OpenGl_Caps)& theCaps,
5e27df78 143 const Handle(OpenGl_Context)& theShareCtx)
58655684 144: OpenGl_Window (theDisplay, theCWindow, theGContext, theCaps, theShareCtx),
a174a3c5 145 NamedStatus (0),
0adbd30f 146 HighlightColor (&THE_WHITE_COLOR),
a174a3c5 147 //
2166f0fa
SK
148 myIsTransientOpen (Standard_False),
149 myRetainMode (Standard_False),
a174a3c5 150 myTransientDrawToFront (Standard_True),
2166f0fa
SK
151 myUseTransparency (Standard_False),
152 myUseZBuffer (Standard_False),
153 myUseDepthTest (Standard_True),
154 myUseGLLight (Standard_True),
155 myBackBufferRestored (Standard_False),
156 //
2166f0fa
SK
157 AspectLine_set (&myDefaultAspectLine),
158 AspectLine_applied (NULL),
159 AspectFace_set (&myDefaultAspectFace),
160 AspectFace_applied (NULL),
161 AspectMarker_set (&myDefaultAspectMarker),
162 AspectMarker_applied (NULL),
163 AspectText_set (&myDefaultAspectText),
164 AspectText_applied (NULL),
165 TextParam_set (&myDefaultTextParam),
166 TextParam_applied (NULL),
167 ViewMatrix_applied (&myDefaultMatrix),
168 StructureMatrix_applied (&myDefaultMatrix),
0f8c0fb8 169 myModelViewMatrix (myDefaultMatrix),
2166f0fa
SK
170 PolygonOffset_applied (NULL)
171{
172 theDisplay->InitAttributes();
173
174 // General initialization of the context
175
176 // Eviter d'avoir les faces mal orientees en noir.
177 // Pourrait etre utiliser pour detecter les problemes d'orientation
bf75be98 178 glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
2166f0fa
SK
179
180 // Optimisation pour le Fog et l'antialiasing
181 glHint (GL_FOG_HINT, GL_FASTEST);
182 glHint (GL_POINT_SMOOTH_HINT, GL_FASTEST);
183 glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST);
184 glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
185
186 // Polygon Offset
187 EnablePolygonOffset();
e276548b 188
189#ifdef HAVE_OPENCL
190
191 myComputeInitStatus = OpenGl_CLIS_NONE;
192
193 myViewModificationStatus = 0;
194 myLayersModificationStatus = 0;
195
196 myRaytraceOutputTexture[0] = 0;
197 myRaytraceOutputTexture[1] = 0;
198
199 myIsRaytraceDataValid = Standard_False;
200 myToUpdateRaytraceData = Standard_False;
201
202#endif
2166f0fa
SK
203}
204
205// =======================================================================
1981cb22 206// function : SetImmediateModeDrawToFront
207// purpose :
208// =======================================================================
209Standard_Boolean OpenGl_Workspace::SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer)
210{
211 const Standard_Boolean aPrevMode = myTransientDrawToFront;
212 myTransientDrawToFront = theDrawToFrontBuffer;
213 return aPrevMode;
214}
215
216// =======================================================================
2166f0fa
SK
217// function : ~OpenGl_Workspace
218// purpose :
219// =======================================================================
220OpenGl_Workspace::~OpenGl_Workspace()
221{
e276548b 222#ifdef HAVE_OPENCL
223 ReleaseOpenCL();
224#endif
2166f0fa
SK
225}
226
227// =======================================================================
228// function : Activate
229// purpose :
230// =======================================================================
231Standard_Boolean OpenGl_Workspace::Activate()
232{
233 if (!OpenGl_Window::Activate())
234 return Standard_False;
235
2166f0fa
SK
236 ViewMatrix_applied = &myDefaultMatrix;
237 StructureMatrix_applied = &myDefaultMatrix;
26395493 238
239 ResetAppliedAspect();
240
241 return Standard_True;
2166f0fa
SK
242}
243
244// =======================================================================
245// function : UseTransparency
246// purpose : call_togl_transparency
247// =======================================================================
248void OpenGl_Workspace::UseTransparency (const Standard_Boolean theFlag)
249{
de75ed09 250 myUseTransparency = theFlag;
2166f0fa 251}
26395493 252
253//=======================================================================
254//function : ResetAppliedAspect
255//purpose : Sets default values of GL parameters in accordance with default aspects
256//=======================================================================
257void OpenGl_Workspace::ResetAppliedAspect()
258{
bf75be98 259 NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0;
0adbd30f 260 HighlightColor = &THE_WHITE_COLOR;
26395493 261 AspectLine_set = &myDefaultAspectLine;
262 AspectLine_applied = NULL;
263 AspectFace_set = &myDefaultAspectFace;
264 AspectFace_applied = NULL;
265 AspectMarker_set = &myDefaultAspectMarker;
266 AspectMarker_applied = NULL;
267 AspectText_set = &myDefaultAspectText;
268 AspectText_applied = NULL;
269 TextParam_set = &myDefaultTextParam;
270 TextParam_applied = NULL;
271 PolygonOffset_applied = NULL;
272
273 AspectLine(Standard_True);
274 AspectFace(Standard_True);
275 AspectMarker(Standard_True);
276 AspectText(Standard_True);
277}
bf75be98 278
279// =======================================================================
280// function : DisableTexture
281// purpose :
282// =======================================================================
283Handle(OpenGl_Texture) OpenGl_Workspace::DisableTexture()
284{
285 if (myTextureBound.IsNull())
286 {
287 return myTextureBound;
288 }
289
290 // reset texture matrix because some code may expect it is identity
291 GLint aMatrixMode = GL_TEXTURE;
292 glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode);
293 glMatrixMode (GL_TEXTURE);
294 glLoadIdentity();
295 glMatrixMode (aMatrixMode);
296
297 myTextureBound->Unbind (myGlContext);
298 switch (myTextureBound->GetTarget())
299 {
300 case GL_TEXTURE_1D:
301 {
302 if (myTextureBound->GetParams()->GenMode() != GL_NONE)
303 {
304 glDisable (GL_TEXTURE_GEN_S);
305 }
306 glDisable (GL_TEXTURE_1D);
307 break;
308 }
309 case GL_TEXTURE_2D:
310 {
311 if (myTextureBound->GetParams()->GenMode() != GL_NONE)
312 {
313 glDisable (GL_TEXTURE_GEN_S);
314 glDisable (GL_TEXTURE_GEN_T);
a577aaab 315 if (myTextureBound->GetParams()->GenMode() == Graphic3d_TOTM_SPRITE)
316 {
317 glDisable (GL_POINT_SPRITE);
318 }
bf75be98 319 }
320 glDisable (GL_TEXTURE_2D);
321 break;
322 }
323 default: break;
324 }
325
326 Handle(OpenGl_Texture) aPrevTexture = myTextureBound;
327 myTextureBound.Nullify();
328 return aPrevTexture;
329}
330
331// =======================================================================
332// function : setTextureParams
333// purpose :
334// =======================================================================
335void OpenGl_Workspace::setTextureParams (Handle(OpenGl_Texture)& theTexture,
336 const Handle(Graphic3d_TextureParams)& theParams)
337{
338 const Handle(Graphic3d_TextureParams)& aParams = theParams.IsNull() ? theTexture->GetParams() : theParams;
339 if (aParams.IsNull())
340 {
341 return;
342 }
343
344 GLint aMatrixMode = GL_TEXTURE;
345 glGetIntegerv (GL_MATRIX_MODE, &aMatrixMode);
346
347 // setup texture matrix
348 glMatrixMode (GL_TEXTURE);
349 glLoadIdentity();
350 const Graphic3d_Vec2& aScale = aParams->Scale();
351 const Graphic3d_Vec2& aTrans = aParams->Translation();
352 glScalef ( aScale.x(), aScale.y(), 1.0f);
353 glTranslatef (-aTrans.x(), -aTrans.y(), 0.0f);
354 glRotatef (-aParams->Rotation(), 0.0f, 0.0f, 1.0f);
355
356 // setup generation of texture coordinates
357 switch (aParams->GenMode())
358 {
359 case Graphic3d_TOTM_OBJECT:
360 {
361 glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
362 glTexGenfv (GL_S, GL_OBJECT_PLANE, aParams->GenPlaneS().GetData());
363 if (theTexture->GetTarget() != GL_TEXTURE_1D)
364 {
365 glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
366 glTexGenfv (GL_T, GL_OBJECT_PLANE, aParams->GenPlaneT().GetData());
367 }
368 break;
369 }
370 case Graphic3d_TOTM_SPHERE:
371 {
372 glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
373 if (theTexture->GetTarget() != GL_TEXTURE_1D)
374 {
375 glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
376 }
377 break;
378 }
379 case Graphic3d_TOTM_EYE:
380 {
381 glMatrixMode (GL_MODELVIEW);
382 glPushMatrix();
383 glLoadIdentity();
384
385 glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
386 glTexGenfv (GL_S, GL_EYE_PLANE, aParams->GenPlaneS().GetData());
387
388 if (theTexture->GetTarget() != GL_TEXTURE_1D)
389 {
390 glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
391 glTexGenfv (GL_T, GL_EYE_PLANE, aParams->GenPlaneT().GetData());
392 }
393 glPopMatrix();
394 break;
395 }
a577aaab 396 case Graphic3d_TOTM_SPRITE:
397 {
398 if (GetGlContext()->core20 != NULL)
399 {
400 glEnable (GL_POINT_SPRITE);
401 glTexEnvi (GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
402 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
403 GetGlContext()->core15->glPointParameteri (GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);
404 }
405 break;
406 }
bf75be98 407 case Graphic3d_TOTM_MANUAL:
408 default: break;
409 }
410
411 // setup lighting
a577aaab 412 if (aParams->GenMode() != Graphic3d_TOTM_SPRITE)
413 {
414 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, aParams->IsModulate() ? GL_MODULATE : GL_DECAL);
415 }
bf75be98 416
417 // setup texture filtering and wrapping
418 //if (theTexture->GetParams() != theParams)
419 const GLenum aFilter = (aParams->Filter() == Graphic3d_TOTF_NEAREST) ? GL_NEAREST : GL_LINEAR;
420 const GLenum aWrapMode = aParams->IsRepeat() ? GL_REPEAT : GL_CLAMP;
421 switch (theTexture->GetTarget())
422 {
423 case GL_TEXTURE_1D:
424 {
425 glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, aFilter);
426 glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, aFilter);
427 glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, aWrapMode);
428 break;
429 }
430 case GL_TEXTURE_2D:
431 {
432 GLenum aFilterMin = aFilter;
433 if (theTexture->HasMipmaps())
434 {
435 aFilterMin = GL_NEAREST_MIPMAP_NEAREST;
436 if (aParams->Filter() == Graphic3d_TOTF_BILINEAR)
437 {
438 aFilterMin = GL_LINEAR_MIPMAP_NEAREST;
439 }
440 else if (aParams->Filter() == Graphic3d_TOTF_TRILINEAR)
441 {
442 aFilterMin = GL_LINEAR_MIPMAP_LINEAR;
443 }
444
445 if (myGlContext->extAnis)
446 {
447 // setup degree of anisotropy filter
448 const GLint aMaxDegree = myGlContext->MaxDegreeOfAnisotropy();
449 switch (aParams->AnisoFilter())
450 {
451 case Graphic3d_LOTA_QUALITY:
452 {
453 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aMaxDegree);
454 break;
455 }
456 case Graphic3d_LOTA_MIDDLE:
457 {
458
459 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (aMaxDegree <= 4) ? 2 : (aMaxDegree / 2));
460 break;
461 }
462 case Graphic3d_LOTA_FAST:
463 {
464 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2);
465 break;
466 }
467 case Graphic3d_LOTA_OFF:
468 default:
469 {
470 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
471 break;
472 }
473 }
474 }
475 }
476 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, aFilterMin);
477 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, aFilter);
478 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, aWrapMode);
479 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, aWrapMode);
480 break;
481 }
482 default: break;
483 }
484
485 switch (theTexture->GetTarget())
486 {
487 case GL_TEXTURE_1D:
488 {
489 if (aParams->GenMode() != Graphic3d_TOTM_MANUAL)
490 {
491 glEnable (GL_TEXTURE_GEN_S);
492 }
493 glEnable (GL_TEXTURE_1D);
494 break;
495 }
496 case GL_TEXTURE_2D:
497 {
498 if (aParams->GenMode() != Graphic3d_TOTM_MANUAL)
499 {
500 glEnable (GL_TEXTURE_GEN_S);
501 glEnable (GL_TEXTURE_GEN_T);
502 }
503 glEnable (GL_TEXTURE_2D);
504 break;
505 }
506 default: break;
507 }
508
509 glMatrixMode (aMatrixMode); // turn back active matrix
510 theTexture->SetParams (aParams);
511}
512
513// =======================================================================
514// function : EnableTexture
515// purpose :
516// =======================================================================
517Handle(OpenGl_Texture) OpenGl_Workspace::EnableTexture (const Handle(OpenGl_Texture)& theTexture,
518 const Handle(Graphic3d_TextureParams)& theParams)
519{
520 if (theTexture.IsNull() || !theTexture->IsValid())
521 {
522 return DisableTexture();
523 }
524
bca1d6e2 525 if (myTextureBound == theTexture
526 && (theParams.IsNull() || theParams == theTexture->GetParams()))
bf75be98 527 {
bca1d6e2 528 // already bound
529 return myTextureBound;
bf75be98 530 }
531
532 Handle(OpenGl_Texture) aPrevTexture = DisableTexture();
533 myTextureBound = theTexture;
534 myTextureBound->Bind (myGlContext);
535 setTextureParams (myTextureBound, theParams);
536
537 return aPrevTexture;
538}
a174a3c5 539
540// =======================================================================
541// function : Redraw
542// purpose :
543// =======================================================================
544void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
545 const Aspect_CLayer2d& theCUnderLayer,
546 const Aspect_CLayer2d& theCOverLayer)
547{
548 if (!Activate())
549 {
550 return;
551 }
552
553 // release pending GL resources
554 Handle(OpenGl_Context) aGlCtx = GetGlContext();
555 aGlCtx->ReleaseDelayed();
556
557 // cache render mode state
558 GLint aRendMode = GL_RENDER;
559 glGetIntegerv (GL_RENDER_MODE, &aRendMode);
560 aGlCtx->SetFeedback (aRendMode == GL_FEEDBACK);
561
562 Tint toSwap = (aRendMode == GL_RENDER); // swap buffers
563 GLint aViewPortBack[4];
564 OpenGl_FrameBuffer* aFrameBuffer = (OpenGl_FrameBuffer* )theCView.ptrFBO;
565 if (aFrameBuffer != NULL)
566 {
567 glGetIntegerv (GL_VIEWPORT, aViewPortBack);
fd4a6963 568 aFrameBuffer->SetupViewport (aGlCtx);
569 aFrameBuffer->BindBuffer (aGlCtx);
a174a3c5 570 toSwap = 0; // no need to swap buffers
571 }
572
e276548b 573#ifdef HAVE_OPENCL
574 if (!theCView.IsRaytracing || myComputeInitStatus == OpenGl_CLIS_FAIL)
575 {
576#endif
577 Redraw1 (theCView, theCUnderLayer, theCOverLayer, toSwap);
578 if (aFrameBuffer == NULL || !myTransientDrawToFront)
579 {
580 RedrawImmediatMode();
581 }
582
583 theCView.WasRedrawnGL = Standard_True;
584#ifdef HAVE_OPENCL
585 }
586 else
a174a3c5 587 {
e276548b 588 int aSizeX = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeX() : myWidth;
589 int aSizeY = aFrameBuffer != NULL ? aFrameBuffer->GetVPSizeY() : myHeight;
590
591 Raytrace (theCView, aSizeX, aSizeY, toSwap);
592
593 theCView.WasRedrawnGL = Standard_False;
a174a3c5 594 }
e276548b 595#endif
a174a3c5 596
597 if (aFrameBuffer != NULL)
598 {
599 aFrameBuffer->UnbindBuffer (aGlCtx);
600 // move back original viewport
601 glViewport (aViewPortBack[0], aViewPortBack[1], aViewPortBack[2], aViewPortBack[3]);
602 }
603
604#if (defined(_WIN32) || defined(__WIN32__)) && defined(HAVE_VIDEOCAPTURE)
605 if (OpenGl_AVIWriter_AllowWriting (theCView.DefWindow.XWindow))
606 {
607 GLint params[4];
608 glGetIntegerv (GL_VIEWPORT, params);
609 int nWidth = params[2] & ~0x7;
610 int nHeight = params[3] & ~0x7;
611
612 const int nBitsPerPixel = 24;
613 GLubyte* aDumpData = new GLubyte[nWidth * nHeight * nBitsPerPixel / 8];
614
615 glPixelStorei (GL_PACK_ALIGNMENT, 1);
616 glReadPixels (0, 0, nWidth, nHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, aDumpData);
617 OpenGl_AVIWriter_AVIWriter (aDumpData, nWidth, nHeight, nBitsPerPixel);
618 delete[] aDumpData;
619 }
620#endif
621
622 // reset render mode state
623 aGlCtx->SetFeedback (Standard_False);
624}