|
|
@ -11,6 +11,7 @@ struct swblit_s |
|
|
|
void (*pUnlockBuffer)( void ); |
|
|
|
void (*pUnlockBuffer)( void ); |
|
|
|
qboolean(*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b ); |
|
|
|
qboolean(*pCreateBuffer)( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b ); |
|
|
|
uint rotate; |
|
|
|
uint rotate; |
|
|
|
|
|
|
|
qboolean gl1; |
|
|
|
} swblit; |
|
|
|
} swblit; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -92,8 +93,18 @@ void GAME_EXPORT GL_SetupAttributes( int safegl ) |
|
|
|
// untill we have any blitter in ref api, setup GL
|
|
|
|
// untill we have any blitter in ref api, setup GL
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_ES ); |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_PROFILE_MASK, REF_GL_CONTEXT_PROFILE_ES ); |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_EGL, 1 ); |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_EGL, 1 ); |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 3 ); |
|
|
|
// safegl=1;
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 0 ); |
|
|
|
if( safegl ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 1 ); |
|
|
|
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 1 ); |
|
|
|
|
|
|
|
swblit.gl1 = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MAJOR_VERSION, 3 ); |
|
|
|
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_CONTEXT_MINOR_VERSION, 0 ); |
|
|
|
|
|
|
|
} |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_DOUBLEBUFFER, 1 ); |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_DOUBLEBUFFER, 1 ); |
|
|
|
|
|
|
|
|
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 5 ); |
|
|
|
gEngfuncs.GL_SetAttribute( REF_GL_RED_SIZE, 5 ); |
|
|
@ -293,16 +304,39 @@ static qboolean R_CreateBuffer_GLES1( int width, int height, uint *stride, uint |
|
|
|
|
|
|
|
|
|
|
|
static void *R_Lock_GLES3( void ) |
|
|
|
static void *R_Lock_GLES3( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
void *buf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !vid.width || !vid.height ) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( glbuf ) |
|
|
|
|
|
|
|
return glbuf; |
|
|
|
|
|
|
|
|
|
|
|
pglBufferData( GL_PIXEL_UNPACK_BUFFER, vid.width * vid.height * 2, 0, GL_STREAM_DRAW_ARB ); |
|
|
|
pglBufferData( GL_PIXEL_UNPACK_BUFFER, vid.width * vid.height * 2, 0, GL_STREAM_DRAW_ARB ); |
|
|
|
return pglMapBuffer( GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY_ARB ); |
|
|
|
buf = pglMapBuffer( GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY_ARB ); |
|
|
|
|
|
|
|
if( !buf ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pglUnmapBuffer( GL_PIXEL_UNPACK_BUFFER ); |
|
|
|
|
|
|
|
pglBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 ); |
|
|
|
|
|
|
|
glbuf = Mem_Malloc( r_temppool, vid.width*vid.height*2 ); |
|
|
|
|
|
|
|
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf ); |
|
|
|
|
|
|
|
return glbuf; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return buf; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void R_Unlock_GLES3( void ) |
|
|
|
static void R_Unlock_GLES3( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gEngfuncs.GL_SwapBuffers(); |
|
|
|
gEngfuncs.GL_SwapBuffers(); |
|
|
|
pglUnmapBuffer( GL_PIXEL_UNPACK_BUFFER ); |
|
|
|
if( glbuf ) |
|
|
|
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0 ); |
|
|
|
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, glbuf ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pglUnmapBuffer( GL_PIXEL_UNPACK_BUFFER ); |
|
|
|
|
|
|
|
pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, vid.width, vid.height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0 ); |
|
|
|
|
|
|
|
} |
|
|
|
//pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
|
|
|
|
//pglDrawArrays( GL_TRIANGLE_FAN, 0,4 );
|
|
|
|
pglBlitFramebuffer( 0, vid.height, vid.width, 0, 0, 0, vid.width, vid.height, GL_COLOR_BUFFER_BIT, GL_NEAREST ); |
|
|
|
pglBlitFramebuffer( 0, vid.height, vid.width, 0, 0, 0, vid.width, vid.height, GL_COLOR_BUFFER_BIT, GL_NEAREST ); |
|
|
|
} |
|
|
|
} |
|
|
@ -591,7 +625,13 @@ void R_InitBlit( qboolean glblit ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
R_BuildBlendMaps(); |
|
|
|
R_BuildBlendMaps(); |
|
|
|
|
|
|
|
|
|
|
|
if( glblit ) |
|
|
|
if( glblit && swblit.gl1 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
swblit.pLockBuffer = R_Lock_GL1; |
|
|
|
|
|
|
|
swblit.pUnlockBuffer = R_Unlock_GLES1; |
|
|
|
|
|
|
|
swblit.pCreateBuffer = R_CreateBuffer_GLES1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if( glblit ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
swblit.pLockBuffer = R_Lock_GLES3; |
|
|
|
swblit.pLockBuffer = R_Lock_GLES3; |
|
|
|
swblit.pUnlockBuffer = R_Unlock_GLES3; |
|
|
|
swblit.pUnlockBuffer = R_Unlock_GLES3; |
|
|
|