mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:12:44 +00:00 
			
		
		
		
	 7ad70f623e
			
		
	
	
		7ad70f623e
		
	
	
	
	
		
			
			As stated in the manual:
     glDeleteTextures silently ignores 0's and names that do not
     correspond to existing textures.
If we do not skip these 0 names, they end up as invalid free texture
names in our name allocator.
		
	
			
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			745 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			745 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibGL/Tex/NameAllocator.h>
 | |
| 
 | |
| namespace GL {
 | |
| 
 | |
| void TextureNameAllocator::allocate(GLsizei count, GLuint* textures)
 | |
| {
 | |
|     for (auto i = 0; i < count; ++i) {
 | |
|         if (!m_free_texture_names.is_empty()) {
 | |
|             textures[i] = m_free_texture_names.top();
 | |
|             m_free_texture_names.pop();
 | |
|         } else {
 | |
|             // We're out of free previously allocated names. Let's allocate a new contiguous amount from the
 | |
|             // last known texture name
 | |
|             textures[i] = m_last_texture_id++;
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| void TextureNameAllocator::free(GLuint texture)
 | |
| {
 | |
|     m_free_texture_names.push(texture);
 | |
| }
 | |
| 
 | |
| }
 |