ReactOS  0.4.14-dev-358-gbef841c
drawpix.c File Reference
#include <stdlib.h>
#include <string.h>
#include "context.h"
#include "drawpix.h"
#include "feedback.h"
#include "dlist.h"
#include "macros.h"
#include "pixel.h"
#include "span.h"
#include "stencil.h"
#include "types.h"
Include dependency graph for drawpix.c:

Go to the source code of this file.

Functions

static void draw_index_pixels (GLcontext *ctx, GLsizei width, GLsizei height, GLenum type, const GLvoid *pixels)
 
static void draw_stencil_pixels (GLcontext *ctx, GLsizei width, GLsizei height, GLenum type, const GLvoid *pixels)
 
static void draw_depth_pixels (GLcontext *ctx, GLsizei width, GLsizei height, GLenum type, const GLvoid *pixels)
 
static void draw_color_pixels (GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
 
static GLboolean quickdraw_rgb (GLcontext *ctx, GLsizei width, GLsizei height, const void *pixels)
 
static void drawpixels (GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
 
void gl_DrawPixels (GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
 

Function Documentation

◆ draw_color_pixels()

static void draw_color_pixels ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)
static

Definition at line 524 of file drawpix.c.

526 {
527  GLuint i, j;
528  GLint x, y, desty;
529  GLdepth zspan[MAX_WIDTH];
530  GLboolean scale_or_bias, quick_draw;
531  GLboolean zoom;
532 
533  zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
534 
535  /* Position, depth of pixels */
536  x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
537  y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
538  desty = y;
539  if (ctx->Depth.Test)
540  {
541  /* fill in array of z values */
542  GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
543  for (i = 0; i < width; i++)
544  {
545  zspan[i] = z;
546  }
547  }
548 
549  /* Determine if scaling and/or biasing is needed */
550  if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F
551  || ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F
552  || ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F
553  || ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F)
554  {
555  scale_or_bias = GL_TRUE;
556  }
557  else
558  {
559  scale_or_bias = GL_FALSE;
560  }
561 
562  /* Determine if we can directly call the device driver function */
563  if (ctx->RasterMask == 0 && !zoom && x >= 0 && y >= 0
564  && x + width <= ctx->Buffer->Width
565  && y + height <= ctx->Buffer->Height)
566  {
567  quick_draw = GL_TRUE;
568  }
569  else
570  {
571  quick_draw = GL_FALSE;
572  }
573 
574  /* First check for common cases */
575  if (type == GL_UNSIGNED_BYTE
576  && (format == GL_RGB || format == GL_LUMINANCE || format == GL_BGR_EXT)
577  && !ctx->Pixel.MapColorFlag
578  && !scale_or_bias && ctx->Visual->EightBitColor)
579  {
581  GLubyte *src = (GLubyte *) pixels;
582  /* constant alpha */
583  MEMSET(alpha, (GLint ) ctx->Visual->AlphaScale, width);
584  if (format == GL_RGB)
585  {
586  /* 8-bit RGB pixels */
590  for (i = 0; i < height; i++, y++)
591  {
592  for (j = 0; j < width; j++)
593  {
594  red[j] = *src++;
595  green[j] = *src++;
596  blue[j] = *src++;
597  }
598  if (quick_draw)
599  {
600  (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, red, green,
601  blue, alpha, NULL);
602  }
603  else if (zoom)
604  {
605  gl_write_zoomed_color_span(ctx, (GLuint) width, x, y, zspan,
606  red, green, blue, alpha, desty);
607  }
608  else
609  {
610  gl_write_color_span(ctx, (GLuint) width, x, y, zspan, red,
612  }
613  }
614  UNDEFARRAY( red );
615  UNDEFARRAY( green );
616  UNDEFARRAY( blue );
617  }
618  else if (format == GL_BGR_EXT)
619  {
620  /* 8-bit BGR pixels */
624  for (i = 0; i < height; i++, y++)
625  {
626  for (j = 0; j < width; j++)
627  {
628  blue[j] = *src++;
629  green[j] = *src++;
630  red[j] = *src++;
631  }
632  if (quick_draw)
633  {
634  (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, red, green,
635  blue, alpha, NULL);
636  }
637  else if (zoom)
638  {
639  gl_write_zoomed_color_span(ctx, (GLuint) width, x, y, zspan,
640  red, green, blue, alpha, desty);
641  }
642  else
643  {
644  gl_write_color_span(ctx, (GLuint) width, x, y, zspan, red,
646  }
647  }
648  UNDEFARRAY( red );
649  UNDEFARRAY( green );
650  UNDEFARRAY( blue );
651  }
652  else
653  {
654  /* 8-bit Luminance pixels */
655  GLubyte *lum = (GLubyte *) pixels;
656  for (i = 0; i < height; i++, y++, lum += width)
657  {
658  if (quick_draw)
659  {
660  (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, lum, lum,
661  lum, alpha, NULL);
662  }
663  else if (zoom)
664  {
665  gl_write_zoomed_color_span(ctx, (GLuint) width, x, y, zspan,
666  lum, lum, lum, alpha, desty);
667  }
668  else
669  {
670  gl_write_color_span(ctx, (GLuint) width, x, y, zspan, lum,
671  lum, lum, alpha, GL_BITMAP);
672  }
673  }
674  }
675  UNDEFARRAY( alpha );
676  }
677  else
678  {
679  /* General solution */
680  GLboolean r_flag, g_flag, b_flag, a_flag, l_flag;
682  GLboolean is_bgr;
683 
684  r_flag = g_flag = b_flag = a_flag = l_flag = GL_FALSE;
685  is_bgr = GL_FALSE;
686  switch (format)
687  {
688  case GL_RED:
689  r_flag = GL_TRUE;
690  components = 1;
691  break;
692  case GL_GREEN:
693  g_flag = GL_TRUE;
694  components = 1;
695  break;
696  case GL_BLUE:
697  b_flag = GL_TRUE;
698  components = 1;
699  break;
700  case GL_ALPHA:
701  a_flag = GL_TRUE;
702  components = 1;
703  break;
704  case GL_RGB:
705  r_flag = g_flag = b_flag = GL_TRUE;
706  components = 3;
707  break;
708  case GL_BGR_EXT:
709  is_bgr = GL_TRUE;
710  r_flag = g_flag = b_flag = GL_TRUE;
711  components = 3;
712  break;
713  case GL_LUMINANCE:
714  l_flag = GL_TRUE;
715  components = 1;
716  break;
717  case GL_LUMINANCE_ALPHA:
718  l_flag = a_flag = GL_TRUE;
719  components = 2;
720  break;
721  case GL_RGBA:
722  r_flag = g_flag = b_flag = a_flag = GL_TRUE;
723  components = 4;
724  break;
725  case GL_BGRA_EXT:
726  is_bgr = GL_TRUE;
727  r_flag = g_flag = b_flag = a_flag = GL_TRUE;
728  components = 4;
729  break;
730  default:
731  gl_problem(ctx, "Bad type in draw_color_pixels");
732  return;
733  }
734 
735  /* process the image row by row */
736  for (i = 0; i < height; i++, y++)
737  {
738  DEFARRAY(GLfloat, rf, MAX_WIDTH);
739  DEFARRAY(GLfloat, gf, MAX_WIDTH);
740  DEFARRAY(GLfloat, bf, MAX_WIDTH);
741  DEFARRAY(GLfloat, af, MAX_WIDTH);
746 
747  /* convert to floats */
748  switch (type)
749  {
750  case GL_UNSIGNED_BYTE:
751  {
752  GLubyte *src = (GLubyte *) pixels + i * width * components;
753  for (j = 0; j < width; j++)
754  {
755  if (l_flag)
756  {
757  rf[j] = gf[j] = bf[j] = UBYTE_TO_FLOAT(*src++);
758  }
759  else if (is_bgr)
760  {
761  bf[j] = b_flag ? UBYTE_TO_FLOAT(*src++) : 0.0;
762  gf[j] = g_flag ? UBYTE_TO_FLOAT(*src++) : 0.0;
763  rf[j] = r_flag ? UBYTE_TO_FLOAT(*src++) : 0.0;
764  }
765  else
766  {
767  rf[j] = r_flag ? UBYTE_TO_FLOAT(*src++) : 0.0;
768  gf[j] = g_flag ? UBYTE_TO_FLOAT(*src++) : 0.0;
769  bf[j] = b_flag ? UBYTE_TO_FLOAT(*src++) : 0.0;
770  }
771  af[j] = a_flag ? UBYTE_TO_FLOAT(*src++) : 1.0;
772  }
773  }
774  break;
775  case GL_BYTE:
776  {
777  GLbyte *src = (GLbyte *) pixels + i * width * components;
778  for (j = 0; j < width; j++)
779  {
780  if (l_flag)
781  {
782  rf[j] = gf[j] = bf[j] = BYTE_TO_FLOAT(*src++);
783  }
784  else if (is_bgr)
785  {
786  bf[j] = b_flag ? BYTE_TO_FLOAT(*src++) : 0.0;
787  gf[j] = g_flag ? BYTE_TO_FLOAT(*src++) : 0.0;
788  rf[j] = r_flag ? BYTE_TO_FLOAT(*src++) : 0.0;
789  }
790  else
791  {
792  rf[j] = r_flag ? BYTE_TO_FLOAT(*src++) : 0.0;
793  gf[j] = g_flag ? BYTE_TO_FLOAT(*src++) : 0.0;
794  bf[j] = b_flag ? BYTE_TO_FLOAT(*src++) : 0.0;
795  }
796  af[j] = a_flag ? BYTE_TO_FLOAT(*src++) : 1.0;
797  }
798  }
799  break;
800  case GL_BITMAP:
801  /* special case */
802  break;
803  case GL_UNSIGNED_SHORT:
804  {
806  for (j = 0; j < width; j++)
807  {
808  if (l_flag)
809  {
810  rf[j] = gf[j] = bf[j] = USHORT_TO_FLOAT(*src++);
811  }
812  else if (is_bgr)
813  {
814  bf[j] = b_flag ? USHORT_TO_FLOAT(*src++) : 0.0;
815  gf[j] = g_flag ? USHORT_TO_FLOAT(*src++) : 0.0;
816  rf[j] = r_flag ? USHORT_TO_FLOAT(*src++) : 0.0;
817  }
818  else
819  {
820  rf[j] = r_flag ? USHORT_TO_FLOAT(*src++) : 0.0;
821  gf[j] = g_flag ? USHORT_TO_FLOAT(*src++) : 0.0;
822  bf[j] = b_flag ? USHORT_TO_FLOAT(*src++) : 0.0;
823  }
824  af[j] = a_flag ? USHORT_TO_FLOAT(*src++) : 1.0;
825  }
826  }
827  break;
828  case GL_SHORT:
829  {
830  GLshort *src = (GLshort *) pixels + i * width * components;
831  for (j = 0; j < width; j++)
832  {
833  if (l_flag)
834  {
835  rf[j] = gf[j] = bf[j] = SHORT_TO_FLOAT(*src++);
836  }
837  else if (is_bgr)
838  {
839  bf[j] = b_flag ? SHORT_TO_FLOAT(*src++) : 0.0;
840  gf[j] = g_flag ? SHORT_TO_FLOAT(*src++) : 0.0;
841  rf[j] = r_flag ? SHORT_TO_FLOAT(*src++) : 0.0;
842  }
843  else
844  {
845  rf[j] = r_flag ? SHORT_TO_FLOAT(*src++) : 0.0;
846  gf[j] = g_flag ? SHORT_TO_FLOAT(*src++) : 0.0;
847  bf[j] = b_flag ? SHORT_TO_FLOAT(*src++) : 0.0;
848  }
849  af[j] = a_flag ? SHORT_TO_FLOAT(*src++) : 1.0;
850  }
851  }
852  break;
853  case GL_UNSIGNED_INT:
854  {
855  GLuint *src = (GLuint *) pixels + i * width * components;
856  for (j = 0; j < width; j++)
857  {
858  if (l_flag)
859  {
860  rf[j] = gf[j] = bf[j] = UINT_TO_FLOAT(*src++);
861  }
862  else if (is_bgr)
863  {
864  bf[j] = b_flag ? UINT_TO_FLOAT(*src++) : 0.0;
865  gf[j] = g_flag ? UINT_TO_FLOAT(*src++) : 0.0;
866  rf[j] = r_flag ? UINT_TO_FLOAT(*src++) : 0.0;
867  }
868  else
869  {
870  rf[j] = r_flag ? UINT_TO_FLOAT(*src++) : 0.0;
871  gf[j] = g_flag ? UINT_TO_FLOAT(*src++) : 0.0;
872  bf[j] = b_flag ? UINT_TO_FLOAT(*src++) : 0.0;
873  }
874  af[j] = a_flag ? UINT_TO_FLOAT(*src++) : 1.0;
875  }
876  }
877  break;
878  case GL_INT:
879  {
880  GLint *src = (GLint *) pixels + i * width * components;
881  for (j = 0; j < width; j++)
882  {
883  if (l_flag)
884  {
885  rf[j] = gf[j] = bf[j] = INT_TO_FLOAT(*src++);
886  }
887  else if (is_bgr)
888  {
889  bf[j] = b_flag ? INT_TO_FLOAT(*src++) : 0.0;
890  gf[j] = g_flag ? INT_TO_FLOAT(*src++) : 0.0;
891  rf[j] = r_flag ? INT_TO_FLOAT(*src++) : 0.0;
892  }
893  else
894  {
895  rf[j] = r_flag ? INT_TO_FLOAT(*src++) : 0.0;
896  gf[j] = g_flag ? INT_TO_FLOAT(*src++) : 0.0;
897  bf[j] = b_flag ? INT_TO_FLOAT(*src++) : 0.0;
898  }
899  af[j] = a_flag ? INT_TO_FLOAT(*src++) : 1.0;
900  }
901  }
902  break;
903  case GL_FLOAT:
904  {
905  GLfloat *src = (GLfloat *) pixels + i * width * components;
906  for (j = 0; j < width; j++)
907  {
908  if (l_flag)
909  {
910  rf[j] = gf[j] = bf[j] = *src++;
911  }
912  else if (is_bgr)
913  {
914  bf[j] = b_flag ? *src++ : 0.0;
915  gf[j] = g_flag ? *src++ : 0.0;
916  rf[j] = r_flag ? *src++ : 0.0;
917  }
918  else
919  {
920  rf[j] = r_flag ? *src++ : 0.0;
921  gf[j] = g_flag ? *src++ : 0.0;
922  bf[j] = b_flag ? *src++ : 0.0;
923  }
924  af[j] = a_flag ? *src++ : 1.0;
925  }
926  }
927  break;
928  default:
929  gl_error(ctx, GL_INVALID_ENUM, "glDrawPixels");
930  return;
931  }
932 
933  /* apply scale and bias */
934  if (scale_or_bias)
935  {
936  for (j = 0; j < width; j++)
937  {
938  GLfloat r, g, b, a;
939  r = rf[j] * ctx->Pixel.RedScale + ctx->Pixel.RedBias;
940  g = gf[j] * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias;
941  b = bf[j] * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias;
942  a = af[j] * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias;
943  rf[j] = CLAMP(r, 0.0, 1.0);
944  gf[j] = CLAMP(g, 0.0, 1.0);
945  bf[j] = CLAMP(b, 0.0, 1.0);
946  af[j] = CLAMP(a, 0.0, 1.0);
947  }
948  }
949 
950  /* apply pixel mappings */
951  if (ctx->Pixel.MapColorFlag)
952  {
953  GLfloat rscale = ctx->Pixel.MapRtoRsize - 1;
954  GLfloat gscale = ctx->Pixel.MapGtoGsize - 1;
955  GLfloat bscale = ctx->Pixel.MapBtoBsize - 1;
956  GLfloat ascale = ctx->Pixel.MapAtoAsize - 1;
957  for (j = 0; j < width; j++)
958  {
959  rf[j] = ctx->Pixel.MapRtoR[(GLint) (rf[j] * rscale)];
960  gf[j] = ctx->Pixel.MapGtoG[(GLint) (gf[j] * gscale)];
961  bf[j] = ctx->Pixel.MapBtoB[(GLint) (bf[j] * bscale)];
962  af[j] = ctx->Pixel.MapAtoA[(GLint) (af[j] * ascale)];
963  }
964  }
965 
966  /* convert to integers */
967  for (j = 0; j < width; j++)
968  {
969  red[j] = (GLint) (rf[j] * ctx->Visual->RedScale);
970  green[j] = (GLint) (gf[j] * ctx->Visual->GreenScale);
971  blue[j] = (GLint) (bf[j] * ctx->Visual->BlueScale);
972  alpha[j] = (GLint) (af[j] * ctx->Visual->AlphaScale);
973  }
974 
975  /* write to frame buffer */
976  if (quick_draw)
977  {
978  (*ctx->Driver.WriteColorSpan)(ctx, width, x, y, red, green,
979  blue, alpha, NULL);
980  }
981  else if (zoom)
982  {
983  gl_write_zoomed_color_span(ctx, width, x, y, zspan, red, green,
984  blue, alpha, desty);
985  }
986  else
987  {
988  gl_write_color_span(ctx, (GLuint) width, x, y, zspan, red,
990  }
991 
992  UNDEFARRAY(rf);
993  UNDEFARRAY(gf);
994  UNDEFARRAY(bf);
995  UNDEFARRAY(af);
996  UNDEFARRAY(red);
997  UNDEFARRAY(green);
998  UNDEFARRAY(blue);
999  UNDEFARRAY(alpha);
1000  }
1001  }
1002 
1003 }
#define UBYTE_TO_FLOAT(B)
Definition: macros.h:180
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
#define GL_BGR_EXT
Definition: glext.h:3114
#define UNDEFARRAY(NAME)
Definition: macros.h:257
#define MEMSET(DST, VAL, N)
Definition: macros.h:241
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_RED
Definition: gl.h:480
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GL_FALSE
Definition: gl.h:173
#define INT_TO_FLOAT(I)
Definition: macros.h:215
#define GL_ALPHA
Definition: gl.h:483
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_BGRA_EXT
Definition: glext.h:3115
#define GL_FLOAT
Definition: gl.h:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct gl_current_attrib Current
Definition: types.h:1320
GLvisual * Visual
Definition: types.h:1272
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define SHORT_TO_FLOAT(S)
Definition: macros.h:201
#define GL_SHORT
Definition: gl.h:179
GLuint RasterMask
Definition: types.h:1361
struct dd_function_table Driver
Definition: types.h:1276
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct gl_pixel_attrib Pixel
Definition: types.h:1328
#define a
Definition: ke_i.h:78
#define CLAMP(f, min, max)
Definition: tif_color.c:177
unsigned char GLboolean
Definition: gl.h:151
GLdouble GLdouble z
Definition: glext.h:5874
smooth NULL
Definition: ftsmooth.c:416
GLfloat AlphaScale
Definition: types.h:1143
GLfloat BlueScale
Definition: types.h:1142
Definition: bufpool.h:45
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define USHORT_TO_FLOAT(S)
Definition: macros.h:194
void gl_write_zoomed_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], const GLubyte red[], const GLubyte green[], const GLubyte blue[], const GLubyte alpha[], GLint y0)
Definition: pixel.c:136
GLclampf GLclampf blue
Definition: gl.h:1740
void gl_write_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLubyte r[], GLubyte g[], GLubyte b[], GLubyte a[], GLenum primitive)
Definition: span.c:378
#define b
Definition: ke_i.h:79
GLfloat GreenScale
Definition: types.h:1141
#define BYTE_TO_FLOAT(B)
Definition: macros.h:187
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLint GLdepth
Definition: types.h:218
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
#define MAX_WIDTH
Definition: config.h:130
GLclampf green
Definition: gl.h:1740
GLboolean EightBitColor
Definition: types.h:1146
#define red
Definition: linetest.c:67
#define GL_RGB
Definition: gl.h:502
GLenum GLenum GLuint components
Definition: glext.h:9620
signed char GLbyte
Definition: gl.h:154
#define GL_BLUE
Definition: gl.h:482
GLenum src
Definition: glext.h:6340
void gl_problem(const GLcontext *ctx, const char *s)
Definition: context.c:1394
#define DEFARRAY(TYPE, NAME, SIZE)
Definition: macros.h:256
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define GL_BYTE
Definition: gl.h:177
#define GL_LUMINANCE
Definition: gl.h:484
struct gl_depthbuffer_attrib Depth
Definition: types.h:1321
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
#define GL_GREEN
Definition: gl.h:481
GLfloat RedScale
Definition: types.h:1140
#define GL_TRUE
Definition: gl.h:174
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define GL_INVALID_ENUM
Definition: gl.h:694
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
float GLfloat
Definition: gl.h:161
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
int GLint
Definition: gl.h:156
#define GL_RGBA
Definition: gl.h:503
#define UINT_TO_FLOAT(U)
Definition: macros.h:208
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
unsigned short GLushort
Definition: gl.h:158
#define DEPTH_SCALE
Definition: config.h:146

Referenced by drawpixels().

◆ draw_depth_pixels()

static void draw_depth_pixels ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
GLenum  type,
const GLvoid pixels 
)
static

