⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idirectfbgl_mesa.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 3 页
字号:
     }     data->surface->GetPixelFormat( data->surface, &data->format );     data->surface->GetSize( data->surface, &data->width, &data->height );     /* Configure visual. */     if (!directfbgl_init_visual( &data->visual, data->format )) {          D_ERROR( "DirectFBGL/Mesa: failed to initialize visual.\n" );          IDirectFBGL_Mesa_Destruct( thiz );          return DFB_UNSUPPORTED;     }          /* Create context. */     if (!directfbgl_create_context( &data->context,                                     &data->framebuffer,                                     &data->visual, data )) {          D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" );          IDirectFBGL_Mesa_Destruct( thiz );          return DFB_UNSUPPORTED;     }     /* Assign interface pointers. */     thiz->AddRef         = IDirectFBGL_Mesa_AddRef;     thiz->Release        = IDirectFBGL_Mesa_Release;     thiz->Lock           = IDirectFBGL_Mesa_Lock;     thiz->Unlock         = IDirectFBGL_Mesa_Unlock;     thiz->GetAttributes  = IDirectFBGL_Mesa_GetAttributes;#if DIRECTFBGL_INTERFACE_VERSION >= 1     thiz->GetProcAddress = IDirectFBGL_Mesa_GetProcAddress;#endif      return DFB_OK;}/***************************** Driver functions ******************************/static const GLubyte*dfbGetString( GLcontext *ctx, GLenum pname ){     return NULL;}static voiddfbUpdateState( GLcontext *ctx, GLuint new_state ){     _swrast_InvalidateState( ctx, new_state );     _swsetup_InvalidateState( ctx, new_state );     _vbo_InvalidateState( ctx, new_state );     _tnl_InvalidateState( ctx, new_state );}static voiddfbGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height ){     GLcontext        *ctx  = _mesa_get_current_context();     IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;     *width  = (GLuint) data->width;     *height = (GLuint) data->height;}/** * We only implement this function as a mechanism to check if the * framebuffer size has changed (and update corresponding state). */static voiddfbSetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ){     /* Nothing to do (the surface can't be resized while it's locked). */     return;}static voiddfbClear( GLcontext *ctx, GLbitfield mask ){     IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; #define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \                         BUFFER_BIT_BACK_LEFT  | BUFFER_BIT_BACK_RIGHT  )     if (mask & BUFFER_BIT_MASK  &&         ctx->Color.ColorMask[0] &&         ctx->Color.ColorMask[1] &&         ctx->Color.ColorMask[2] &&         ctx->Color.ColorMask[3])     {          DFBRegion clip;          GLubyte   a, r, g, b;                    UNCLAMPED_FLOAT_TO_UBYTE( a, ctx->Color.ClearColor[ACOMP] );          UNCLAMPED_FLOAT_TO_UBYTE( r, ctx->Color.ClearColor[RCOMP] );          UNCLAMPED_FLOAT_TO_UBYTE( g, ctx->Color.ClearColor[GCOMP] );          UNCLAMPED_FLOAT_TO_UBYTE( b, ctx->Color.ClearColor[BCOMP] );          clip.x1 = ctx->DrawBuffer->_Xmin;          clip.y1 = ctx->DrawBuffer->_Ymin;          clip.x2 = ctx->DrawBuffer->_Xmax - 1;          clip.y2 = ctx->DrawBuffer->_Ymax - 1;          data->surface->SetClip( data->surface, &clip );                    data->surface->Unlock( data->surface );                    data->surface->Clear( data->surface, r, g, b, a );                    data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE,                               (void*)&data->video.start, &data->video.pitch );          data->video.end = data->video.start + (data->height-1) * data->video.pitch;          data->render.Data = data->video.start;                    mask &= ~BUFFER_BIT_MASK;     }#undef BUFFER_BIT_MASK          if (mask)          _swrast_Clear( ctx, mask );}/************************ RenderBuffer functions *****************************/static voiddfbDeleteRenderbuffer( struct gl_renderbuffer *render ){     return;}static GLbooleandfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,                        GLenum internalFormat, GLuint width, GLuint height ){     return GL_TRUE;}/***************************** Span functions ********************************//* RGB332 */#define NAME(PREFIX) PREFIX##_RGB332#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLubyte *P = data->video.end - (Y) * data->video.pitch + (X);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[RCOMP]) & 0xe0)     ) | \          (((S[GCOMP]) & 0xe0) >> 3) | \          (((S[BCOMP])       ) >> 6) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0xe0)     ); \   D[GCOMP] = ((*P & 0x1c) << 3); \   D[BCOMP] = ((*P & 0x03) << 6); \   D[ACOMP] = 0xff#include "swrast/s_spantemp.h"/* ARGB4444 */#define NAME(PREFIX) PREFIX##_ARGB4444#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL_RGB(P, X, Y, S) \   *P = ( 0xf000                     | \          (((S[RCOMP]) & 0xf0) << 4) | \          (((S[GCOMP]) & 0xf0)     ) | \          (((S[BCOMP]) & 0xf0) >> 4) )#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[ACOMP]) & 0xf0) << 8) | \          (((S[RCOMP]) & 0xf0) << 4) | \          (((S[GCOMP]) & 0xf0)     ) | \          (((S[BCOMP]) & 0xf0) >> 4) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >>  8); \   D[GCOMP] = ((*P & 0x00f0)     ) | ((*P & 0x00f0) >>  4); \   D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f)      ); \   D[ACOMP] = ((*P & 0xf000) >> 8) | ((*P & 0xf000) >> 12)#include "swrast/s_spantemp.h"/* RGB444 */#define NAME(PREFIX) PREFIX##_RGB444#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[RCOMP]) & 0xf0) << 4) | \          (((S[GCOMP]) & 0xf0)     ) | \          (((S[BCOMP]) & 0xf0) >> 4) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \   D[GCOMP] = ((*P & 0x00f0)     ) | ((*P & 0x00f0) >> 4); \   D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f)     ); \   D[ACOMP] = 0xff#include "swrast/s_spantemp.h"/* ARGB2554 */#define NAME(PREFIX) PREFIX##_ARGB2554#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL_RGB(P, X, Y, S) \   *P = ( 0xc000                     | \          (((S[RCOMP]) & 0xf8) << 6) | \          (((S[GCOMP]) & 0xf8) << 1) | \          (((S[BCOMP]) & 0xf0) >> 4) )#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[ACOMP]) & 0xc0) << 8) | \          (((S[RCOMP]) & 0xf8) << 6) | \          (((S[GCOMP]) & 0xf8) << 1) | \          (((S[BCOMP]) & 0xf0) >> 4) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0x3e00) >>  9); \   D[GCOMP] = ((*P & 0x01f0) >>  4); \   D[BCOMP] = ((*P & 0x000f) <<  4); \   D[ACOMP] = ((*P & 0xc000) >> 14)#include "swrast/s_spantemp.h"   /* ARGB1555 */#define NAME(PREFIX) PREFIX##_ARGB1555#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL_RGB(P, X, Y, S) \   *P = ( 0x8000                      | \          (((S[RCOMP]) & 0xf8) <<  7) | \          (((S[GCOMP]) & 0xf8) <<  2) | \          (((S[BCOMP])       ) >>  3) )#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[ACOMP]) & 0x80) << 16) | \          (((S[RCOMP]) & 0xf8) <<  7) | \          (((S[GCOMP]) & 0xf8) <<  2) | \          (((S[BCOMP])       ) >>  3) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \   D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >>  7); \   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) <<  2); \   D[ACOMP] = ((*P & 0x8000) ? 0xff : 0)#include "swrast/s_spantemp.h"/* RGB555 */#define NAME(PREFIX) PREFIX##_RGB555#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[RCOMP]) & 0xf8) <<  7) | \          (((S[GCOMP]) & 0xf8) <<  2) | \          (((S[BCOMP])       ) >>  3) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \   D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >>  7); \   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) <<  2); \   D[ACOMP] = 0xff#include "swrast/s_spantemp.h"/* RGB16 */#define NAME(PREFIX) PREFIX##_RGB16#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL(P, X, Y, S) \   *P = ( (((S[RCOMP]) & 0xf8) << 8) | \          (((S[GCOMP]) & 0xfc) << 3) | \          (((S[BCOMP])       ) >> 3) )#define FETCH_PIXEL(D, P) \   D[RCOMP] = ((*P & 0xf800) >> 8) | ((*P & 0xf800) >> 13); \   D[GCOMP] = ((*P & 0x07e0) >> 3) | ((*P & 0x07e0) >>  9); \   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) >>  2); \   D[ACOMP] = 0xff#include "swrast/s_spantemp.h"/* RGB24 */#define NAME(PREFIX) PREFIX##_RGB24#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLubyte *P = data->video.end - (Y) * data->video.pitch + (X) * 3;#define INC_PIXEL_PTR(P) P += 3#define STORE_PIXEL(P, X, Y, S) \   P[0] = S[BCOMP];  P[1] = S[GCOMP];  P[2] = S[BCOMP]#define FETCH_PIXEL(D, P) \   D[RCOMP] = P[2];  D[GCOMP] = P[1];  D[BCOMP] = P[0]; D[ACOMP] = 0xff#include "swrast/s_spantemp.h"/* RGB32 */#define NAME(PREFIX) PREFIX##_RGB32#define FORMAT GL_RGBA8#define RB_TYPE GLubyte#define SPAN_VARS \   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;#define INIT_PIXEL_PTR(P, X, Y) \   GLuint *P = (GLuint*) (data->video.end - (Y) * data->video.pitch + (X) * 4);#define INC_PIXEL_PTR(P) P += 1#define STORE_PIXEL(P, X, Y, S) \   *P = ( ((S[RCOMP]) << 16) | \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -