Add OGLTextureView
This commit is contained in:
		 Fernando Sahmkow
					Fernando Sahmkow
				
			
				
					committed by
					
						 ReinUsesLisp
						ReinUsesLisp
					
				
			
			
				
	
			
			
			 ReinUsesLisp
						ReinUsesLisp
					
				
			
						parent
						
							6b0695b3cd
						
					
				
				
					commit
					3b26206dbd
				
			| @@ -33,6 +33,24 @@ void OGLTexture::Release() { | ||||
|     handle = 0; | ||||
| } | ||||
|  | ||||
| void OGLTextureView::Create() { | ||||
|     if (handle != 0) | ||||
|         return; | ||||
|  | ||||
|     MICROPROFILE_SCOPE(OpenGL_ResourceCreation); | ||||
|     glGenTextures(1, &handle); | ||||
| } | ||||
|  | ||||
| void OGLTextureView::Release() { | ||||
|     if (handle == 0) | ||||
|         return; | ||||
|  | ||||
|     MICROPROFILE_SCOPE(OpenGL_ResourceDeletion); | ||||
|     glDeleteTextures(1, &handle); | ||||
|     OpenGLState::GetCurState().UnbindTexture(handle).Apply(); | ||||
|     handle = 0; | ||||
| } | ||||
|  | ||||
| void OGLSampler::Create() { | ||||
|     if (handle != 0) | ||||
|         return; | ||||
|   | ||||
| @@ -36,6 +36,31 @@ public: | ||||
|     GLuint handle = 0; | ||||
| }; | ||||
|  | ||||
| class OGLTextureView : private NonCopyable { | ||||
| public: | ||||
|     OGLTextureView() = default; | ||||
|  | ||||
|     OGLTextureView(OGLTextureView&& o) noexcept : handle(std::exchange(o.handle, 0)) {} | ||||
|  | ||||
|     ~OGLTextureView() { | ||||
|         Release(); | ||||
|     } | ||||
|  | ||||
|     OGLTextureView& operator=(OGLTextureView&& o) noexcept { | ||||
|         Release(); | ||||
|         handle = std::exchange(o.handle, 0); | ||||
|         return *this; | ||||
|     } | ||||
|  | ||||
|     /// Creates a new internal OpenGL resource and stores the handle | ||||
|     void Create(); | ||||
|  | ||||
|     /// Deletes the internal OpenGL resource | ||||
|     void Release(); | ||||
|  | ||||
|     GLuint handle = 0; | ||||
| }; | ||||
|  | ||||
| class OGLSampler : private NonCopyable { | ||||
| public: | ||||
|     OGLSampler() = default; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user