summaryrefslogtreecommitdiff
path: root/goodies/source/base3d/b3dopngl.hxx
blob: 1876584887ff3d0616762d5b346e85a03de246f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: b3dopngl.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 02:26:42 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _B3D_B3DOPNGL_HXX
#define _B3D_B3DOPNGL_HXX

#ifndef _B3D_BASE3D_HXX
#include "base3d.hxx"
#endif

#ifndef _SV_OPENGL_HXX
#include <vcl/opengl.hxx>
#endif

/*************************************************************************
|*
|* Die Basisklasse fuer Standard 3D Ausgaben mittels OpenGL unter
|* Windows (Win95 und Windows NT)
|*
\************************************************************************/

class Base3DOpenGL : public Base3D
{
private:
    // Datenuebergabe
    B3dEntity                   aEntity;

    // OpenGL Objekt
    OpenGL                      aOpenGL;

    // Letzte Normale und letzte Texturkoordinate
    Vector3D                    aLastNormal;
    Vector3D                    aLastTexCoor;
    Vector3D                    aEmptyVector;

    float                       fOffFacMul100;
    float                       fOffUniMul100;

    // Simulation Phong-Mode
    BOOL                        bPhongBufferedMode;
    B3dEntityBucket             aPhongBuffer;
    long                        nPhongDivideSize;
    long                        nInternPhongDivideSize;

    // flags (#70626#)
    BOOL                        bForceToSinglePrimitiveOutput;

    void DrawPhongPrimitives();
    void DrawPhongTriangle(UINT32 nInd1, UINT32 nInd2, UINT32 nInd3);
    void CalcInternPhongDivideSize();

public:
    Base3DOpenGL(OutputDevice* pOutDev);

    // DivideSize bei Phong-Simulation
    long GetPhongDivideSize() { return nPhongDivideSize; }
    void SetPhongDivideSize(long nNew);

    // Get/Set force to single primitive output (#70626#)
    BOOL IsForceToSinglePrimitiveOutput() const { return bForceToSinglePrimitiveOutput; }
    void SetForceToSinglePrimitiveOutput(BOOL bNew) { bForceToSinglePrimitiveOutput = bNew; }

    // Typbestimmung
    virtual UINT16 GetBase3DType();

    virtual void StartScene();
    virtual void EndScene();

    // Scissoring
    virtual void SetScissorRegionPixel(const Rectangle& rRect, BOOL bActivate=TRUE);
    virtual void ActivateScissorRegion(BOOL bNew);

    // Dithering
    virtual void SetDither(BOOL bNew);

    // Farbe
    virtual void SetColor(Color aNew);

    // Material
    virtual void SetMaterial(Color rNew,
        Base3DMaterialValue=Base3DMaterialAmbient,
        Base3DMaterialMode=Base3DMaterialFrontAndBack);
    virtual void SetShininess(UINT16 nExponent,
        Base3DMaterialMode=Base3DMaterialFrontAndBack);

    // Texturen
private:
    virtual B3dTexture* CreateTexture(TextureAttributes& rAtt, BitmapEx& rBitmapEx);
    virtual void DestroyTexture(B3dTexture*);
public:
    virtual void SetActiveTexture(B3dTexture* pTex=NULL);

    // Darstellungsqualitaet
    virtual void SetDisplayQuality(UINT8 nNew);

    // PolygonOffset
    virtual void SetPolygonOffset(
        Base3DPolygonOffset eNew=Base3DPolygonOffsetLine, BOOL bNew=FALSE);

    // Beleuchtung setzen/lesen
    virtual void SetLightGroup(B3dLightGroup* pSet, BOOL bSetGlobal=TRUE);

    virtual void SetRenderMode(Base3DRenderMode eNew,
        Base3DMaterialMode=Base3DMaterialFrontAndBack);
    virtual void SetShadeModel(Base3DShadeModel eNew);
    virtual void SetCullMode(Base3DCullMode eNew);

    virtual void SetEdgeFlag(BOOL bNew=TRUE);
    virtual void SetPointSize(double fNew=1.0);
    virtual void SetLineWidth(double fNew=1.0);

    // Ein Objekt in Form einer B3dGeometry direkt ausgeben
    virtual void DrawPolygonGeometry(B3dGeometry& rGeometry, BOOL bOutline=FALSE);

    // Callbacks bei Matrixaenderungen
    virtual void SetTransformationSet(B3dTransformationSet* pSet);

protected:
    // Geometrische Daten uebergeben
    virtual B3dEntity& ImplGetFreeEntity();
    virtual void ImplPostAddVertex(B3dEntity& rEnt);

    virtual void ImplStartPrimitive();
    virtual void ImplEndPrimitive();

    // Callbacks bei Matrixaenderungen
    void PostSetObjectOrientation(B3dTransformationSet* pCaller);
    void PostSetProjection(B3dTransformationSet* pCaller);
    void PostSetTexture(B3dTransformationSet* pCaller);
    void PostSetViewport(B3dTransformationSet* pCaller);

    // lokale Parameter des LightModels
    void SetGlobalAmbientLight(const Color rNew);
    void SetLocalViewer(BOOL bNew=TRUE);
    void SetModelTwoSide(BOOL bNew=FALSE);

    // Hauptschalter fuer die Beleuchtung
    void EnableLighting(BOOL bNew=TRUE);

    // Lichtquellen Interface
    void SetIntensity(const Color rNew,
        Base3DMaterialValue=Base3DMaterialAmbient,
        Base3DLightNumber=Base3DLight0);
    void SetPosition(const Vector3D& rNew,
        Base3DLightNumber=Base3DLight0);
    void SetDirection(const Vector3D& rNew,
        Base3DLightNumber=Base3DLight0);
    void SetSpotDirection(const Vector3D& rNew,
        Base3DLightNumber=Base3DLight0);
    void SetSpotExponent(UINT16 nNew,
        Base3DLightNumber=Base3DLight0);
    void SetSpotCutoff(double fNew,
        Base3DLightNumber=Base3DLight0);
    void SetConstantAttenuation(double fNew,
        Base3DLightNumber=Base3DLight0);
    void SetLinearAttenuation(double fNew,
        Base3DLightNumber=Base3DLight0);
    void SetQuadraticAttenuation(double fNew,
        Base3DLightNumber=Base3DLight0);
    void Enable(BOOL bNew=TRUE,
        Base3DLightNumber=Base3DLight0);
};


#endif          // _B3D_B3DOPNGL_HXX