Definition at line 358 of file drawpix.c.

360 {
361  GLint x, y, desty;
363  GLuint ispan[MAX_WIDTH];
364  GLboolean bias_or_scale;
365  GLboolean zoom;
366 
367  bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
368  zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
369 
370  /* Position, depth of pixels */
371  x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
372  y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
373  desty = y;
374 
375  /* Color or index */
376  if (ctx->Visual->RGBAflag) {
377  GLint r, g, b, a;
378  r = (GLint) (ctx->Current.RasterColor[0] * ctx->Visual->RedScale);
379  g = (GLint) (ctx->Current.RasterColor[1] * ctx->Visual->GreenScale);
380  b = (GLint) (ctx->Current.RasterColor[2] * ctx->Visual->BlueScale);
381  a = (GLint) (ctx->Current.RasterColor[3] * ctx->Visual->AlphaScale);
382  MEMSET( red, r, width );
383  MEMSET( green, g, width );
384  MEMSET( blue, b, width );
385  MEMSET( alpha, a, width );
386  }
387  else {
388  GLuint i;
389  for (i=0;i<width;i++) {
390  ispan[i] = ctx->Current.RasterIndex;
391  }
392  }
393 
394  if (type==GL_UNSIGNED_INT && !bias_or_scale && !zoom && ctx->Visual->RGBAflag)
395  {
396  /* Special case: directly write 32-bit depth values */
397  GLuint i, j;
398  /* Compute shift value to scale 32-bit uints down to depth values. */
399  GLuint shift = 0;
400  GLuint max = MAX_DEPTH;
401  while ((max&0x80000000)==0) {
402  max = max << 1;
403  shift++;
404  }
405  for (j=0;j<height;j++,y++) {
406  GLdepth zspan[MAX_WIDTH];
407  GLuint *zptr = (GLuint *) pixels + j * width;
408  for (i=0;i<width;i++) {
409  zspan[i] = zptr[i] >> shift;
410  }
411  gl_write_color_span( ctx, width, x, y, zspan,
412  red, green, blue, alpha, GL_BITMAP );
413  }
414  }
415  else {
416  /* General case (slower) */
417  GLuint i, j;
418 
419  /* process image row by row */
420  for (i=0;i<height;i++,y++) {
422  GLdepth zspan[MAX_WIDTH];
423 
424  switch (type) {
425  case GL_UNSIGNED_BYTE:
426  {
427  GLubyte *src = (GLubyte *) pixels + i * width;
428  for (j=0;j<width;j++) {
429  depth[j] = UBYTE_TO_FLOAT( *src++ );
430  }
431  }
432  break;
433  case GL_BYTE:
434  {
435  GLbyte *src = (GLbyte *) pixels + i * width;
436  for (j=0;j<width;j++) {
437  depth[j] = BYTE_TO_FLOAT( *src++ );
438  }
439  }
440  break;
441  case GL_UNSIGNED_SHORT:
442  {
443  GLushort *src = (GLushort *) pixels + i * width;
444  for (j=0;j<width;j++) {
445  depth[j] = USHORT_TO_FLOAT( *src++ );
446  }
447  }
448  break;
449  case GL_SHORT:
450  {
451  GLshort *src = (GLshort *) pixels + i * width;
452  for (j=0;j<width;j++) {
453  depth[j] = SHORT_TO_FLOAT( *src++ );
454  }
455  }
456  break;
457  case GL_UNSIGNED_INT:
458  {
459  GLuint *src = (GLuint *) pixels + i * width;
460  for (j=0;j<width;j++) {
461  depth[j] = UINT_TO_FLOAT( *src++ );
462  }
463  }
464  break;
465  case GL_INT:
466  {
467  GLint *src = (GLint *) pixels + i * width;
468  for (j=0;j<width;j++) {
469  depth[j] = INT_TO_FLOAT( *src++ );
470  }
471  }
472  break;
473  case GL_FLOAT:
474  {
475  GLfloat *src = (GLfloat *) pixels + i * width;
476  for (j=0;j<width;j++) {
477  depth[j] = *src++;
478  }
479  }
480  break;
481  default:
482  gl_problem(ctx, "Bad type in draw_depth_pixels");
483  return;
484  }
485 
486  /* apply depth scale and bias */
487  if (ctx->Pixel.DepthScale!=1.0 || ctx->Pixel.DepthBias!=0.0) {
488  for (j=0;j<width;j++) {
489  depth[j] = depth[j] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
490  }
491  }
492 
493  /* clamp depth values to [0,1] and convert from floats to integers */
494  for (j=0;j<width;j++) {
495  zspan[j] = (GLdepth) (CLAMP( depth[j], 0.0F, 1.0F ) * DEPTH_SCALE);
496  }
497 
498  if (ctx->Visual->RGBAflag) {
499  if (zoom) {
500  gl_write_zoomed_color_span( ctx, width, x, y, zspan,
501  red, green, blue, alpha, desty );
502  }
503  else {
504  gl_write_color_span( ctx, width, x, y, zspan,
505  red, green, blue, alpha, GL_BITMAP );
506  }
507  }
508  else {
509  if (zoom) {
510  gl_write_zoomed_index_span( ctx, width, x, y, zspan,
511  ispan, GL_BITMAP );
512  }
513  else {
514  gl_write_index_span( ctx, width, x, y, zspan, ispan, GL_BITMAP );
515  }
516  }
517 
518  }
519  }
520 }
#define UBYTE_TO_FLOAT(B)
Definition: macros.h:180
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
#define MEMSET(DST, VAL, N)
Definition: macros.h:241
GLint GLint GLsizei width
Definition: gl.h:1546
#define max(a, b)
Definition: svc.c:63
#define shift
Definition: input.c:1668
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define INT_TO_FLOAT(I)
Definition: macros.h:215
GLboolean RGBAflag
Definition: types.h:1137
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_FLOAT
Definition: gl.h:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct gl_current_attrib Current
Definition: types.h:1320
GLvisual * Visual
Definition: types.h:1272
#define SHORT_TO_FLOAT(S)
Definition: macros.h:201
#define GL_SHORT
Definition: gl.h:179
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct gl_pixel_attrib Pixel
Definition: types.h:1328
#define a
Definition: ke_i.h:78
#define CLAMP(f, min, max)
Definition: tif_color.c:177
unsigned char GLboolean
Definition: gl.h:151
GLfloat AlphaScale
Definition: types.h:1143
GLfloat BlueScale
Definition: types.h:1142
#define MAX_DEPTH
Definition: config.h:145
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define USHORT_TO_FLOAT(S)
Definition: macros.h:194
void gl_write_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLuint index[], GLenum primitive)
Definition: span.c:167
void gl_write_zoomed_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], const GLubyte red[], const GLubyte green[], const GLubyte blue[], const GLubyte alpha[], GLint y0)
Definition: pixel.c:136
GLclampf GLclampf blue
Definition: gl.h:1740
void gl_write_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLubyte r[], GLubyte g[], GLubyte b[], GLubyte a[], GLenum primitive)
Definition: span.c:378
#define b
Definition: ke_i.h:79
GLfloat GreenScale
Definition: types.h:1141
#define BYTE_TO_FLOAT(B)
Definition: macros.h:187
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLint GLdepth
Definition: types.h:218
#define MAX_WIDTH
Definition: config.h:130
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
signed char GLbyte
Definition: gl.h:154
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
void gl_problem(const GLcontext *ctx, const char *s)
Definition: context.c:1394
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_BYTE
Definition: gl.h:177
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
GLfloat RedScale
Definition: types.h:1140
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
float GLfloat
Definition: gl.h:161
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
int GLint
Definition: gl.h:156
#define UINT_TO_FLOAT(U)
Definition: macros.h:208
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
unsigned short GLushort
Definition: gl.h:158
void gl_write_zoomed_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], const GLuint indexes[], GLint y0)
Definition: pixel.c:237
#define F(x, y, z)
Definition: md5.c:51
#define DEPTH_SCALE
Definition: config.h:146

