ReactOS Fundraising Campaign 2012
 
€ 4,060 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

drawpix.c
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  7.1
00004  *
00005  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 #include "glheader.h"
00026 #include "imports.h"
00027 #include "bufferobj.h"
00028 #include "context.h"
00029 #include "drawpix.h"
00030 #include "feedback.h"
00031 #include "framebuffer.h"
00032 #include "image.h"
00033 #include "readpix.h"
00034 #include "state.h"
00035 
00036 
00037 #if _HAVE_FULL_GL
00038 
00039 /*
00040  * Execute glDrawPixels
00041  */
00042 void GLAPIENTRY
00043 _mesa_DrawPixels( GLsizei width, GLsizei height,
00044                   GLenum format, GLenum type, const GLvoid *pixels )
00045 {
00046    GET_CURRENT_CONTEXT(ctx);
00047    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
00048 
00049    if (width < 0 || height < 0) {
00050       _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" );
00051       return;
00052    }
00053 
00054    if (ctx->NewState) {
00055       _mesa_update_state(ctx);
00056    }
00057 
00058    if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
00059       _mesa_error(ctx, GL_INVALID_OPERATION,
00060                   "glDrawPixels (invalid fragment program)");
00061       return;
00062    }
00063 
00064    if (_mesa_error_check_format_type(ctx, format, type, GL_TRUE)) {
00065       /* found an error */
00066       return;
00067    }
00068 
00069    if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
00070       _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
00071                   "glDrawPixels(incomplete framebuffer)" );
00072       return;
00073    }
00074 
00075    if (!ctx->Current.RasterPosValid) {
00076       return;
00077    }
00078 
00079    if (ctx->RenderMode == GL_RENDER) {
00080       /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
00081       GLint x = IROUND(ctx->Current.RasterPos[0]);
00082       GLint y = IROUND(ctx->Current.RasterPos[1]);
00083 
00084       if (ctx->Unpack.BufferObj->Name) {
00085          /* unpack from PBO */
00086          if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
00087                                         format, type, pixels)) {
00088             _mesa_error(ctx, GL_INVALID_OPERATION,
00089                         "glDrawPixels(invalid PBO access)");
00090             return;
00091          }
00092          if (ctx->Unpack.BufferObj->Pointer) {
00093             /* buffer is mapped - that's an error */
00094             _mesa_error(ctx, GL_INVALID_OPERATION,
00095                         "glDrawPixels(PBO is mapped)");
00096             return;
00097          }
00098       }
00099 
00100       ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
00101                  &ctx->Unpack, pixels);
00102    }
00103    else if (ctx->RenderMode == GL_FEEDBACK) {
00104       /* Feedback the current raster pos info */
00105       FLUSH_CURRENT( ctx, 0 );
00106       FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN );
00107       _mesa_feedback_vertex( ctx,
00108                              ctx->Current.RasterPos,
00109                              ctx->Current.RasterColor,
00110                              ctx->Current.RasterIndex,
00111                              ctx->Current.RasterTexCoords[0] );
00112    }
00113    else {
00114       ASSERT(ctx->RenderMode == GL_SELECT);
00115       /* Do nothing.  See OpenGL Spec, Appendix B, Corollary 6. */
00116    }
00117 }
00118 
00119 
00120 void GLAPIENTRY
00121 _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
00122                   GLenum type )
00123 {
00124    GET_CURRENT_CONTEXT(ctx);
00125    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
00126 
00127    if (ctx->NewState) {
00128       _mesa_update_state(ctx);
00129    }
00130 
00131    if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
00132       _mesa_error(ctx, GL_INVALID_OPERATION,
00133                   "glCopyPixels (invalid fragment program)");
00134       return;
00135    }
00136 
00137    if (width < 0 || height < 0) {
00138       _mesa_error(ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)");
00139       return;
00140    }
00141 
00142    if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT ||
00143        ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
00144       _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
00145                   "glCopyPixels(incomplete framebuffer)" );
00146       return;
00147    }
00148 
00149    if (!_mesa_source_buffer_exists(ctx, type) ||
00150        !_mesa_dest_buffer_exists(ctx, type)) {
00151       _mesa_error(ctx, GL_INVALID_OPERATION,
00152                   "glCopyPixels(missing source or dest buffer)");
00153       return;
00154    }
00155 
00156    if (!ctx->Current.RasterPosValid) {
00157       return;
00158    }
00159 
00160    if (ctx->RenderMode == GL_RENDER) {
00161       /* Round to satisfy conformance tests (matches SGI's OpenGL) */
00162       GLint destx = IROUND(ctx->Current.RasterPos[0]);
00163       GLint desty = IROUND(ctx->Current.RasterPos[1]);
00164       ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty,
00165                   type );
00166    }
00167    else if (ctx->RenderMode == GL_FEEDBACK) {
00168       FLUSH_CURRENT( ctx, 0 );
00169       FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN );
00170       _mesa_feedback_vertex( ctx, 
00171                              ctx->Current.RasterPos,
00172                              ctx->Current.RasterColor,
00173                              ctx->Current.RasterIndex,
00174                              ctx->Current.RasterTexCoords[0] );
00175    }
00176    else {
00177       ASSERT(ctx->RenderMode == GL_SELECT);
00178       /* Do nothing.  See OpenGL Spec, Appendix B, Corollary 6. */
00179    }
00180 }
00181 
00182 #endif /* _HAVE_FULL_GL */
00183 
00184 
00185 
00186 void GLAPIENTRY
00187 _mesa_Bitmap( GLsizei width, GLsizei height,
00188               GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
00189               const GLubyte *bitmap )
00190 {
00191    GET_CURRENT_CONTEXT(ctx);
00192    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
00193 
00194    if (width < 0 || height < 0) {
00195       _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" );
00196       return;
00197    }
00198 
00199    if (!ctx->Current.RasterPosValid) {
00200       return;    /* do nothing */
00201    }
00202 
00203    if (ctx->NewState) {
00204       _mesa_update_state(ctx);
00205    }
00206 
00207    if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
00208       _mesa_error(ctx, GL_INVALID_OPERATION,
00209                   "glBitmap (invalid fragment program)");
00210       return;
00211    }
00212 
00213    if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
00214       _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
00215                   "glBitmap(incomplete framebuffer)");
00216       return;
00217    }
00218 
00219    if (ctx->RenderMode == GL_RENDER) {
00220       /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
00221       const GLfloat epsilon = (const GLfloat)0.0001;
00222       GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig);
00223       GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig);
00224 
00225       if (ctx->Unpack.BufferObj->Name) {
00226          /* unpack from PBO */
00227          if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
00228                                         GL_COLOR_INDEX, GL_BITMAP,
00229                                         (GLvoid *) bitmap)) {
00230             _mesa_error(ctx, GL_INVALID_OPERATION,
00231                         "glBitmap(invalid PBO access)");
00232             return;
00233          }
00234          if (ctx->Unpack.BufferObj->Pointer) {
00235             /* buffer is mapped - that's an error */
00236             _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
00237             return;
00238          }
00239       }
00240 
00241       ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
00242    }
00243 #if _HAVE_FULL_GL
00244    else if (ctx->RenderMode == GL_FEEDBACK) {
00245       FLUSH_CURRENT(ctx, 0);
00246       FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN );
00247       _mesa_feedback_vertex( ctx,
00248                              ctx->Current.RasterPos,
00249                              ctx->Current.RasterColor,
00250                              ctx->Current.RasterIndex, 
00251                              ctx->Current.RasterTexCoords[0] );
00252    }
00253    else {
00254       ASSERT(ctx->RenderMode == GL_SELECT);
00255       /* Do nothing.  See OpenGL Spec, Appendix B, Corollary 6. */
00256    }
00257 #endif
00258 
00259    /* update raster position */
00260    ctx->Current.RasterPos[0] += xmove;
00261    ctx->Current.RasterPos[1] += ymove;
00262 }
00263 
00264 
00265 
00266 #if 0  /* experimental */
00267 /*
00268  * Execute glDrawDepthPixelsMESA().  This function accepts both a color
00269  * image and depth (Z) image.  Rasterization produces fragments with
00270  * color and Z taken from these images.  This function is intended for
00271  * Z-compositing.  Normally, this operation requires two glDrawPixels
00272  * calls with stencil testing.
00273  */
00274 void GLAPIENTRY
00275 _mesa_DrawDepthPixelsMESA( GLsizei width, GLsizei height,
00276                            GLenum colorFormat, GLenum colorType,
00277                            const GLvoid *colors,
00278                            GLenum depthType, const GLvoid *depths )
00279 {
00280    GET_CURRENT_CONTEXT(ctx);
00281    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
00282 
00283    if (width < 0 || height < 0) {
00284       _mesa_error( ctx, GL_INVALID_VALUE,
00285                    "glDrawDepthPixelsMESA(width or height < 0" );
00286       return;
00287    }
00288 
00289    if (!ctx->Current.RasterPosValid) {
00290       return;
00291    }
00292 
00293    if (ctx->NewState) {
00294       _mesa_update_state(ctx);
00295    }
00296 
00297    if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
00298       _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
00299                   "glDrawDepthPixelsMESA(incomplete framebuffer)");
00300       return;
00301    }
00302 
00303    if (ctx->RenderMode == GL_RENDER) {
00304       /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
00305       GLint x = IROUND(ctx->Current.RasterPos[0]);
00306       GLint y = IROUND(ctx->Current.RasterPos[1]);
00307       ctx->Driver.DrawDepthPixelsMESA(ctx, x, y, width, height,
00308                                       colorFormat, colorType, colors,
00309                                       depthType, depths, &ctx->Unpack);
00310    }
00311    else if (ctx->RenderMode == GL_FEEDBACK) {
00312       /* Feedback the current raster pos info */
00313       FLUSH_CURRENT( ctx, 0 );
00314       FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN );
00315       _mesa_feedback_vertex( ctx,
00316                              ctx->Current.RasterPos,
00317                              ctx->Current.RasterColor,
00318                              ctx->Current.RasterIndex,
00319                              ctx->Current.RasterTexCoords[0] );
00320    }
00321    else {
00322       ASSERT(ctx->RenderMode == GL_SELECT);
00323       /* Do nothing.  See OpenGL Spec, Appendix B, Corollary 6. */
00324    }
00325 }
00326 
00327 #endif

Generated on Tue May 22 2012 04:24:01 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.