axmol/cocos/renderer/backend/opengl/DeviceGL.h

111 lines
4.0 KiB
C++

/****************************************************************************
Copyright (c) 2018-2019 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "../Device.h"
#include "platform/CCGL.h"
CC_BACKEND_BEGIN
/**
* @addtogroup _opengl
* @{
*/
/**
* Use to create resoureces.
*/
class DeviceGL : public Device
{
public:
DeviceGL();
~DeviceGL();
GLint getDefaultFBO() const;
/**
* New a CommandBuffer object, not auto released.
* @return A CommandBuffer object.
*/
virtual CommandBuffer* newCommandBuffer() override;
/**
* New a Buffer object, not auto released.
* @param size Specifies the size in bytes of the buffer object's new data store.
* @param type Specifies the target buffer object. The symbolic constant must be BufferType::VERTEX or
* BufferType::INDEX.
* @param usage Specifies the expected usage pattern of the data store. The symbolic constant must be
* BufferUsage::STATIC, BufferUsage::DYNAMIC.
* @return A Buffer object.
*/
virtual Buffer* newBuffer(std::size_t size, BufferType type, BufferUsage usage) override;
/**
* New a TextureBackend object, not auto released.
* @param descriptor Specifies texture description.
* @return A TextureBackend object.
*/
virtual TextureBackend* newTexture(const TextureDescriptor& descriptor) override;
RenderTarget* newDefaultRenderTarget(TargetBufferFlags rtf) override;
RenderTarget* newRenderTarget(TargetBufferFlags rtf,
TextureBackend* colorAttachment,
TextureBackend* depthAttachment,
TextureBackend* stencilAttachhment) override;
virtual DepthStencilState* newDepthStencilState() override;
/**
* New a RenderPipeline object, not auto released.
* @param descriptor Specifies render pipeline description.
* @return A RenderPipeline object.
*/
virtual RenderPipeline* newRenderPipeline() override;
/**
* Design for metal.
*/
virtual void setFrameBufferOnly(bool frameBufferOnly) override {}
/**
* New a Program, not auto released.
* @param vertexShader Specifes this is a vertex shader source.
* @param fragmentShader Specifes this is a fragment shader source.
* @return A Program instance.
*/
virtual Program* newProgram(const std::string& vertexShader, const std::string& fragmentShader) override;
protected:
/**
* New a shaderModule, not auto released.
* @param stage Specifies whether is vertex shader or fragment shader.
* @param source Specifies shader source.
* @return A ShaderModule object.
*/
virtual ShaderModule* newShaderModule(ShaderStage stage, const std::string& source) override;
GLint _defaultFBO = 0; // The value gets from glGetIntegerv, so need to use GLint
};
// end of _opengl group
/// @}
CC_BACKEND_END