Referenced by drawpixels().

◆ draw_index_pixels()

static void draw_index_pixels ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
GLenum  type,
const GLvoid pixels 
)
static

Definition at line 99 of file drawpix.c.

101 {
102  GLint x, y, desty;
103  GLuint i, j;
104  GLdepth zspan[MAX_WIDTH];
105  GLboolean zoom;
106 
107  zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
108 
109  /* Position, depth of pixels */
110  x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
111  y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
112  desty = y;
113  if (ctx->Depth.Test) {
114  GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
115  for (i=0;i<width;i++) {
116  zspan[i] = zval;
117  }
118  }
119 
120  /* process the image row by row */
121  for (i=0;i<height;i++,y++) {
122  GLuint ispan[MAX_WIDTH];
123 
124  /* convert to uints */
125  switch (type) {
126  case GL_UNSIGNED_BYTE:
127  {
128  GLubyte *src = (GLubyte *) pixels + i * width;
129  for (j=0;j<width;j++) {
130  ispan[j] = (GLuint) *src++;
131  }
132  }
133  break;
134  case GL_BYTE:
135  {
136  GLbyte *src = (GLbyte *) pixels + i * width;
137  for (j=0;j<width;j++) {
138  ispan[j] = (GLuint) *src++;
139  }
140  }
141  break;
142  case GL_UNSIGNED_SHORT:
143  {
144  GLushort *src = (GLushort *) pixels + i * width;
145  for (j=0;j<width;j++) {
146  ispan[j] = (GLuint) *src++;
147  }
148  }
149  break;
150  case GL_SHORT:
151  {
152  GLshort *src = (GLshort *) pixels + i * width;
153  for (j=0;j<width;j++) {
154  ispan[j] = (GLuint) *src++;
155  }
156  }
157  break;
158  case GL_UNSIGNED_INT:
159  {
160  GLuint *src = (GLuint *) pixels + i * width;
161  for (j=0;j<width;j++) {
162  ispan[j] = *src++;
163  }
164  }
165  break;
166  case GL_INT:
167  {
168  GLint *src = (GLint *) pixels + i * width;
169  for (j=0;j<width;j++) {
170  ispan[j] = (GLuint) *src++;
171  }
172  }
173  break;
174  case GL_BITMAP:
175  /* TODO */
176  break;
177  case GL_FLOAT:
178  {
179  GLfloat *src = (GLfloat *) pixels + i * width;
180  for (j=0;j<width;j++) {
181  ispan[j] = (GLuint) (GLint) *src++;
182  }
183  }
184  break;
185  default:
186  gl_error( ctx, GL_INVALID_ENUM, "Internal: draw_index_pixels" );
187  }
188 
189  /* apply shift and offset */
190  if (ctx->Pixel.IndexOffset || ctx->Pixel.IndexShift) {
191  if (ctx->Pixel.IndexShift>=0) {
192  for (j=0;j<width;j++) {
193  ispan[j] = (ispan[j] << ctx->Pixel.IndexShift)
194  + ctx->Pixel.IndexOffset;
195  }
196  }
197  else {
198  for (j=0;j<width;j++) {
199  ispan[j] = (ispan[j] >> -ctx->Pixel.IndexShift)
200  + ctx->Pixel.IndexOffset;
201  }
202  }
203  }
204 
205  if (ctx->Visual->RGBAflag) {
206  /* Convert index to RGBA and write to frame buffer */
209  for (j=0;j<width;j++) {
210  red[j] = (GLint) (ctx->Pixel.MapItoR[ispan[j]] * ctx->Visual->RedScale);
211  green[j] = (GLint) (ctx->Pixel.MapItoG[ispan[j]] * ctx->Visual->GreenScale);
212  blue[j] = (GLint) (ctx->Pixel.MapItoB[ispan[j]] * ctx->Visual->BlueScale);
213  alpha[j] = (GLint) (ctx->Pixel.MapItoA[ispan[j]] * ctx->Visual->AlphaScale);
214  }
215  if (zoom) {
216  gl_write_zoomed_color_span( ctx, width, x, y, zspan,
217  red, green, blue, alpha, desty );
218  }
219  else {
220  gl_write_color_span( ctx, width, x, y, zspan,
221  red, green, blue, alpha, GL_BITMAP );
222  }
223  }
224  else {
225  /* optionally apply index map then write to frame buffer */
226  if (ctx->Pixel.MapColorFlag) {
227  for (j=0;j<width;j++) {
228  ispan[j] = ctx->Pixel.MapItoI[ispan[j]];
229  }
230  }
231  if (zoom) {
232  gl_write_zoomed_index_span( ctx, width, x, y, zspan, ispan, desty );
233  }
234  else {
235  gl_write_index_span( ctx, width, x, y, zspan, ispan, GL_BITMAP );
236  }
237  }
238  }
239 
240 }
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
GLboolean RGBAflag
Definition: types.h:1137
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_FLOAT
Definition: gl.h:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct gl_current_attrib Current
Definition: types.h:1320
GLvisual * Visual
Definition: types.h:1272
#define GL_SHORT
Definition: gl.h:179
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct gl_pixel_attrib Pixel
Definition: types.h:1328
unsigned char GLboolean
Definition: gl.h:151
GLfloat AlphaScale
Definition: types.h:1143
GLfloat BlueScale
Definition: types.h:1142
#define GL_UNSIGNED_INT
Definition: gl.h:182
void gl_write_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLuint index[], GLenum primitive)
Definition: span.c:167
void gl_write_zoomed_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], const GLubyte red[], const GLubyte green[], const GLubyte blue[], const GLubyte alpha[], GLint y0)
Definition: pixel.c:136
GLclampf GLclampf blue
Definition: gl.h:1740
void gl_write_color_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth z[], GLubyte r[], GLubyte g[], GLubyte b[], GLubyte a[], GLenum primitive)
Definition: span.c:378
GLfloat GreenScale
Definition: types.h:1141
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
GLint GLdepth
Definition: types.h:218
#define MAX_WIDTH
Definition: config.h:130
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
signed char GLbyte
Definition: gl.h:154
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define GL_BYTE
Definition: gl.h:177
struct gl_depthbuffer_attrib Depth
Definition: types.h:1321
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
GLfloat RedScale
Definition: types.h:1140
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define GL_INVALID_ENUM
Definition: gl.h:694
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
float GLfloat
Definition: gl.h:161
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
int GLint
Definition: gl.h:156
unsigned short GLushort
Definition: gl.h:158
void gl_write_zoomed_index_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], const GLuint indexes[], GLint y0)
Definition: pixel.c:237
#define DEPTH_SCALE
Definition: config.h:146

