This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheglMakeCurrent.c
70 lines (57 loc) · 1.67 KB
/
eglMakeCurrent.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdlib.h>
#include "pspgl_internal.h"
#include "pspgl_dlist.h"
/**
* mask out trigger action registers, or the GE might run amok on context changes...
* This bitfield is generated from ge_init_state[] with all non-action fields enabled.
*/
uint32_t __pspgl_context_register[256 / 32];
EGLBoolean eglMakeCurrent (EGLDisplay dpy,
EGLSurface drawsurf, EGLSurface readsurf,
EGLContext ctx)
{
struct pspgl_context *c = (struct pspgl_context *) ctx;
struct pspgl_surface *read = (struct pspgl_surface *)readsurf;
struct pspgl_surface *draw = (struct pspgl_surface *)drawsurf;
int changed;
changed = (c != pspgl_curctx);
if (c) {
c->refcount++;
if (draw)
draw->refcount++;
if (read)
read->refcount++;
if (c->draw)
eglDestroySurface(dpy, c->draw);
if (c->read)
eglDestroySurface(dpy, c->read);
c->draw = draw;
c->read = read;
}
if (pspgl_curctx) {
if (changed)
glFinish();
eglDestroyContext(dpy, pspgl_curctx);
}
pspgl_curctx = c;
if (c == NULL)
return EGL_TRUE;
if (!c->initialized) {
__pspgl_dlist_init();
__pspgl_ge_init(c);
c->initialized = 1;
}
if (changed) {
/* mark all registers and matrices as dirty, we need to
rewrite them at init and after context restore... */
for (int i=0; i<sizeof(c->hw.ge_reg_touched)/sizeof(c->hw.ge_reg_touched[0]); i++)
c->hw.ge_reg_touched[i] |= __pspgl_context_register[i];
c->projection_stack.flags |= MF_DIRTY;
c->modelview_stack.flags |= MF_DIRTY;
c->texture_stack.flags |= MF_DIRTY;
c->view_stack.flags |= MF_DIRTY;
for(int i = 0; i < NBONES; i++)
c->bone_stacks[i].flags |= MF_DIRTY;
}
return __pspgl_vidmem_setup_write_and_display_buffer(c->draw);
}