This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/gpu/opengl/gl_immediate.hh
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

66 lines
1.5 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2016 by Mike Erwin. All rights reserved. */
/** \file
* \ingroup gpu
*
* Mimics old style opengl immediate mode drawing.
*/
#pragma once
#include "MEM_guardedalloc.h"
#include "glew-mx.h"
#include "gpu_immediate_private.hh"
namespace blender::gpu {
/* size of internal buffer */
#define DEFAULT_INTERNAL_BUFFER_SIZE (4 * 1024 * 1024)
class GLImmediate : public Immediate {
private:
/* Use two buffers for strict and non-strict vertex count to
* avoid some huge driver slowdown (see T70922).
* Use accessor functions to get / modify. */
struct {
/** Opengl Handle for this buffer. */
GLuint vbo_id = 0;
/** Offset of the mapped data in data. */
size_t buffer_offset = 0;
/** Size of the whole buffer in bytes. */
size_t buffer_size = 0;
} buffer, buffer_strict;
/** Size in bytes of the mapped region. */
size_t bytes_mapped_ = 0;
/** Vertex array for this immediate mode instance. */
GLuint vao_id_ = 0;
public:
GLImmediate();
~GLImmediate();
uchar *begin() override;
void end() override;
private:
GLuint &vbo_id()
{
return strict_vertex_len ? buffer_strict.vbo_id : buffer.vbo_id;
};
size_t &buffer_offset()
{
return strict_vertex_len ? buffer_strict.buffer_offset : buffer.buffer_offset;
};
size_t &buffer_size()
{
return strict_vertex_len ? buffer_strict.buffer_size : buffer.buffer_size;
};
};
} // namespace blender::gpu