Referenced by drawpixels().

◆ draw_stencil_pixels()

static void draw_stencil_pixels ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
GLenum  type,
const GLvoid pixels 
)
static

Definition at line 244 of file drawpix.c.

246 {
247  GLint x, y, desty;
248  GLuint i, j;
249  GLboolean zoom;
250 
251  zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
252 
253  /* Position, depth of pixels */
254  x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
255  y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
256  desty = y;
257 
258  /* process the image row by row */
259  for (i=0;i<height;i++,y++) {
261 
262  /* convert to ubytes */
263  switch (type) {
264  case GL_UNSIGNED_BYTE:
265  {
266  GLubyte *src = (GLubyte *) pixels + i * width;
267  MEMCPY( stencil, src, width );
268  }
269  break;
270  case GL_BYTE:
271  {
272  GLbyte *src = (GLbyte *) pixels + i * width;
273  MEMCPY( stencil, src, width );
274  }
275  break;
276  case GL_UNSIGNED_SHORT:
277  {
278  GLushort *src = (GLushort *) pixels + i * width;
279  for (j=0;j<width;j++) {
280  stencil[j] = (GLubyte) ((*src++) & 0xff);
281  }
282  }
283  break;
284  case GL_SHORT:
285  {
286  GLshort *src = (GLshort *) pixels + i * width;
287  for (j=0;j<width;j++) {
288  stencil[j] = (GLubyte) ((*src++) & 0xff);
289  }
290  }
291  break;
292  case GL_UNSIGNED_INT:
293  {
294  GLuint *src = (GLuint *) pixels + i * width;
295  for (j=0;j<width;j++) {
296  stencil[j] = (GLubyte) ((*src++) & 0xff);
297  }
298  }
299  break;
300  case GL_INT:
301  {
302  GLint *src = (GLint *) pixels + i * width;
303  for (j=0;j<width;j++) {
304  stencil[j] = (GLubyte) ((*src++) & 0xff);
305  }
306  }
307  break;
308  case GL_BITMAP:
309  /* TODO */
310  break;
311  case GL_FLOAT:
312  {
313  GLfloat *src = (GLfloat *) pixels + i * width;
314  for (j=0;j<width;j++) {
315  stencil[j] = (GLubyte) (((GLint) *src++) & 0xff);
316  }
317  }
318  break;
319  default:
320  gl_error( ctx, GL_INVALID_ENUM, "Internal: draw_stencil_pixels" );
321  }
322 
323  /* apply shift and offset */
324  if (ctx->Pixel.IndexOffset || ctx->Pixel.IndexShift) {
325  if (ctx->Pixel.IndexShift>=0) {
326  for (j=0;j<width;j++) {
327  stencil[j] = (stencil[j] << ctx->Pixel.IndexShift)
328  + ctx->Pixel.IndexOffset;
329  }
330  }
331  else {
332  for (j=0;j<width;j++) {
333  stencil[j] = (stencil[j] >> -ctx->Pixel.IndexShift)
334  + ctx->Pixel.IndexOffset;
335  }
336  }
337  }
338 
339  /* mapping */
340  if (ctx->Pixel.MapStencilFlag) {
341  for (j=0;j<width;j++) {
342  stencil[j] = ctx->Pixel.MapStoS[ stencil[j] ];
343  }
344  }
345 
346  /* write stencil values to stencil buffer */
347  if (zoom) {
348  gl_write_zoomed_stencil_span( ctx, (GLuint) width, x, y, stencil, desty );
349  }
350  else {
352  }
353  }
354 }
#define GL_INT
Definition: gl.h:181
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
void gl_write_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte stencil[])
Definition: stencil.c:957
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_BITMAP
Definition: gl.h:497
unsigned char GLubyte
Definition: gl.h:157
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_FLOAT
Definition: gl.h:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct gl_current_attrib Current
Definition: types.h:1320
#define GL_SHORT
Definition: gl.h:179
GLint GLfloat GLint stencil
Definition: glext.h:6260
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct gl_pixel_attrib Pixel
Definition: types.h:1328
unsigned char GLboolean
Definition: gl.h:151
#define GL_UNSIGNED_INT
Definition: gl.h:182
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MAX_WIDTH
Definition: config.h:130
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
void gl_write_zoomed_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLubyte stencil[], GLint y0)
Definition: pixel.c:328
signed char GLbyte
Definition: gl.h:154
GLenum src
Definition: glext.h:6340
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define GL_BYTE
Definition: gl.h:177
short GLshort
Definition: gl.h:155
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
#define GL_INVALID_ENUM
Definition: gl.h:694
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
float GLfloat
Definition: gl.h:161
int GLint
Definition: gl.h:156
unsigned short GLushort
Definition: gl.h:158

