ref: 29391635dbbba91a93aa316d80ea38b158e05aef
parent: 2d8758d2ff5ec69fbb4c5d341fa35f0ffe6cd361
author: David <gek@katherine>
date: Sat Feb 20 21:37:13 EST 2021
Added glPointSize with No distance scaling. TODO is to scale based on distance.
--- a/SDL_Examples/gears.c
+++ b/SDL_Examples/gears.c
@@ -242,7 +242,7 @@
glEnable(GL_POLYGON_STIPPLE);
// glDisable(GL_POLYGON_STIPPLE);
glPolygonStipple(stipplepattern);
-
+ glPointSize(10.0f);
glTextSize(GL_TEXT_SIZE24x24);
/* make the gears */
gear1 = glGenLists(1);
--- a/src/init.c
+++ b/src/init.c
@@ -280,6 +280,7 @@
/* depth test */
c->zb->depth_test = 0;
c->zb->depth_write = 1;
+ c->zb->pointsize = 1;
/* raster position */
c->rasterpos.v[0] = 0;
--- a/src/zline.c
+++ b/src/zline.c
@@ -12,16 +12,45 @@
GLint zz;
GLubyte zbdw = zb->depth_write;
GLubyte zbdt = zb->depth_test;
- //TGL_BLEND_VARS
+ GLfloat zbps = zb->pointsize;
+ TGL_BLEND_VARS
// PIXEL col;
- pz = zb->zbuf + (p->y * zb->xsize + p->x);
- pp = (PIXEL*)((GLbyte*)zb->pbuf + zb->linesize * p->y + p->x * PSZB);
- zz = p->z >> ZB_POINT_Z_FRAC_BITS;
- if (ZCMP(zz, *pz)) {
- *pp = RGB_TO_PIXEL(p->r, p->g, p->b);
- //TGL_BLEND_FUNC_RGB(p->r, p->g, p->b, (*pp))
- if(zbdw)
- *pz = zz;
+ if(zbps == 1){
+ pz = zb->zbuf + (p->y * zb->xsize + p->x);
+ pp = (PIXEL*)((GLbyte*)zb->pbuf + zb->linesize * p->y + p->x * PSZB);
+ zz = p->z >> ZB_POINT_Z_FRAC_BITS;
+ if (ZCMP(zz, *pz)) {
+ if(!zb->enable_blend)
+ *pp = RGB_TO_PIXEL(p->r, p->g, p->b);
+ else
+ TGL_BLEND_FUNC_RGB(p->r, p->g, p->b, (*pp))
+ if(zbdw)
+ *pz = zz;
+ }
+ } else {
+ PIXEL col = RGB_TO_PIXEL(p->r, p->g, p->b);
+ GLfloat hzbps = zbps / 2.0f;
+ GLint bx = (GLfloat)p->x - hzbps; GLint ex = (GLfloat)p->x + hzbps;
+ GLint by = (GLfloat)p->y - hzbps; GLint ey = (GLfloat)p->y + hzbps;
+ bx = (bx<0)?0:bx;
+ by = (by<0)?0:by;
+ ex = (ex>zb->xsize)?zb->xsize:ex;
+ ey = (ey>zb->ysize)?zb->ysize:ey;
+ for(GLint y = by; y < ey; y++)
+ for(GLint x = bx; x < ex; x++)
+ {
+ pz = zb->zbuf + (y * zb->xsize + x);
+ pp = (PIXEL*)((GLbyte*)zb->pbuf + zb->linesize * y + x * PSZB);
+ zz = p->z >> ZB_POINT_Z_FRAC_BITS;
+ if (ZCMP(zz, *pz)) {
+ if(!zb->enable_blend)
+ *pp = col;
+ else
+ TGL_BLEND_FUNC_RGB(p->r, p->g, p->b, (*pp))
+ if(zbdw)
+ *pz = zz;
+ }
+ }
}
}