0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 20:03:10 +02:00

use GenBuffers to get a buffer number instead of hardcoding 1.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16234 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2005-08-16 17:57:53 +00:00
parent 1d720784bd
commit 44ec3f7566
3 changed files with 17 additions and 3 deletions

View File

@ -2,6 +2,8 @@
#include <string.h> #include <string.h>
#include "gl_common.h" #include "gl_common.h"
void (APIENTRY *GenBuffers)(GLsizei, GLuint *);
void (APIENTRY *DeleteBuffers)(GLsizei, const GLuint *);
void (APIENTRY *BindBuffer)(GLenum, GLuint); void (APIENTRY *BindBuffer)(GLenum, GLuint);
GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum); GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum);
GLboolean (APIENTRY *UnmapBuffer)(GLenum); GLboolean (APIENTRY *UnmapBuffer)(GLenum);
@ -203,6 +205,12 @@ static void *(*getProcAddress)(const GLubyte *procName) = NULL;
static void getFunctions() { static void getFunctions() {
if (!getProcAddress) if (!getProcAddress)
getProcAddress = setNull; getProcAddress = setNull;
GenBuffers = getProcAddress("glGenBuffers");
if (!GenBuffers)
GenBuffers = getProcAddress("glGenBuffersARB");
DeleteBuffers = getProcAddress("glDeleteBuffers");
if (!DeleteBuffers)
DeleteBuffers = getProcAddress("glDeleteBuffersARB");
BindBuffer = getProcAddress("glBindBuffer"); BindBuffer = getProcAddress("glBindBuffer");
if (!BindBuffer) if (!BindBuffer)
BindBuffer = getProcAddress("glBindBufferARB"); BindBuffer = getProcAddress("glBindBufferARB");

View File

@ -85,6 +85,8 @@ int setGlWindow(XVisualInfo **vinfo, GLXContext *context, Window win);
void releaseGlContext(XVisualInfo **vinfo, GLXContext *context); void releaseGlContext(XVisualInfo **vinfo, GLXContext *context);
#endif #endif
extern void (APIENTRY *GenBuffers)(GLsizei, GLuint *);
extern void (APIENTRY *DeleteBuffers)(GLsizei, const GLuint *);
extern void (APIENTRY *BindBuffer)(GLenum, GLuint); extern void (APIENTRY *BindBuffer)(GLenum, GLuint);
extern GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum); extern GLvoid* (APIENTRY *MapBuffer)(GLenum, GLenum);
extern GLboolean (APIENTRY *UnmapBuffer)(GLenum); extern GLboolean (APIENTRY *UnmapBuffer)(GLenum);

View File

@ -65,6 +65,7 @@ static GLenum gl_target;
static GLenum gl_texfmt; static GLenum gl_texfmt;
static GLenum gl_format; static GLenum gl_format;
static GLenum gl_type; static GLenum gl_type;
static GLint gl_buffer;
static int gl_buffersize; static int gl_buffersize;
static int int_pause; static int int_pause;
@ -147,6 +148,7 @@ static int initGl(uint32_t d_width, uint32_t d_height) {
glClearColor( 0.0f,0.0f,0.0f,0.0f ); glClearColor( 0.0f,0.0f,0.0f,0.0f );
glClear( GL_COLOR_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT );
gl_buffer = 0;
gl_buffersize = 0; gl_buffersize = 0;
err_shown = 0; err_shown = 0;
return 1; return 1;
@ -419,7 +421,7 @@ static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
} }
static uint32_t get_image(mp_image_t *mpi) { static uint32_t get_image(mp_image_t *mpi) {
if (!BindBuffer || !BufferData || !MapBuffer) { if (!GenBuffers || !BindBuffer || !BufferData || !MapBuffer) {
if (!err_shown) if (!err_shown)
mp_msg(MSGT_VO, MSGL_ERR, "[gl] extensions missing for dr\n" mp_msg(MSGT_VO, MSGL_ERR, "[gl] extensions missing for dr\n"
"Expect a _major_ speed penalty\n"); "Expect a _major_ speed penalty\n");
@ -429,7 +431,9 @@ static uint32_t get_image(mp_image_t *mpi) {
if (mpi->flags & MP_IMGFLAG_READABLE) return VO_FALSE; if (mpi->flags & MP_IMGFLAG_READABLE) return VO_FALSE;
if (mpi->type == MP_IMGTYPE_IP || mpi->type == MP_IMGTYPE_IPB) if (mpi->type == MP_IMGTYPE_IP || mpi->type == MP_IMGTYPE_IPB)
return VO_FALSE; // we can not provide readable buffers return VO_FALSE; // we can not provide readable buffers
BindBuffer(GL_PIXEL_UNPACK_BUFFER, 1); if (!gl_buffer)
GenBuffers(1, &gl_buffer);
BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer);
mpi->stride[0] = mpi->width * mpi->bpp / 8; mpi->stride[0] = mpi->width * mpi->bpp / 8;
if (mpi->stride[0] * mpi->h > gl_buffersize) { if (mpi->stride[0] * mpi->h > gl_buffersize) {
BufferData(GL_PIXEL_UNPACK_BUFFER, mpi->stride[0] * mpi->h, BufferData(GL_PIXEL_UNPACK_BUFFER, mpi->stride[0] * mpi->h,
@ -457,7 +461,7 @@ static uint32_t draw_image(mp_image_t *mpi) {
return VO_TRUE; return VO_TRUE;
if (mpi->flags & MP_IMGFLAG_DIRECT) { if (mpi->flags & MP_IMGFLAG_DIRECT) {
data = NULL; data = NULL;
BindBuffer(GL_PIXEL_UNPACK_BUFFER, 1); BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer);
UnmapBuffer(GL_PIXEL_UNPACK_BUFFER); UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
slice = 0; // always "upload" full texture slice = 0; // always "upload" full texture
} }