Referenced by drawpixels().

◆ drawpixels()

static void drawpixels ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)
static

Definition at line 1075 of file drawpix.c.

1077 {
1078  if (INSIDE_BEGIN_END(ctx)) {
1079  gl_error( ctx, GL_INVALID_OPERATION, "glDrawPixels" );
1080  return;
1081  }
1082 
1083  if (ctx->RenderMode==GL_RENDER) {
1084  if (!ctx->Current.RasterPosValid) {
1085  return;
1086  }
1087  switch (format) {
1088  case GL_COLOR_INDEX:
1090  break;
1091  case GL_STENCIL_INDEX:
1093  break;
1094  case GL_DEPTH_COMPONENT:
1096  break;
1097  case GL_RED:
1098  case GL_GREEN:
1099  case GL_BLUE:
1100  case GL_ALPHA:
1101  case GL_RGB:
1102  case GL_BGR_EXT:
1103  case GL_LUMINANCE:
1104  case GL_LUMINANCE_ALPHA:
1105  case GL_RGBA:
1106  case GL_BGRA_EXT:
1108  break;
1109  default:
1110  gl_error( ctx, GL_INVALID_ENUM, "glDrawPixels" );
1111  }
1112  }
1113  else if (ctx->RenderMode==GL_FEEDBACK) {
1114  if (ctx->Current.RasterPosValid) {
1115  GLfloat color[4], texcoord[4], invq;
1116  color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale;
1117  color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale;
1118  color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale;
1119  color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale;
1120  invq = 1.0F / ctx->Current.TexCoord[3];
1121  texcoord[0] = ctx->Current.TexCoord[0] * invq;
1122  texcoord[1] = ctx->Current.TexCoord[1] * invq;
1123  texcoord[2] = ctx->Current.TexCoord[2] * invq;
1124  texcoord[3] = ctx->Current.TexCoord[3];
1126  gl_feedback_vertex( ctx, ctx->Current.RasterPos[0],
1127  ctx->Current.RasterPos[1],
1128  ctx->Current.RasterPos[2],
1129  ctx->Current.RasterPos[3],
1130  color, ctx->Current.Index, texcoord );
1131  }
1132  }
1133  else if (ctx->RenderMode==GL_SELECT) {
1134  if (ctx->Current.RasterPosValid) {
1135  gl_update_hitflag( ctx, ctx->Current.RasterPos[2] );
1136  }
1137  }
1138 }
#define GL_BGR_EXT
Definition: glext.h:3114
GLint GLint GLsizei width
Definition: gl.h:1546
#define GL_RED
Definition: gl.h:480
#define GL_ALPHA
Definition: gl.h:483
#define GL_BGRA_EXT
Definition: glext.h:3115
static void draw_depth_pixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum type, const GLvoid *pixels)
Definition: drawpix.c:358
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct gl_current_attrib Current
Definition: types.h:1320
GLvisual * Visual
Definition: types.h:1272
#define FEEDBACK_TOKEN(CTX, T)
Definition: feedback.h:39
#define GL_DRAW_PIXEL_TOKEN
Definition: gl.h:402
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135
GLuint color
Definition: glext.h:6243
void gl_update_hitflag(GLcontext *ctx, GLfloat z)
Definition: feedback.c:240
GLenum RenderMode
Definition: types.h:1356
GLfloat InvRedScale
Definition: types.h:1148
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
static void draw_color_pixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
Definition: drawpix.c:524
#define GL_RGB
Definition: gl.h:502
#define GL_STENCIL_INDEX
Definition: gl.h:458
#define GL_INVALID_OPERATION
Definition: gl.h:696
#define GL_BLUE
Definition: gl.h:482
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define GL_LUMINANCE
Definition: gl.h:484
#define GL_SELECT
Definition: gl.h:389
#define GL_DEPTH_COMPONENT
Definition: gl.h:307
#define GL_GREEN
Definition: gl.h:481
#define GL_COLOR_INDEX
Definition: gl.h:479
#define GL_FEEDBACK
Definition: gl.h:387
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLfloat InvBlueScale
Definition: types.h:1150
#define GL_INVALID_ENUM
Definition: gl.h:694
float GLfloat
Definition: gl.h:161
static void draw_stencil_pixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum type, const GLvoid *pixels)
Definition: drawpix.c:244
GLfloat InvGreenScale
Definition: types.h:1149
int GLint
Definition: gl.h:156
#define GL_RGBA
Definition: gl.h:503
#define GL_RENDER
Definition: gl.h:388
GLfloat InvAlphaScale
Definition: types.h:1151
static void draw_index_pixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum type, const GLvoid *pixels)
Definition: drawpix.c:99
void gl_feedback_vertex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w, const GLfloat color[4], GLfloat index, const GLfloat texcoord[4])
Definition: feedback.c:161

