40 #include <GLKit/GLKVector3.h>
41 #include <GLKit/GLKMatrix4.h>
42 #include <GLKit/GLKMathUtils.h>
46 GLEWContext* glewGetContext()
48 return NCBI_NS_NCBI::CGLGlewContext::GetInstance().GetGlewContext();
60 CGLGlewContext& CGLGlewContext::GetInstance()
62 static CGLGlewContext instance;
78 const char*
str =
reinterpret_cast<const char*
> (glGetString(GL_RENDERER));
83 _TRACE(
"GL_VERSION = " << glGetString(GL_VERSION));
84 _TRACE(
"GL_RENDERER = " << glGetString(GL_RENDERER));
85 _TRACE(
"GL_EXTENSIONS = " << glGetString(GL_EXTENSIONS));
90 if (s.find(
"software renderer") != string::npos) {
92 <<
"CGlUtils::GetAccelerated(): "
93 "auto-detected non-hardware-accelerated platform");
97 <<
"CGlUtils::GetAccelerated(): "
98 "auto-detected hardware-accelerated platform");
113 const char*
value = getenv(
"NCBI_GBENCH_GLERROR");
135 msg =
"CGlUtils::CheckGlError(): unknown error";
138 case GL_INVALID_OPERATION:
139 msg =
"CGlUtils::CheckGlError(): invalid operation";
142 case GL_INVALID_ENUM:
143 msg =
"CGlUtils::CheckGlError(): invalid enum";
146 case GL_INVALID_VALUE:
147 msg =
"CGlUtils::CheckGlError(): invalid value";
150 case GL_STACK_OVERFLOW:
151 msg =
"CGlUtils::CheckGlError(): stack overflow";
154 case GL_STACK_UNDERFLOW:
155 msg =
"CGlUtils::CheckGlError(): stack underflow";
158 case GL_OUT_OF_MEMORY:
159 msg =
"CGlUtils::CheckGlError(): out of memory";
168 GLint
error = glGetError();
169 if (
error == GL_NO_ERROR) {
210 LOG_POST(
Info <<
"OpenGL Vendor: " << glGetString(GL_VENDOR));
211 LOG_POST(
Info <<
"OpenGL Renderer: " << glGetString(GL_RENDERER));
212 LOG_POST(
Info <<
"OpenGL Version: " << glGetString(GL_VERSION));
213 LOG_POST(
Info <<
"OpenGL Extensions: " << glGetString(GL_EXTENSIONS));
218 float projection[16];
221 glGetIntegerv(GL_VIEWPORT, viewport);
222 glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
223 glGetFloatv(GL_PROJECTION_MATRIX, projection);
224 glGetFloatv(GL_CURRENT_COLOR,
color);
227 GLint green_bits = 0;
229 GLint alpha_bits = 0;
230 GLint depth_bits = 0;
231 GLint stencil_bits = 0;
232 glGetIntegerv(GL_RED_BITS, &red_bits);
233 glGetIntegerv(GL_GREEN_BITS, &green_bits);
234 glGetIntegerv(GL_BLUE_BITS, &blue_bits);
235 glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
236 glGetIntegerv(GL_DEPTH_BITS, &depth_bits);
237 glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
241 <<
" Red=" << red_bits <<
" bits"
242 <<
" Green=" << green_bits <<
" bits"
243 <<
" Blue=" << blue_bits <<
" bits"
244 <<
" Alpha=" << alpha_bits <<
" bits");
246 LOG_POST(
Info <<
" Stencil: " << alpha_bits <<
" bits");
249 << viewport[0] <<
", " << viewport[1] <<
", "
250 << viewport[2] <<
", " << viewport[3]);
255 for (
i = 0;
i < 4; ++
i) {
257 for (j = 0; j < 4; ++j) {
265 for (
i = 0;
i < 4; ++
i) {
267 for (j = 0; j < 4; ++j) {
279 << (glIsEnabled(GL_LIGHTING) ?
"enabled" :
"disabled"));
281 << (glIsEnabled(GL_DEPTH_TEST) ?
"enabled" :
"disabled"));
283 << (glIsEnabled(GL_CULL_FACE) ?
"enabled" :
"disabled"));
285 << (glIsEnabled(GL_BLEND) ?
"enabled" :
"disabled"));
287 << (glIsEnabled(GL_ALPHA_TEST) ?
"enabled" :
"disabled"));
289 << (glIsEnabled(GL_TEXTURE_2D) ?
"enabled" :
"disabled"));
294 #ifdef NCBI_OS_DARWIN
300 const GLdouble modelMatrix[16],
301 const GLdouble projMatrix[16],
302 const GLint viewport[4],
307 GLKVector3
object { (float)objx, (
float)objy, (float)objz };
308 GLKMatrix4 model = GLKMatrix4Make(
309 modelMatrix[0], modelMatrix[1], modelMatrix[2], modelMatrix[3],
310 modelMatrix[4], modelMatrix[5], modelMatrix[6], modelMatrix[7],
311 modelMatrix[8], modelMatrix[9], modelMatrix[10], modelMatrix[11],
312 modelMatrix[12], modelMatrix[13], modelMatrix[14], modelMatrix[15]);
313 GLKMatrix4 projection = GLKMatrix4Make(
314 projMatrix[0], projMatrix[1], projMatrix[2], projMatrix[3],
315 projMatrix[4], projMatrix[5], projMatrix[6], projMatrix[7],
316 projMatrix[8], projMatrix[9], projMatrix[10], projMatrix[11],
317 projMatrix[12], projMatrix[13], projMatrix[14], projMatrix[15]);
318 GLKVector3
result = GLKMathProject(
object, model, projection,
const_cast<int*
>(viewport));
329 const GLdouble modelMatrix[16],
330 const GLdouble projMatrix[16],
331 const GLint viewport[4],
336 GLKVector3 window{ (float)winx, (
float)winy, (float)winz };
337 GLKMatrix4 model = GLKMatrix4Make(
338 modelMatrix[0], modelMatrix[1], modelMatrix[2], modelMatrix[3],
339 modelMatrix[4], modelMatrix[5], modelMatrix[6], modelMatrix[7],
340 modelMatrix[8], modelMatrix[9], modelMatrix[10], modelMatrix[11],
341 modelMatrix[12], modelMatrix[13], modelMatrix[14], modelMatrix[15]);
342 GLKMatrix4 projection = GLKMatrix4Make(
343 projMatrix[0], projMatrix[1], projMatrix[2], projMatrix[3],
344 projMatrix[4], projMatrix[5], projMatrix[6], projMatrix[7],
345 projMatrix[8], projMatrix[9], projMatrix[10], projMatrix[11],
346 projMatrix[12], projMatrix[13], projMatrix[14], projMatrix[15]);
347 bool success =
false;
348 GLKVector3
result = GLKMathUnproject(window, model, projection,
const_cast<int*
>(viewport), &success);
352 return (success ? GL_TRUE : GL_FALSE);
static const char * str(char *buf, int n)
NCBI_XNCBI_EXPORT void Abort(void)
Smart abort function.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Info(CExceptionArgs_Base &args)
int gluProjectX(GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz)
EAccelState
status of hardware acceleration.
static EAccelState m_Accel
static EGlDiagMode GetDiagnosticMode()
Get current diagnostic (error handling) mode.
static void DumpState()
Dump many of the most common OpenGL states.
static bool CheckGlError()
Check if there are any OpenGL errors.
static string GetErrMsg(GLint error)
Get message for specified OpenGL error.
int gluUnProjectX(GLdouble winx, GLdouble winy, GLdouble winz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *objx, GLdouble *objy, GLdouble *objz)
static EAccelState GetAccelerated(void)
Get the status of hardware acceleration.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
const GenericPointer< typename T::ValueType > T2 value
int strcmp(const char *str1, const char *str2)
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Standard mechanism to include OpenGL headers for all platforms.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)