Message 1 of 3
OpenGL commands

Not applicable
03-08-2004
02:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I would like to draw to Inventor view using my own OpenGL commands with C++. For example I would like to draw s single polygon using glVertex3f(...) OpenGL function. Can anybody tell me how to draw to Inventor display using OpenGL commands? (I can not use Inventor own graphical primitives for my purposes and I have to use pure OpenGL commands)
I have made following code that initializes my OpenGL context (m_pApplication is pointer to Application object):
// Find out hWnd to current view window
CComPtr pActiveView;
m_pApplication->get_ActiveView(&pActiveView);
pActiveView->get_HWND((long*)&hWnd);
// get the device context (DC)
hDC = GetDC( hWnd );
// Create new device context
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
Then I try to draw using OpenGL commands:
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex3f(.5, 0, 0);
glColor3f(0, 1, 0);
glVertex3f(0, .5, 0);
glColor3f(0, 0, 1);
glVertex3f(-.5, 0, 0);
glEnd();
SwapBuffers(hDC);
I can not get any OpenGL primitives visible into Inventor view display. Even if I try to clear current view using glClear it seems not to happen.
Can you tell me how to draw into Inventor display using OpenGL commands?
Regards,
Janne Hietanen
I would like to draw to Inventor view using my own OpenGL commands with C++. For example I would like to draw s single polygon using glVertex3f(...) OpenGL function. Can anybody tell me how to draw to Inventor display using OpenGL commands? (I can not use Inventor own graphical primitives for my purposes and I have to use pure OpenGL commands)
I have made following code that initializes my OpenGL context (m_pApplication is pointer to Application object):
// Find out hWnd to current view window
CComPtr
m_pApplication->get_ActiveView(&pActiveView);
pActiveView->get_HWND((long*)&hWnd);
// get the device context (DC)
hDC = GetDC( hWnd );
// Create new device context
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
Then I try to draw using OpenGL commands:
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex3f(.5, 0, 0);
glColor3f(0, 1, 0);
glVertex3f(0, .5, 0);
glColor3f(0, 0, 1);
glVertex3f(-.5, 0, 0);
glEnd();
SwapBuffers(hDC);
I can not get any OpenGL primitives visible into Inventor view display. Even if I try to clear current view using glClear it seems not to happen.
Can you tell me how to draw into Inventor display using OpenGL commands?
Regards,
Janne Hietanen