Referenced by gl_DrawPixels().

◆ gl_DrawPixels()

void gl_DrawPixels ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
const GLvoid pixels 
)

Definition at line 1145 of file drawpix.c.

1147 {
1148  GLvoid *image;
1149 
1150  if (width<0 || height<0) {
1151  gl_error( ctx, GL_INVALID_VALUE, "glDrawPixels" );
1152  return;
1153  }
1154 
1155  if (ctx->NewState) {
1156  gl_update_state(ctx);
1157  }
1158 
1159  /* Let the device driver take a crack at glDrawPixels */
1160  if (!ctx->CompileFlag && ctx->Driver.DrawPixels) {
1161  GLint x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
1162  GLint y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
1163  if ((*ctx->Driver.DrawPixels)( ctx, x, y, width, height,
1164  format, type, GL_FALSE, pixels )) {
1165  /* Device driver did the job */
1166  return;
1167  }
1168  }
1169 
1171  && !ctx->CompileFlag && ctx->RenderMode==GL_RENDER
1172  && ctx->RasterMask==0 && ctx->CallDepth==0) {
1173  /* optimized path */
1174  if (quickdraw_rgb( ctx, width, height, pixels )) {
1175  /* success */
1176  return;
1177  }
1178  }
1179 
1180  /* take the general path */
1181 
1182  /* THIS IS A REAL HACK - FIX IN MESA 2.5
1183  * If we're inside glCallList then we don't have to unpack the pixels again.
1184  */
1185  if (ctx->CallDepth == 0) {
1187  if (!image) {
1188  gl_error( ctx, GL_OUT_OF_MEMORY, "glDrawPixels" );
1189  return;
1190  }
1191  }
1192  else {
1193  image = (GLvoid *) pixels;
1194  }
1195 
1196  if (ctx->CompileFlag) {
1198  }
1199  if (ctx->ExecuteFlag) {
1200  drawpixels( ctx, width, height, format, type, image );
1201  if (!ctx->CompileFlag) {
1202  /* may discard unpacked image now */
1203  if (image!=pixels)
1204  free( image );
1205  }
1206  }
1207 }
GLeglImageOES image
Definition: gl.h:2204
GLuint CallDepth
Definition: types.h:1305
GLint GLint GLsizei width
Definition: gl.h:1546
GLboolean ExecuteFlag
Definition: types.h:1306
GLuint NewState
Definition: types.h:1355
#define GL_FALSE
Definition: gl.h:173
#define free
Definition: debug_ros.c:5
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct gl_current_attrib Current
Definition: types.h:1320
GLboolean FastDrawPixels
Definition: types.h:1368
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLuint RasterMask
Definition: types.h:1361
struct dd_function_table Driver
Definition: types.h:1276
void gl_save_DrawPixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
Definition: dlist.c:1249
GLenum RenderMode
Definition: types.h:1356
#define GL_RGB
Definition: gl.h:502
#define GL_INVALID_VALUE
Definition: gl.h:695
GLboolean CompileFlag
Definition: types.h:1307
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
static GLboolean quickdraw_rgb(GLcontext *ctx, GLsizei width, GLsizei height, const void *pixels)
Definition: drawpix.c:1014
void gl_update_state(GLcontext *ctx)
Definition: context.c:1749
GLvoid * gl_unpack_pixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
Definition: pixel.c:880
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define GL_OUT_OF_MEMORY
Definition: gl.h:699
int GLint
Definition: gl.h:156
#define GL_RENDER
Definition: gl.h:388
static void drawpixels(GLcontext *ctx, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
Definition: drawpix.c:1075

Referenced by execute_list(), init_dlist_pointers(), and init_exec_pointers().

◆ quickdraw_rgb()

static GLboolean quickdraw_rgb ( GLcontext ctx,
GLsizei  width,
GLsizei  height,
const void pixels 
)
static

Definition at line 1014 of file drawpix.c.

1016 {
1021  GLint i, j;
1022  GLint x, y;
1023  GLint bytes_per_row;
1024  GLboolean result;
1025 
1026  bytes_per_row = width * 3 + (width % ctx->Unpack.Alignment);
1027 
1028  if (!ctx->Current.RasterPosValid) {
1029  /* This is success, actually. */
1030  result = GL_TRUE;
1031  }
1032  else {
1033  x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
1034  y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
1035 
1036  if (x<0 || y<0
1037  || x+width>ctx->Buffer->Width || y+height>ctx->Buffer->Height) {
1038  result = GL_FALSE; /* can't handle this situation */
1039  }
1040  else {
1041  /* constant alpha */
1042  for (j=0;j<width;j++) {
1043  alpha[j] = (GLint) ctx->Visual->AlphaScale;
1044  }
1045 
1046  /* write directly to device driver */
1047  for (i=0;i<height;i++) {
1048  /* each row of pixel data starts at 4-byte boundary */
1049  GLubyte *src = (GLubyte *) pixels + i * bytes_per_row;
1050  for (j=0;j<width;j++) {
1051  red[j] = *src++;
1052  green[j] = *src++;
1053  blue[j] = *src++;
1054  }
1055  (*ctx->Driver.WriteColorSpan)( ctx, width, x, y+i,
1056  red, green, blue, alpha, NULL);
1057  }
1058  result = GL_TRUE;
1059  }
1060  }
1061 
1062  UNDEFARRAY( red );
1063  UNDEFARRAY( green );
1064  UNDEFARRAY( blue );
1065  UNDEFARRAY( alpha );
1066 
1067  return result;
1068 }
#define UNDEFARRAY(NAME)
Definition: macros.h:257
GLint GLint GLsizei width
Definition: gl.h:1546
GLframebuffer * Buffer
Definition: types.h:1273
unsigned char GLubyte
Definition: gl.h:157
#define GL_FALSE
Definition: gl.h:173
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
struct gl_current_attrib Current
Definition: types.h:1320
GLvisual * Visual
Definition: types.h:1272
GLint Height
Definition: types.h:1179
struct dd_function_table Driver
Definition: types.h:1276
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char GLboolean
Definition: gl.h:151
smooth NULL
Definition: ftsmooth.c:416
GLfloat AlphaScale
Definition: types.h:1143
GLclampf GLclampf blue
Definition: gl.h:1740
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MAX_WIDTH
Definition: config.h:130
GLclampf green
Definition: gl.h:1740
#define red
Definition: linetest.c:67
GLenum src
Definition: glext.h:6340
#define DEFARRAY(TYPE, NAME, SIZE)
Definition: macros.h:256
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
struct gl_pixelstore_attrib Unpack
Definition: types.h:1344
#define GL_TRUE
Definition: gl.h:174
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: gl.h:1546
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint Width
Definition: types.h:1178
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
int GLint
Definition: gl.h:156
GLuint64EXT * result
Definition: glext.h:11304

Referenced by gl_DrawPixels().