MCPcopy Index your code
hub / github.com/ad-si/LuaCAD / init

Method init

OpenCSG/src/channelManager.cpp:124–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122 }
123
124 bool ChannelManager::init() {
125
126 assert(!gInUse);
127 if (gInUse)
128 return false;
129 gInUse = true;
130
131 OffscreenType newOffscreenType = static_cast<OffscreenType>(getOption(OffscreenSetting));
132
133 if ( newOffscreenType == OpenCSG::AutomaticOffscreenType
134 || newOffscreenType == OpenCSG::FrameBufferObject
135 ) {
136 if (OPENCSG_HAS_EXT(ARB_framebuffer_object)) {
137 newOffscreenType = OpenCSG::FrameBufferObjectARB;
138 }
139 else
140 if ( OPENCSG_HAS_EXT(EXT_framebuffer_object)
141 && OPENCSG_HAS_EXT(EXT_packed_depth_stencil)
142 ) {
143 newOffscreenType = OpenCSG::FrameBufferObjectEXT;
144 }
145 else {
146 // At least one set of the above OpenGL extensions is required
147 return false;
148 }
149 }
150
151 mOffscreenBuffer = OpenGL::getOffscreenBuffer(newOffscreenType);
152
153 if (!mOffscreenBuffer)
154 {
155 // Creating the offscreen buffer failed, maybe the OpenGL extension
156 // for the specific offscreen buffer type is not supported
157 return false;
158 }
159
160 if (!mOffscreenBuffer->ReadCurrent())
161 {
162 return false;
163 }
164
165 const int dx = OpenGL::canvasPos[2] - OpenGL::canvasPos[0];
166 const int dy = OpenGL::canvasPos[3] - OpenGL::canvasPos[1];
167
168 int tx = dx;
169 int ty = dy;
170 // We don't need to enlarge the texture to the next largest power-of-two size if:
171 // - the ARB_texture_non_power_of_two extension is supported
172 // - or any of the texture rectangle extensions is supported
173 // Negating this gives the following expression from hell:
174 if ( !OPENCSG_HAS_EXT(ARB_texture_non_power_of_two)
175 && !OPENCSG_HAS_EXT(ARB_texture_rectangle)
176 && !OPENCSG_HAS_EXT(EXT_texture_rectangle)
177 && !OPENCSG_HAS_EXT(NV_texture_rectangle)
178 ) {
179 // blow up the texture to legal power-of-two size :-(
180 tx = nextPow2(dx);
181 ty = nextPow2(dy);

Callers 2

renderSCSFunction · 0.80
renderGoldfeatherFunction · 0.80

Calls 15

getOptionFunction · 0.85
getOffscreenBufferFunction · 0.85
nextPow2Function · 0.85
defaultsFunction · 0.85
newValueMethod · 0.80
getMaxMethod · 0.80
ReadCurrentMethod · 0.45
IsInitializedMethod · 0.45
InitializeMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected