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
Christian Rauch a296b8f694 GPU: replace GLEW with libepoxy
With libepoxy we can choose between EGL and GLX at runtime, as well as
dynamically open EGL and GLX libraries without linking to them.

This will make it possible to build with Wayland, EGL, GLVND support while
still running on systems that only have X11, GLX and libGL. It also paves
the way for headless rendering through EGL.

libepoxy is a new library dependency, and is included in the precompiled
libraries. GLEW is no longer a dependency, and WITH_SYSTEM_GLEW was removed.

Includes contributions by Brecht Van Lommel, Ray Molenkamp, Campbell Barton
and Sergey Sharybin.

Ref T76428

Differential Revision: https://developer.blender.org/D15291
2022-08-15 16:10:29 +02:00

64 lines
1.4 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 "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