Admin Production ni-theme
Current Publication

OGLConvertCtrl

LabWindows/CVI

OGLConvertCtrl

int OGLConvertCtrl (int panelHandle, int pictureToConvert);

Purpose

Converts an existing picture control into a OGL control.

The function must be called from the same thread that the parent panel on which the thread resides is created in.

Although you can call OGLNewCtrl to create an OGL control from scratch, it may be more convenient to create and position a picture control in the User Interface Editor and then use this function to convert the picture control into an OGL control after the panel is loaded.

The OGL control has to be created from the same thread that the parent panel on which the thread resides is created in.

Event Type When Received


OGLEVENT_REFRESH Whenever the control is refreshed and during pan/zoom/rotate
EVENT_LEFT_CLICK Left click on control
EVENT_RIGHT_CLICK Right click on control
EVENT_LEFT_DOUBLE_CLICK Left double click on control
EVENT_RIGHT_DOUBLE_CLICK Right double click on control

Note   The CVIOGL control cannot be created on child panels.
Note   When the OGLEVENT_REFRESH event is received, eventData1 specifies whether the view is being modified using the pan/zoom/rotate feature. eventData2 is not used.
Note   The CVIOGL control cannot be used when the system pixel depth is below 8 bits (256 colors).
Note   The CVIOGL control will not resize when a panel and its contents are resized. You must manually resize the CVIOGL control using the following code inside a panel callback.

int CVICALLBACK PanelCallbackWithCVIOGLCtrl (int panel, int event, void *callbackData, int eventData1, int eventData2)

{

int width, height, top, left;


switch (event)

{

case EVENT_PANEL_SIZE:

GetCtrlAttribute(demoPanel, DEMOPANEL_PICTURE, ATTR_TOP, &top);

GetCtrlAttribute(demoPanel, DEMOPANEL_PICTURE, ATTR_LEFT, &left);

GetCtrlAttribute(demoPanel, DEMOPANEL_PICTURE, ATTR_WIDTH, &width);

GetCtrlAttribute(demoPanel, DEMOPANEL_PICTURE, ATTR_HEIGHT, &height);


OGLSetCtrlAttribute (demoPanel, demoControl, OGLATTR_TOP, top);

OGLSetCtrlAttribute (demoPanel, demoControl, OGLATTR_LEFT, left);

OGLSetCtrlAttribute (demoPanel, demoControl, OGLATTR_WIDTH, width);

OGLSetCtrlAttribute (demoPanel, demoControl, OGLATTR_HEIGHT, height);


OGLRefreshGraph(demoPanel,demoControl);

break;

}

return 0;

}

Parameters

Input
Name Type Description
panelHandle int The specifier for a particular panel that is currently in memory.

This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function. The panel has to be a parent panel and should not be the child of any other panel. The panel cannot be scrollable or resizeable.
pictureToConvert int Specifies the picture control on the panel to convert into an OGL control.

Pass the defined constant (located in the UIR header file) that was assigned to the picture control in the User Interface Editor or the ID returned by the NewCtrl or DuplicateCtrl function.

Return Value

Name Type Description
OGLControlId int Returns the ID used to specify this control in subsequent function calls. Negative values indicate that an error occurred.

Error Codes

-1 to -999 A User Interface Library error code. (constants are available in userint.h)
-1001 The panel is a child panel.
-1002 No window system handle for panel.
-1003 Only a canvas or picture can be converted into an OGL control.
-1004 Error registering window.
-1005 Error creating window.
-1006 The OGL control could not be found.
-1007 Too many controls.
-1008 The OGL plot could not be found.
-1009 Too many plots.
-1010 The label attribute could not be obtained.
-1011 Could not hide the control.
-1012 Could not unhide the control.
-1013 Could not move the control.
-1014 Could not resize the control.
-1015 Invalid parameters passed to the function.
-1016 The attribute is an invalid OGL control attribute.
-1017 The attribute is an invalid OGL plot attribute.
-1018 The last operation caused an OpenGL error. Use OGLGetLastOpenGLError to get the error code.
-1019 The last operation caused a Windows error. Use GetLastError to get the error code.
-1020 The font name is too long.
-1021 The attribute value cannot be set.
-1022 Not enough memory.
-1023 Could not set the context.
-1024 Could not restore the context.
-1025 The control was created by another thread.
-1026 The data type passed to this function was invalid.
-1027 Trying to get an uninitialized or zero length array attribute.
-1028 The function has to be called from the main thread.
-1029 The control is already being refreshed.
-1030 The pixel depth cannot be less than 8 bits (256 colors).

Additional Information

Library: OpenGL 3D Plotting Control

Include file: custctrl\cviogl.h

LabWindows/CVI compatibility: LabWindows/CVI 5.0 and later

Examples

Refer to the following examples that use the OGLConvertCtrl function:

  • apps\oglscxi\oglscxi.cws

    Open example
  • userint\custctrl\cviogl\oglarm.cws

    Open example
  • userint\custctrl\cviogl\ogldemo.cws

    Open example
  • userint\custctrl\cviogl\ogldraw.cws

    Open example
  • userint\custctrl\cviogl\simple.cws

    Open example