# DeviceContextC

# Class hierarchy

DeviceContextC

# Overview

The purpose of the device context class is to gather all the device interfaces available to the effects. The interfaces may range from renderin APIs (such as OpenGL, or Direct3D) to music system APIs. The interface holds just enough information to use the API and some helper methods to help the use of the API under the editor. Device context simply holds these interfaces. These interfaces can be queried from the context.

This class is implemented by the system.

Header: | DeviceContextC.h
Library: | core.lib

# Class members

`DeviceContextC();`

#### Remarks

Default constructor. Initialises the structures used by the device context. Used internally.

#### Example

`virtual ~DeviceContextC();`

#### Remarks

The destructor. Releases all resgitered interfaces. Used internally.

#### Example

`virtual DeviceInterfaceI* query_interface( int32 i32Iface );`

#### Parameters

i32Iface
  ID of the interface to query.

#### Return value

Pointer to existing interface. If no interface was found the return value is NULL.

#### Remarks

This is the only method user needs to call. It makes a query to the list inside the device context to see if the queried interface is available. If it is available pointer to the interface will be returned, otherwise the return value is NULL.

The IDs for the interfaces are defined in the header files of the interfaces.

#### Example

`void
TestEffectC::do_frame( DeviceContextC* pContext )
{
OpenGLInterfaceC* pInterface = (OpenGLInterfaceC*)pContext->query_interface( INTERFACE_OPENGL );
if( !pInterface ) {
// No interface available... bail out!
return;
}
// do the effect...
}
`

`virtual void register_interface( int32 i32IFace DeviceInterfaceI* pInterface );`

#### Parameters

i32IFace
  The ID of the interface.
pInterface
  Pointer to the interface to be added.

#### Remarks

The system uses this method to register device interfaces to the device context. This method is used internally.

`virtual void set_name( const char* szName );`

#### Parameters

szName
  A NULL terminated string containing the new name of the effect.

#### Return value

None.

#### Remarks

Sets the name of the effect. It is not necessary to overload this member.

#### Example

Copyright © 2000 Moppi Productions