0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / OpenGl / OpenGl_Marker.cxx
CommitLineData
2166f0fa
SK
1// File: OpenGl_Marker.cxx
2// Created: 13 July 2011
3// Author: Sergey ZERCHANINOV
4// Copyright: OPEN CASCADE 2011
5
5f8b738e 6#include <OpenGl_GlCore11.hxx>
2166f0fa 7
5f8b738e 8#include <OpenGl_Marker.hxx>
2166f0fa
SK
9
10#include <OpenGl_AspectMarker.hxx>
11#include <OpenGl_Structure.hxx>
12#include <OpenGl_Display.hxx>
13
14/*----------------------------------------------------------------------*/
15
16void OpenGl_Marker::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
17{
18 const OpenGl_AspectMarker *aspect_marker = AWorkspace->AspectMarker( Standard_True );
19
20 // Use highlight colours
21 glColor3fv( (AWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)? AWorkspace->HighlightColor->rgb : aspect_marker->Color().rgb );
22
23 switch ( aspect_marker->Type() )
24 {
25 case Aspect_TOM_O_POINT :
26 {
27 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, aspect_marker->Scale() );
28 glRasterPos3fv( myPoint.xyz );
29 AWorkspace->GetDisplay()->SetBaseForMarker();
30 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
31 }
32 case Aspect_TOM_POINT :
33 {
34 glPointSize( aspect_marker->Scale() );
35 glBegin( GL_POINTS );
36 glVertex3fv( myPoint.xyz );
37 glEnd();
38 break;
39 }
40 default:
41 {
42 glRasterPos3fv( myPoint.xyz );
43 switch ( aspect_marker->Type() )
44 {
45 case Aspect_TOM_RING1 :
46 case Aspect_TOM_RING2 :
47 case Aspect_TOM_RING3 :
48 {
49 const float ADelta = 0.1f;
50 float AScale = aspect_marker->Scale();
51 float ALimit = 0.f;
52 if (aspect_marker->Type() == Aspect_TOM_RING1)
53 ALimit = AScale * 0.2f;
54 else if (aspect_marker->Type() == Aspect_TOM_RING2)
55 ALimit = AScale * 0.5f;
56 else
57 ALimit = AScale * 0.8f;
58 AWorkspace->GetDisplay()->SetBaseForMarker();
59 while (AScale > ALimit && AScale >= 1.f)
60 {
61 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( Aspect_TOM_O, AScale );
62 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *) str );
63 AScale -= ADelta;
64 }
65 break;
66 }
67 case Aspect_TOM_USERDEFINED :
68 {
69 glCallList( openglDisplay->GetUserMarkerListIndex( (int)aspect_marker->Scale() ) );
70 break;
71 }
72 default :
73 {
74 AWorkspace->GetDisplay()->SetBaseForMarker();
75 const char *str = AWorkspace->GetDisplay()->GetStringForMarker( aspect_marker->Type(), aspect_marker->Scale() );
76 glCallLists( strlen( str ), GL_UNSIGNED_BYTE, (const GLubyte *)str );
77 }
78 }
79 GLint mode;
80 glGetIntegerv( GL_RENDER_MODE, &mode );
81 if( mode==GL_FEEDBACK )
82 {
83 glBegin( GL_POINTS );
84 glVertex3fv( myPoint.xyz );
85 glEnd();
86 /* it is necessary to indicate end of marker information*/
87 }
88 }
89 }
90}
91
92/*----------------------------------------------------------------------*/