| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include <X11/Xlib.h>
|
| #include <X11/Xutil.h>
|
| #include <GL/glew.h>
|
| #include <GL/gl.h>
|
| #include <GL/glx.h>
|
| #include <iostream>
|
| #include <mutex>
|
|
|
| #include <cuda.h>
|
| #include <cudaGL.h>
|
|
|
| #include "../Utils/NvCodecUtils.h"
|
| #include "FramePresenter.h"
|
|
|
| #include <thread>
|
| #include <queue>
|
|
|
| #pragma once
|
|
|
|
|
|
|
| #define BUFFER_COUNT 2
|
|
|
|
|
| class FramePresenterGLX : public FramePresenter {
|
|
|
| CUgraphicsResource cuResource[BUFFER_COUNT];
|
| GLuint pbo[BUFFER_COUNT];
|
| GLuint tex[BUFFER_COUNT];
|
| GLuint program;
|
|
|
|
|
| Display *display;
|
| Window win;
|
| GLXContext ctx;
|
| GLXContext shared_ctx;
|
| Colormap cmap;
|
|
|
| CUcontext cuContext;
|
|
|
| int currentFrame;
|
| float totalWaitTime;
|
|
|
| NvThread renderingThread;
|
|
|
| public:
|
|
|
| FramePresenterGLX(int w, int h);
|
|
|
| ~FramePresenterGLX();
|
|
|
| void init(int w, int h, CUcontext context);
|
|
|
|
|
| void initWindowSystem();
|
| void initOpenGLResources();
|
| void releaseWindowSystem();
|
|
|
| bool isVendorNvidia();
|
| void Render();
|
|
|
| bool GetDeviceFrameBuffer(CUdeviceptr*, int *);
|
| void ReleaseDeviceFrameBuffer();
|
|
|
| ConcurrentQueue<int> frameFeeder;
|
|
|
| Display*& getDisplay() {
|
| return this->display;
|
| }
|
|
|
| Window& getWindow() {
|
| return this->win;
|
| }
|
|
|
| GLXContext& getContext() {
|
| return this->ctx;
|
| }
|
|
|
| GLXContext& getSharedContext() {
|
| return this->shared_ctx;
|
| }
|
|
|
| Colormap& getColorMap() {
|
| return this->cmap;
|
| }
|
|
|
| GLuint* getPBO() {
|
| return this->pbo;
|
| }
|
|
|
| GLuint* getTextures() {
|
| return this->tex;
|
| }
|
|
|
| GLuint& getProgramObject() {
|
| return this->program;
|
| }
|
|
|
| void setDimensions(unsigned int w, unsigned int h) {
|
|
|
| this->width = w;
|
| this->height = h;
|
| }
|
|
|
| int getWidth() {
|
| return this->width;
|
| }
|
|
|
| int getHeight() {
|
| return this->height;
|
| }
|
|
|
| void mapBufferObject(CUdeviceptr*);
|
| void unmapBufferObject();
|
| };
|
|
|