CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TrRndLocalContext.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23// Base local context interface
24
25#ifndef ODTRRNDLOCALCONTEXT
26#define ODTRRNDLOCALCONTEXT
28#include "TD_PackPush.h"
36#define GLProcedure0(t,a) virtual t no##a() const{ return (t)0; }
37#define GLProcedure(t,a,b) virtual t no##a(b) const{ return (t)0; }
38#define GLFunction0(t,a) virtual t no##a() const {}
39#define GLFunction(t,a,b) virtual t no##a(b) const {}
40#define GLFunction2(t,a,b,c) virtual t no##a(b,c) const {}
41#define GLFunction3(t,a,b,c,d) virtual t no##a(b,c,d) const {}
42#define GLFunction4(t,a,b,c,d,e) virtual t no##a(b,c,d,e) const {}
43#define GLFunction5(t,a,b,c,d,e,f) virtual t no##a(b,c,d,e,f) const {}
44#define GLFunction6(t,a,b,c,d,e,f,g) virtual t no##a(b,c,d,e,f,g) const {}
45#define GLFunction7(t,a,b,c,d,e,f,g,h) virtual t no##a(b,c,d,e,f,g,h) const {}
46#define GLFunction9(t,a,b,c,d,e,f,g,h,i,j) virtual t no##a(b,c,d,e,f,g,h,i,j) const {}
47
48struct GLFunctions : public nogl
50 virtual ~GLFunctions(){};
51 virtual void glesSafeDrawArrays(GLenum mode, GLint first, GLsizei count) const
52 {
53 noglDrawArrays(mode, first, count);
54 };
55 virtual bool noglDrawSimplePoint(const GLfloat *pPoint) const { return false; }
56 virtual bool noglDrawSimplePoint(const GLdouble *pPoint) const { return false; }
57 virtual bool noglDrawSimpleLine(const GLfloat *pPoint0, const GLfloat *pPoint1) const { return false; }
58 virtual bool noglDrawSimpleLine(const GLdouble *pPoint0, const GLdouble *pPoint1) const { return false; }
59 virtual bool noglDrawSimpleIndexedPoint(GLuint id) const { return false; }
60 virtual bool noglDrawSimpleIndexedLine(GLuint id0, GLuint id1) const { return false; }
61 virtual bool noglWireframeMode(bool bEnable) const { return false; }
63};
65class OdTrRndNoGLShaderState;
66class OdTrRndLocalContext : public OdRxObject, public GLFunctions
68 virtual void CreateExtensionRegistry() const{};
69 public:
71 { enum { kMaxDrawBuffers = 4 };
72#if defined(_MSC_VER) && (_MSC_VER < 1900)
74#else
76#endif
77 int numBufs() const
78 { int nBufs = 1;
79 for (int nBuf = 1; nBuf < kMaxDrawBuffers; nBuf++)
80 { if (m_nBuf[nBuf]) nBufs++; else break; }
81 return nBufs;
82 }
83#if defined(_MSC_VER) && (_MSC_VER < 1900)
85 {
86 for (unsigned int i = 0; i < kMaxDrawBuffers; i++)
87 {
88 m_nBuf[i] = 0;
89 }
90 }
91
92 DrawBufferLayout(GLenum buf0, GLenum buf1 = 0, GLenum buf2 = 0, GLenum buf3 = 0)
93 {
94 for (unsigned int i = 0; i < kMaxDrawBuffers; i++)
95 {
96 switch (i)
97 {
98 case 0: m_nBuf[i] = buf0; break;
99 case 1: m_nBuf[i] = buf1; break;
100 case 2: m_nBuf[i] = buf2; break;
101 case 3: m_nBuf[i] = buf3; break;
102 default: m_nBuf[i] = 0;
103 }
104 }
105 }
106#else
107 DrawBufferLayout() = default;
108 DrawBufferLayout(GLenum buf0, GLenum buf1 = 0, GLenum buf2 = 0, GLenum buf3 = 0)
109 : m_nBuf{ buf0, buf1, buf2, buf3 } { }
110#endif
111 };
114 ReadBufferLayout() = default;
116 : m_nBuf(buf) { }
117 };
118 protected:
119 //mutable OdRxObjectPtr m_pExtensionsRegistry;
121 public:
124 {
128 }
129
130 virtual void createContext(OdTrVisRenderClient *pDevice) = 0;
131 virtual void updateContext(OdTrVisRenderClient * /*pDevice*/) { }
132 virtual void destroyContext() = 0;
133
134 virtual bool isContextCreated() const = 0;
135
136 virtual void makeCurrentContext() = 0;
137
138 virtual bool pushCurrentContext() { return false; }
139 virtual bool popCurrentContext() { return false; }
140
141 virtual void presentContext() = 0;
142
143 virtual bool isExtensionBasedEmulation() const { return false; }
144 virtual bool isExtensionSupported(const char * /*pExtensionName*/) { return false; }
145 virtual void *acquireExtensionFunctionPtr(const char * /*pFunctionName*/) { return NULL; }
146
147 // Search OpenGL extension in cross-platform way using our own extensions registry
149 {
150 if (m_pExtensionsRegistry == NULL)
151 CreateExtensionRegistry();
152 return *m_pExtensionsRegistry;
153 }
154
155 virtual OdTrRndNoGLShaderState* CreateShaderState() const {return NULL;};
156
157 // Returns active draw buffer layout or nullptr if layouts doesn't supported.
158 virtual const DrawBufferLayout *activeDrawBufferLayout() const { return NULL; }
159 // Return true if active draw buffer layout is fully compatible with specified layout.
160 virtual bool isDrawBufferLayoutCompatible(const DrawBufferLayout & /*dbl*/) const { return true; }
161 // Change active draw buffer layout. Return previous active layout state.
163
164 // Returns active read buffer layout or nullptr if layouts doesn't supported.
165 virtual const ReadBufferLayout *activeReadBufferLayout() const { return NULL; }
166 // Return true if active read buffer layout is fully compatible with specified layout.
167 virtual bool isReadBufferLayoutCompatible(const ReadBufferLayout & /*rbl*/) const { return true; }
168 // Change active read buffer layout. Return previous active layout state.
170};
171
173
178{
179 public:
182
183 virtual void createContext(OdTrVisRenderClient * /*pDevice*/) { }
184 virtual void destroyContext() { }
185
186 virtual bool isContextCreated() const { return true; }
187
188 virtual void makeCurrentContext() { }
189
190 virtual void presentContext() { }
191};
192
197{
198 protected:
201public:
203 : m_pLc(nullptr)
204 {
205 if (!pLc->isDrawBufferLayoutCompatible(changeLayout))
206 m_prevLayout = pLc->changeDrawBufferLayout(changeLayout), m_pLc = pLc;
207 }
209 {
210 if (m_pLc)
211 m_pLc->changeDrawBufferLayout(m_prevLayout);
212 }
213};
214
219{
220 protected:
223 public:
225 : m_pLc(nullptr)
226 {
227 if (!pLc->isReadBufferLayoutCompatible(changeLayout))
228 m_prevLayout = pLc->changeReadBufferLayout(changeLayout), m_pLc = pLc;
229 }
231 {
232 if (m_pLc)
233 m_pLc->changeReadBufferLayout(m_prevLayout);
234 }
235};
236
237#include "TD_PackPop.h"
238
239#endif // ODTRRNDLOCALCONTEXT
OdSmartPtr< OdTrRndLocalContext > OdTrRndLocalContextPtr
OdTrRndLocalContext::DrawBufferLayout m_prevLayout
OdTrRndDrawBufferLayout(OdTrRndLocalContext *pLc, const OdTrRndLocalContext::DrawBufferLayout &changeLayout)
OdTrRndLocalContext * m_pLc
virtual OdTrRndNoGLShaderState * CreateShaderState() const
virtual bool isExtensionBasedEmulation() const
virtual bool popCurrentContext()
virtual bool isDrawBufferLayoutCompatible(const DrawBufferLayout &) const
OdTrRndNoGLExtensionsRegistry * m_pExtensionsRegistry
virtual void presentContext()=0
virtual void destroyContext()=0
virtual bool isExtensionSupported(const char *)
virtual void updateContext(OdTrVisRenderClient *)
virtual bool pushCurrentContext()
OdTrRndNoGLExtensionsRegistry & extensionsRegistry() const
virtual void * acquireExtensionFunctionPtr(const char *)
virtual ReadBufferLayout changeReadBufferLayout(const ReadBufferLayout &)
virtual void createContext(OdTrVisRenderClient *pDevice)=0
virtual void makeCurrentContext()=0
virtual DrawBufferLayout changeDrawBufferLayout(const DrawBufferLayout &)
virtual bool isContextCreated() const =0
virtual bool isReadBufferLayoutCompatible(const ReadBufferLayout &) const
virtual const DrawBufferLayout * activeDrawBufferLayout() const
virtual const ReadBufferLayout * activeReadBufferLayout() const
virtual bool isContextCreated() const
virtual void createContext(OdTrVisRenderClient *)
virtual void makeCurrentContext()
OdTrRndReadBufferLayout(OdTrRndLocalContext *pLc, const OdTrRndLocalContext::ReadBufferLayout &changeLayout)
OdTrRndLocalContext * m_pLc
OdTrRndLocalContext::ReadBufferLayout m_prevLayout
GLsizei GLsizei * count
Definition gles2_ext.h:276
GLenum GLuint GLenum GLbitfield GLboolean GLfloat GLclampf GLenum GLenum GLfloat GLsizei
virtual bool noglDrawSimpleIndexedLine(GLuint id0, GLuint id1) const
virtual void glesSafeDrawArrays(GLenum mode, GLint first, GLsizei count) const
GLenum GLuint GLenum GLbitfield GLboolean GLfloat GLclampf GLenum GLenum GLfloat
virtual ~GLFunctions()
virtual bool noglDrawSimplePoint(const GLfloat *pPoint) const
virtual bool noglWireframeMode(bool bEnable) const
virtual bool noglDrawSimpleLine(const GLfloat *pPoint0, const GLfloat *pPoint1) const
virtual bool noglDrawSimpleIndexedPoint(GLuint id) const
DrawBufferLayout(GLenum buf0, GLenum buf1=0, GLenum buf2=0, GLenum buf3=0)
Definition NoGL.h:30
double GLdouble
Definition NoGL.h:43
unsigned int GLuint
Definition NoGL.h:40