GCC Code Coverage Report


Directory: ./
File: tests/gl.cpp
Date: 2024-08-14 11:04:57
Exec Total Coverage
Lines: 0 25 0.0%
Branches: 0 46 0.0%

Line Branch Exec Source
1 #include <stdio.h>
2
3 #include <iostream>
4
5 #ifdef _WIN32
6 #include <Windows.h>
7 #endif
8
9 #include <osg/GLExtensions>
10 #include <osgViewer/Viewer>
11
12 const int OSG_WIDTH = 1024;
13 const int OSG_HEIGHT = 960;
14
15 class TestSupportOperation : public osg::GraphicsOperation {
16 public:
17 TestSupportOperation()
18 : osg::Referenced(true),
19 osg::GraphicsOperation("TestSupportOperation", false),
20 m_supported(true),
21 m_errorMsg(),
22 m_version(1.3) {}
23
24 virtual void operator()(osg::GraphicsContext* gc) {
25 OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
26 osg::GLExtensions* gl2ext = gc->getState()->get<osg::GLExtensions>();
27
28 if (gl2ext) {
29 if (!gl2ext->isGlslSupported) {
30 m_supported = false;
31 m_errorMsg = "ERROR: GLSL not supported by OpenGL driver.";
32 } else
33 m_version = gl2ext->glVersion;
34 } else {
35 m_supported = false;
36 m_errorMsg = "ERROR: GLSL not supported.";
37 }
38 }
39
40 OpenThreads::Mutex m_mutex;
41 bool m_supported;
42 std::string m_errorMsg;
43 float m_version;
44 };
45
46 int main(int, char**) {
47 #ifdef _WIN32
48 ::SetProcessDPIAware();
49 #endif
50
51 osgViewer::Viewer viewer;
52 viewer.setUpViewInWindow(100, 100, OSG_WIDTH, OSG_HEIGHT);
53
54 // openGL version:
55 osg::ref_ptr<TestSupportOperation> so = new TestSupportOperation;
56 viewer.setRealizeOperation(so.get());
57 viewer.realize();
58
59 if (so->m_supported)
60 std::cout << "GLVersion=" << so->m_version << std::endl;
61 else
62 std::cout << so->m_errorMsg << std::endl;
63
64 return viewer.run();
65 }
66