📄 wmesa.c
字号:
LPBYTE lpb; (void) ctx; y=FLIP(y); lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); if (mask) { for (i=0; i<n; i++) if (mask[i]) { lpb[3*i] = rgba[i][BCOMP]; lpb[3*i+1] = rgba[i][GCOMP]; lpb[3*i+2] = rgba[i][RCOMP]; } } else { for (i=0; i<n; i++) { *lpb++ = rgba[i][BCOMP]; *lpb++ = rgba[i][GCOMP]; *lpb++ = rgba[i][RCOMP]; } }}/* Write a horizontal span of RGB color pixels with a boolean mask. */static void write_rgb_span_24(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, const GLubyte rgb[][3], const GLubyte mask[] ){ WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); GLuint i; LPBYTE lpb; (void) ctx; y=FLIP(y); lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); if (mask) { for (i=0; i<n; i++) if (mask[i]) { lpb[3*i] = rgb[i][BCOMP]; lpb[3*i+1] = rgb[i][GCOMP]; lpb[3*i+2] = rgb[i][RCOMP]; } } else { for (i=0; i<n; i++) { *lpb++ = rgb[i][BCOMP]; *lpb++ = rgb[i][GCOMP]; *lpb++ = rgb[i][RCOMP]; } }}/* * Write a horizontal span of pixels with a boolean mask. The current color * is used for all pixels. */static void write_mono_rgba_span_24(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, const GLchan color[4], const GLubyte mask[]){ LPBYTE lpb; GLuint i; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); y=FLIP(y); if (mask) { for (i=0; i<n; i++) if (mask[i]) { lpb[3*i] = color[BCOMP]; lpb[3*i+1] = color[GCOMP]; lpb[3*i+2] = color[RCOMP]; } } else for (i=0; i<n; i++) { *lpb++ = color[BCOMP]; *lpb++ = color[GCOMP]; *lpb++ = color[RCOMP]; }}/* Write an array of RGBA pixels with a boolean mask. */static void write_rgba_pixels_24(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[]){ GLuint i; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); for (i=0; i<n; i++) if (mask[i]) WMSETPIXEL24(pwfb, FLIP(y[i]), x[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);}/* * Write an array of pixels with a boolean mask. The current color * is used for all pixels. */static void write_mono_rgba_pixels_24(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[], const GLchan color[4], const GLubyte mask[]){ GLuint i; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); for (i=0; i<n; i++) if (mask[i]) WMSETPIXEL24(pwfb, FLIP(y[i]),x[i],color[RCOMP], color[GCOMP], color[BCOMP]);}/* Read a horizontal span of color pixels. */static void read_rgba_span_24(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ){ GLuint i; LPBYTE lpb; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); y = FLIP(y); lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); for (i=0; i<n; i++) { rgba[i][RCOMP] = lpb[3*i+2]; rgba[i][GCOMP] = lpb[3*i+1]; rgba[i][BCOMP] = lpb[3*i]; rgba[i][ACOMP] = 255; }}/* Read an array of color pixels. */static void read_rgba_pixels_24(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4]){ GLuint i; LPBYTE lpb; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); for (i=0; i<n; i++) { GLint y2 = FLIP(y[i]); lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y2)) + (3 * x[i]); rgba[i][RCOMP] = lpb[3*i+2]; rgba[i][GCOMP] = lpb[3*i+1]; rgba[i][BCOMP] = lpb[3*i]; rgba[i][ACOMP] = 255; }}/*********************************************************************//* DOUBLE BUFFER 16-bit */#define WMSETPIXEL16(pwc, y, x, r, g, b) { \LPWORD lpw = ((LPWORD)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (x)); \*lpw = BGR16((r),(g),(b)); }/* Write a horizontal span of RGBA color pixels with a boolean mask. */static void write_rgba_span_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] ){ WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); GLuint i; LPWORD lpw; (void) ctx; y=FLIP(y); lpw = ((LPWORD)(pwfb->pbPixels + pwfb->ScanWidth * y)) + x; if (mask) { for (i=0; i<n; i++) if (mask[i]) lpw[i] = BGR16(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); } else { for (i=0; i<n; i++) *lpw++ = BGR16(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); }}/* Write a horizontal span of RGB color pixels with a boolean mask. */static void write_rgb_span_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, const GLubyte rgb[][3], const GLubyte mask[] ){ WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); GLuint i; LPWORD lpw; (void) ctx; y=FLIP(y); lpw = ((LPWORD)(pwfb->pbPixels + pwfb->ScanWidth * y)) + x; if (mask) { for (i=0; i<n; i++) if (mask[i]) lpw[i] = BGR16(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]); } else { for (i=0; i<n; i++) *lpw++ = BGR16(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]); }}/* * Write a horizontal span of pixels with a boolean mask. The current color * is used for all pixels. */static void write_mono_rgba_span_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, const GLchan color[4], const GLubyte mask[]){ LPWORD lpw; WORD pixel; GLuint i; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); (void) ctx; lpw = ((LPWORD)(pwfb->pbPixels + pwfb->ScanWidth * y)) + x; y=FLIP(y); pixel = BGR16(color[RCOMP], color[GCOMP], color[BCOMP]); if (mask) { for (i=0; i<n; i++) if (mask[i]) lpw[i] = pixel; } else for (i=0; i<n; i++) *lpw++ = pixel;}/* Write an array of RGBA pixels with a boolean mask. */static void write_rgba_pixels_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[]){ GLuint i; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); (void) ctx; for (i=0; i<n; i++) if (mask[i]) WMSETPIXEL16(pwfb, FLIP(y[i]), x[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);}/* * Write an array of pixels with a boolean mask. The current color * is used for all pixels. */static void write_mono_rgba_pixels_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[], const GLchan color[4], const GLubyte mask[]){ GLuint i; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); (void) ctx; for (i=0; i<n; i++) if (mask[i]) WMSETPIXEL16(pwfb, FLIP(y[i]),x[i],color[RCOMP], color[GCOMP], color[BCOMP]);}/* Read a horizontal span of color pixels. */static void read_rgba_span_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ){ GLuint i, pixel; LPWORD lpw; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); y = FLIP(y); lpw = ((LPWORD)(pwfb->pbPixels + pwfb->ScanWidth * y)) + x; for (i=0; i<n; i++) { pixel = lpw[i]; /* Windows uses 5,5,5 for 16-bit */ rgba[i][RCOMP] = (pixel & 0x7c00) >> 7; rgba[i][GCOMP] = (pixel & 0x03e0) >> 2; rgba[i][BCOMP] = (pixel & 0x001f) << 3; rgba[i][ACOMP] = 255; }}/* Read an array of color pixels. */static void read_rgba_pixels_16(const GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4]){ GLuint i, pixel; LPWORD lpw; WMesaContext pwc = wmesa_context(ctx); WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); for (i=0; i<n; i++) { GLint y2 = FLIP(y[i]); lpw = ((LPWORD)(pwfb->pbPixels + pwfb->ScanWidth * y2)) + x[i]; pixel = *lpw; /* Windows uses 5,5,5 for 16-bit */ rgba[i][RCOMP] = (pixel & 0x7c00) >> 7; rgba[i][GCOMP] = (pixel & 0x03e0) >> 2; rgba[i][BCOMP] = (pixel & 0x001f) << 3; rgba[i][ACOMP] = 255; }}/**********************************************************************//***** BUFFER Functions *****//**********************************************************************/static voidwmesa_delete_renderbuffer(struct gl_renderbuffer *rb){ _mesa_free(rb);}/** * This is called by Mesa whenever it determines that the window size * has changed. Do whatever's needed to cope with that. */static GLbooleanwmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height){ rb->Width = width; rb->Height = height; return GL_TRUE;}/** * Plug in the Get/PutRow/Values functions for a renderbuffer depending * on if we're drawing to the front or back color buffer. */void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, BYTE cColorBits, int double_buffer){ if (double_buffer) { /* back buffer */ /* Picking the correct span functions is important because * the DIB was allocated with the indicated depth. */ switch(pixelformat) { case PF_5R6G5B: rb->PutRow = write_rgba_span_16; rb->PutRowRGB = write_rgb_span_16; rb->PutMonoRow = write_mono_rgba_span_16; rb->PutValues = write_rgba_pixels_16; rb->PutMonoValues = write_mono_rgba_pixels_16; rb->GetRow = read_rgba_span_16; rb->GetValues = read_rgba_pixels_16; rb->RedBits = 5; rb->GreenBits = 6; rb->BlueBits = 5; break; case PF_8R8G8B: if (cColorBits == 24) { rb->PutRow = write_rgba_span_24; rb->PutRowRGB = write_rgb_span_24; rb->PutMonoRow = write_mono_rgba_span_24; rb->PutValues = write_rgba_pixels_24; rb->PutMonoValues = write_mono_rgba_pixels_24; rb->GetRow = read_rgba_span_24; rb->GetValues = read_rgba_pixels_24; rb->RedBits = 8; rb->GreenBits = 8; rb->BlueBits = 8; } else { rb->PutRow = write_rgba_span_32; rb->PutRowRGB = write_rgb_span_32; rb->PutMonoRow = write_mono_rgba_span_32; rb->PutValues = write_rgba_pixels_32; rb->PutMonoValues = write_mono_rgba_pixels_32; rb->GetRow = read_rgba_span_32; rb->GetValues = read_rgba_pixels_32; rb->RedBits = 8; rb->GreenBits = 8; rb->BlueBits = 8; } break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -