docs/html/glTexture_8h_source.html
| | Jetson Inference
DNN Vision Library |
glTexture.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __GL_TEXTURE_H__
24 #define __GL_TEXTURE_H__
25
26
27 #include "glBuffer.h"
28
29
34 #ifndef GL_RGB32F
35 #define GL_RGB32F GL_RGB32F_ARB
36 #endif
37
42 #ifndef GL_RGBA32F
43 #define GL_RGBA32F GL_RGBA32F_ARB
44 #endif
45
46
52 {
53 public:
61static glTexture* Create( uint32_t width, uint32_t height, uint32_t format, void* data=NULL );
62
66~glTexture();
67
71bool Bind();
72
76void Unbind();
77
81void Render( float x, float y );
82
86void Render( float x, float y, float width, float height );
87
91void Render( const float4& rect );
92
96inline uint32_t GetID() const { return mID; }
97
101inline uint32_t GetWidth() const { return mWidth; }
102
106inline uint32_t GetHeight() const { return mHeight; }
107
111inline uint32_t GetFormat() const { return mFormat; }
112
116inline uint32_t GetSize() const { return mSize; }
117
133void* Map( uint32_t device, uint32_t flags );
134
139void Unmap();
140
158bool Copy( void* ptr, uint32_t flags );
159
176bool Copy( void* ptr, uint32_t size, uint32_t flags );
177
198bool Copy( void* ptr, uint32_t offset, uint32_t size, uint32_t flags );
199
200
201 private:
202glTexture();
203
204bool init( uint32_t width, uint32_t height, uint32_t format, void* data );
205
206 uint32_t allocDMA( uint32_t type );
207 cudaGraphicsResource* allocInterop( uint32_t type, uint32_t flags );
208
209 uint32_t mID;
210 uint32_t mPackDMA;
211 uint32_t mUnpackDMA;
212
213 uint32_t mWidth;
214 uint32_t mHeight;
215 uint32_t mFormat;
216 uint32_t mSize;
217
218 uint32_t mMapDevice;
219 uint32_t mMapFlags;
220
221 cudaGraphicsResource* mInteropPack;
222 cudaGraphicsResource* mInteropUnpack;
223 };
224
225
226 #endif
static glTexture * Create(uint32_t width, uint32_t height, uint32_t format, void *data=NULL)
Allocate an OpenGL texture.
uint32_t GetFormat() const
Retrieve the texture's format (e.g.
Definition: glTexture.h:111
bool Copy(void *ptr, uint32_t flags)
Copy entire contents of the texture to/from CPU or CUDA memory.
uint32_t GetID() const
Retrieve the OpenGL resource handle of the texture.
Definition: glTexture.h:96
void Unmap()
Unmap the texture from CPU/CUDA access.
~glTexture()
Free the texture.
void * Map(uint32_t device, uint32_t flags)
Map the texture for accessing from the CPU or CUDA.
uint32_t GetWidth() const
Retrieve the width in pixels of the texture.
Definition: glTexture.h:101
bool Bind()
Activate using the texture.
OpenGL texture with CUDA interoperability.
Definition: glTexture.h:51
void Render(float x, float y)
Render the texture at the specified window coordinates.
void Unbind()
Deactivate using the texture.
uint32_t GetSize() const
Retrieve the size in bytes of the texture.
Definition: glTexture.h:116
uint32_t GetHeight() const
Retrieve the height in pixels of the texture.
Definition: glTexture.h:106