Cocos2d-x  v4
Device Class Referenceabstract

New or create resources from Device. More...

Inherits Ref.

Inherited by DeviceGL, and DeviceMTL.

Public Member Functions

virtual CommandBuffernewCommandBuffer ()=0
 New a CommandBuffer object, not auto released. More...
 
virtual BuffernewBuffer (size_t size, BufferType type, BufferUsage usage)=0
 New a Buffer object, not auto released. More...
 
virtual TextureBackendnewTexture (const TextureDescriptor &descriptor)=0
 New a TextureBackend object, not auto released. More...
 
virtual DepthStencilStatecreateDepthStencilState (const DepthStencilDescriptor &descriptor)=0
 Create an auto released DepthStencilState object. More...
 
virtual RenderPipelinenewRenderPipeline ()=0
 New a RenderPipeline object, not auto released. More...
 
virtual void setFrameBufferOnly (bool frameBufferOnly)=0
 This property controls whether or not the drawables' metal textures may only be used for framebuffer attachments (YES) or whether they may also be used for texture sampling and pixel read/write operations (NO). More...
 
virtual ProgramnewProgram (const std::string &vertexShader, const std::string &fragmentShader)=0
 Create an auto released Program. More...
 
DeviceInfogetDeviceInfo () const
 Get a DeviceInfo object. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Static Public Member Functions

static DevicegetInstance ()
 Returns a shared instance of the device.
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

New or create resources from Device.

Member Function Documentation

◆ newCommandBuffer()

virtual CommandBuffer* newCommandBuffer ( )
pure virtual

New a CommandBuffer object, not auto released.

Returns
A CommandBuffer object.

Implemented in DeviceMTL, and DeviceGL.

◆ newBuffer()

virtual Buffer* newBuffer ( size_t  size,
BufferType  type,
BufferUsage  usage 
)
pure virtual

New a Buffer object, not auto released.

Parameters
sizeSpecifies the size in bytes of the buffer object's new data store.
typeSpecifies the target buffer object. The symbolic constant must be BufferType::VERTEX or BufferType::INDEX.
usageSpecifies the expected usage pattern of the data store. The symbolic constant must be BufferUsage::STATIC, BufferUsage::DYNAMIC.
Returns
A Buffer object.

◆ newTexture()

virtual TextureBackend* newTexture ( const TextureDescriptor descriptor)
pure virtual

New a TextureBackend object, not auto released.

Parameters
descriptorSpecifies texture description.
Returns
A TextureBackend object.

Implemented in DeviceMTL, and DeviceGL.

◆ createDepthStencilState()

virtual DepthStencilState* createDepthStencilState ( const DepthStencilDescriptor descriptor)
pure virtual

Create an auto released DepthStencilState object.

Parameters
descriptorSpecifies depth and stencil description.
Returns
An auto release DepthStencilState object.

Implemented in DeviceMTL, and DeviceGL.

◆ newRenderPipeline()

virtual RenderPipeline* newRenderPipeline ( )
pure virtual

New a RenderPipeline object, not auto released.

Parameters
descriptorSpecifies render pipeline description.
Returns
A RenderPipeline object.

Implemented in DeviceMTL, and DeviceGL.

◆ setFrameBufferOnly()

virtual void setFrameBufferOnly ( bool  frameBufferOnly)
pure virtual

This property controls whether or not the drawables' metal textures may only be used for framebuffer attachments (YES) or whether they may also be used for texture sampling and pixel read/write operations (NO).

Parameters
frameBufferOnlyA value of YES allows CAMetalLayer to allocate the MTLTexture objects in ways that are optimized for display purposes that makes them unsuitable for sampling. The recommended value for most applications is YES.
Note
This interface is specificaly designed for metal.

Implemented in DeviceMTL, and DeviceGL.

◆ newProgram()

virtual Program* newProgram ( const std::string &  vertexShader,
const std::string &  fragmentShader 
)
pure virtual

Create an auto released Program.

Parameters
vertexShaderSpecifes this is a vertex shader source.
fragmentShaderSpecifes this is a fragment shader source.
Returns
A Program instance.

Implemented in DeviceMTL, and DeviceGL.

◆ getDeviceInfo()

DeviceInfo* getDeviceInfo ( ) const
inline

Get a DeviceInfo object.

Returns
A DeviceInfo object.

The documentation for this class was generated from the following file: