-
Notifications
You must be signed in to change notification settings - Fork 8
/
glBindBufferARB.c
54 lines (39 loc) · 1 KB
/
glBindBufferARB.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "pspgl_internal.h"
#include "pspgl_buffers.h"
void glBindBufferARB(GLenum target, GLuint id)
{
struct hashtable *hash = &pspgl_curctx->shared->buffers;
struct pspgl_bufferobj *bufp, *prev, **prevp;
prevp = __pspgl_bufferobj_for_target(target);
if (prevp == NULL)
return;
prev = *prevp;
bufp = NULL;
if (id != 0) {
bufp = __pspgl_hash_lookup(hash, id);
if (bufp == NULL) {
bufp = __pspgl_bufferobj_new(NULL);
if (unlikely(bufp == NULL))
goto out_error;
__pspgl_hash_insert(hash, id, bufp);
}
}
if (bufp == prev)
return;
if (prev) {
if (prev->mapped && prev->data)
__pspgl_buffer_unmap(prev->data, prev->access);
psp_log("unbinding %p from target %x\n", prev, target);
prev->mapped = GL_FALSE;
__pspgl_bufferobj_free(prev);
}
psp_log("binding %p to target %x\n", bufp, target);
*prevp = bufp;
if (bufp)
bufp->refcount++;
return;
out_error:
GLERROR(GL_OUT_OF_MEMORY);
}
void glBindBuffer (GLenum, GLuint)
__attribute__((alias("glBindBufferARB")));