Remove glew include in libopenrecorder
This commit is contained in:
parent
c69ea65ac2
commit
ab10f335e9
@ -623,6 +623,12 @@ void IrrDriver::initDevice()
|
||||
"RecorderConfig is invalid, use the default one.");
|
||||
}
|
||||
|
||||
ogrRegReadPixelsFunction((ogrFucReadPixels)glReadPixels);
|
||||
ogrRegPBOFunctions((ogrFucGenBuffers)glGenBuffers,
|
||||
(ogrFucBindBuffer)glBindBuffer, (ogrFucBufferData)glBufferData,
|
||||
(ogrFucDeleteBuffers)glDeleteBuffers, (ogrFucMapBuffer)glMapBuffer,
|
||||
(ogrFucUnmapBuffer)glUnmapBuffer);
|
||||
|
||||
ogrRegGeneralCallback(OGR_CBT_START_RECORDING,
|
||||
[] (void* user_data) { MessageQueue::add
|
||||
(MessageQueue::MT_GENERIC, _("Video recording started.")); }, NULL);
|
||||
|
@ -8,11 +8,6 @@
|
||||
#include "vpx_encoder.hpp"
|
||||
#include "wasapi_recorder.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <GL/glew.h>
|
||||
}
|
||||
|
||||
const uint32_t E_GL_PIXEL_PACK_BUFFER = 0x88EB;
|
||||
const uint32_t E_GL_STREAM_READ = 0x88E1;
|
||||
const uint32_t E_GL_READ_ONLY = 0x88B8;
|
||||
@ -30,14 +25,14 @@ CaptureLibrary::CaptureLibrary(RecorderConfig* rc)
|
||||
m_decompress_handle = tjInitDecompress();
|
||||
if (m_recorder_cfg->m_triple_buffering > 0)
|
||||
{
|
||||
glGenBuffers(3, m_pbo);
|
||||
ogrGenBuffers(3, m_pbo);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo[i]);
|
||||
glBufferData(GL_PIXEL_PACK_BUFFER, m_recorder_cfg->m_width *
|
||||
m_recorder_cfg->m_height * 4, NULL, GL_STREAM_READ);
|
||||
ogrBindBuffer(E_GL_PIXEL_PACK_BUFFER, m_pbo[i]);
|
||||
ogrBufferData(E_GL_PIXEL_PACK_BUFFER, m_recorder_cfg->m_width *
|
||||
m_recorder_cfg->m_height * 4, NULL, E_GL_STREAM_READ);
|
||||
}
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
ogrBindBuffer(E_GL_PIXEL_PACK_BUFFER, 0);
|
||||
}
|
||||
m_capture_thread = std::thread(CaptureLibrary::captureConversion, this);
|
||||
} // CaptureLibrary
|
||||
@ -52,7 +47,7 @@ CaptureLibrary::~CaptureLibrary()
|
||||
tjDestroy(m_decompress_handle);
|
||||
if (m_recorder_cfg->m_triple_buffering > 0)
|
||||
{
|
||||
glDeleteBuffers(3, m_pbo);
|
||||
ogrDeleteBuffers(3, m_pbo);
|
||||
}
|
||||
} // ~CaptureLibrary
|
||||
|
||||
@ -176,15 +171,16 @@ void CaptureLibrary::capture()
|
||||
if (use_pbo)
|
||||
{
|
||||
pbo_read = m_pbo_use % 3;
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo[pbo_read]);
|
||||
void* ptr = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
ogrBindBuffer(E_GL_PIXEL_PACK_BUFFER, m_pbo[pbo_read]);
|
||||
void* ptr = ogrMapBuffer(E_GL_PIXEL_PACK_BUFFER,
|
||||
E_GL_READ_ONLY);
|
||||
memcpy(fbi, ptr, size);
|
||||
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
ogrUnmapBuffer(E_GL_PIXEL_PACK_BUFFER);
|
||||
}
|
||||
else
|
||||
{
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
fbi);
|
||||
ogrReadPixels(0, 0, width, height, E_GL_RGBA,
|
||||
E_GL_UNSIGNED_BYTE, fbi);
|
||||
}
|
||||
addFrameBufferImage(fbi, frame_count);
|
||||
}
|
||||
@ -194,9 +190,9 @@ void CaptureLibrary::capture()
|
||||
return;
|
||||
|
||||
assert(pbo_read == -1 || pbo_use == pbo_read);
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo[pbo_use]);
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
ogrBindBuffer(E_GL_PIXEL_PACK_BUFFER, m_pbo[pbo_use]);
|
||||
ogrReadPixels(0, 0, width, height, E_GL_RGBA, E_GL_UNSIGNED_BYTE, NULL);
|
||||
ogrBindBuffer(E_GL_PIXEL_PACK_BUFFER, 0);
|
||||
} // capture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "capture_library.hpp"
|
||||
#include "recorder_private.hpp"
|
||||
|
||||
#include <turbojpeg.h>
|
||||
|
||||
namespace Recorder
|
||||
{
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,8 @@
|
||||
#ifndef HEADER_OPENGLRECORDER_H
|
||||
#define HEADER_OPENGLRECORDER_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* \mainpage libopenglrecorder
|
||||
*
|
||||
@ -160,6 +162,16 @@ struct RecorderConfig
|
||||
unsigned int m_record_jpg_quality;
|
||||
};
|
||||
|
||||
/* List of opengl function used by libopenglrecorder: */
|
||||
typedef void(*ogrFucReadPixels)(int, int, int, int, unsigned int, unsigned int,
|
||||
void*);
|
||||
typedef void(*ogrFucGenBuffers)(int, unsigned int*);
|
||||
typedef void(*ogrFucBindBuffer)(unsigned int, unsigned int);
|
||||
typedef void(*ogrFucBufferData)(unsigned int, ptrdiff_t, const void*, unsigned int);
|
||||
typedef void(*ogrFucDeleteBuffers)(int, const unsigned int*);
|
||||
typedef void*(*ogrFucMapBuffer)(unsigned int, unsigned int);
|
||||
typedef void(*ogrFucUnmapBuffer)(unsigned int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@ -214,6 +226,16 @@ void ogrRegIntCallback(CallBackType, IntCallback, void*);
|
||||
* Return 1 if recording is happening in libopenglrecorder, 0 otherwise.
|
||||
*/
|
||||
int ogrCapturing(void);
|
||||
/**
|
||||
* Set opengl function for read pixels (always required).
|
||||
*/
|
||||
void ogrRegReadPixelsFunction(ogrFucReadPixels);
|
||||
/**
|
||||
* Set opengl functions for using PBOs (required if triple buffering is used).
|
||||
*/
|
||||
void ogrRegPBOFunctions(ogrFucGenBuffers, ogrFucBindBuffer, ogrFucBufferData,
|
||||
ogrFucDeleteBuffers, ogrFucMapBuffer,
|
||||
ogrFucUnmapBuffer);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -8,6 +8,14 @@
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
// ============================================================================
|
||||
ogrFucReadPixels ogrReadPixels = NULL;
|
||||
ogrFucGenBuffers ogrGenBuffers = NULL;
|
||||
ogrFucBindBuffer ogrBindBuffer = NULL;
|
||||
ogrFucBufferData ogrBufferData = NULL;
|
||||
ogrFucDeleteBuffers ogrDeleteBuffers = NULL;
|
||||
ogrFucMapBuffer ogrMapBuffer = NULL;
|
||||
ogrFucUnmapBuffer ogrUnmapBuffer = NULL;
|
||||
// ============================================================================
|
||||
std::unique_ptr<RecorderConfig> g_recorder_config(nullptr);
|
||||
// ============================================================================
|
||||
@ -105,7 +113,8 @@ const std::string& getSavedName()
|
||||
// ----------------------------------------------------------------------------
|
||||
void ogrPrepareCapture(void)
|
||||
{
|
||||
assert(g_recorder_config.get() != nullptr && !g_saved_name.empty());
|
||||
assert(g_recorder_config.get() != nullptr && !g_saved_name.empty() &&
|
||||
ogrReadPixels != NULL);
|
||||
if (g_capture_library.get() == nullptr)
|
||||
{
|
||||
assert(g_recorder_config.get() != nullptr);
|
||||
@ -243,6 +252,35 @@ int ogrCapturing(void)
|
||||
return g_capturing.load() ? 1 : 0;
|
||||
} // ogrCapturing
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ogrRegReadPixelsFunction(ogrFucReadPixels read_pixels)
|
||||
{
|
||||
assert(read_pixels != NULL);
|
||||
ogrReadPixels = read_pixels;
|
||||
} // ogrRegReadPixelsFunction
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ogrRegPBOFunctions(ogrFucGenBuffers gen_buffers,
|
||||
ogrFucBindBuffer bind_buffer,
|
||||
ogrFucBufferData buffer_data,
|
||||
ogrFucDeleteBuffers delete_buffers,
|
||||
ogrFucMapBuffer map_buffer,
|
||||
ogrFucUnmapBuffer unmap_buffer)
|
||||
{
|
||||
assert(gen_buffers != NULL);
|
||||
ogrGenBuffers = gen_buffers;
|
||||
assert(bind_buffer != NULL);
|
||||
ogrBindBuffer = bind_buffer;
|
||||
assert(buffer_data != NULL);
|
||||
ogrBufferData = buffer_data;
|
||||
assert(delete_buffers != NULL);
|
||||
ogrDeleteBuffers = delete_buffers;
|
||||
assert(map_buffer != NULL);
|
||||
ogrMapBuffer = map_buffer;
|
||||
assert(unmap_buffer != NULL);
|
||||
ogrUnmapBuffer = unmap_buffer;
|
||||
} // ogrRegPBOFunctions
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void setCapturing(bool val)
|
||||
{
|
||||
|
@ -6,6 +6,14 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
extern ogrFucReadPixels ogrReadPixels;
|
||||
extern ogrFucGenBuffers ogrGenBuffers;
|
||||
extern ogrFucBindBuffer ogrBindBuffer;
|
||||
extern ogrFucBufferData ogrBufferData;
|
||||
extern ogrFucDeleteBuffers ogrDeleteBuffers;
|
||||
extern ogrFucMapBuffer ogrMapBuffer;
|
||||
extern ogrFucUnmapBuffer ogrUnmapBuffer;
|
||||
|
||||
RecorderConfig* getConfig();
|
||||
const std::string& getSavedName();
|
||||
void setCapturing(bool val);
|
||||
|
Loading…
Reference in New Issue
Block a user