shithub: tinygl

Download patch

ref: 3aaf17bc54e0ab5bc103036d016a76283c371517
parent: 12e7574c2cfaaa85ba947512670fc64cba6a51c3
author: David <gek@katherine>
date: Tue Feb 16 15:40:28 EST 2021

More detachment from stdio

--- a/src/clip.c
+++ b/src/clip.c
@@ -1,5 +1,5 @@
 #include "zgl.h"
-
+#include "msghandling.h"
 /* fill triangle profile */
 /* #define PROFILE */
 
@@ -32,7 +32,7 @@
 }
 
 static void gl_add_select1(GLContext* c, GLint z1, GLint z2, GLint z3) {
-	GLuint min, max;
+	GLint min, max;
 	min = max = z1;
 	if (z2 < min)
 		min = z2;
@@ -198,10 +198,10 @@
 		q->zp.g = p0->zp.g + (p1->zp.g - p0->zp.g) * t;
 		q->zp.b = p0->zp.b + (p1->zp.b - p0->zp.b) * t;
 		// q->color.v[3]=p0->color.v[3] + (p1->color.v[3] - p0->color.v[3])*t;
-		// printf("\np0 Components are %f, %f, %f", p0->color.v[0], p0->color.v[1], p0->color.v[2]);
-		// printf("\nZbuffer point r,g,b for p0 are: %d %d %d",p0->zp.r, p0->zp.g,p0->zp.b);
-		// printf("\n~\nNew Components are %f, %f, %f", q->color.v[0], q->color.v[1], q->color.v[2]);
-		// printf("\nZbuffer point r,g,b for new point are: %d %d %d",q->zp.r, q->zp.g,q->zp.b);
+		// tgl_warning("\np0 Components are %f, %f, %f", p0->color.v[0], p0->color.v[1], p0->color.v[2]);
+		// tgl_warning("\nZbuffer point r,g,b for p0 are: %d %d %d",p0->zp.r, p0->zp.g,p0->zp.b);
+		// tgl_warning("\n~\nNew Components are %f, %f, %f", q->color.v[0], q->color.v[1], q->color.v[2]);
+		// tgl_warning("\nZbuffer point r,g,b for new point are: %d %d %d",q->zp.r, q->zp.g,q->zp.b);
 		/// *
 	} else {
 		q->color.v[0] = p0->color.v[0];
@@ -301,10 +301,10 @@
 		/* this test can be true only in case of rounding errors */
 		if (clip_bit == 6) {
 #if 0
-      printf("Error:\n");
-      printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);
-      printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);
-      printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
+      tgl_warning("Error:\n");
+      tgl_warning("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);
+      tgl_warning("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);
+      tgl_warning("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
 #endif
 			return;
 		}
--- a/src/list.c
+++ b/src/list.c
@@ -76,10 +76,10 @@
 			s++;
 			switch (*s++) {
 			case 'f':
-				fprintf(f, "%g", p[0].f);
+				fpr_ntf(f, "%g", p[0].f);
 				break;
 			default:
-				fprintf(f, "%d", p[0].i);
+				fpr_ntf(f, "%d", p[0].i);
 				break;
 			}
 			p++;
--- a/src/misc.c
+++ b/src/misc.c
@@ -97,7 +97,7 @@
 			gl_enable_disable_light(c, code - GL_LIGHT0, v);
 		} else {
 			/*
-			fprintf(stderr,"glEnableDisable: 0x%X not supported.\n",code);
+			fpr_ntf(stderr,"glEnableDisable: 0x%X not supported.\n",code);
 			*/
 		}
 		break;
--- a/src/oscontext.c.unused
+++ /dev/null
@@ -1,84 +1,0 @@
-#include "include/GL/oscontext.h"
-#include "include/zbuffer.h"
-#include "zgl.h"
-#include "include/GL/gl.h"
-#include <stdlib.h>
-#include <assert.h>
-
-static int buffercnt = 0;
-
-ostgl_context *
-ostgl_create_context(const int xsize,
-                     const int ysize,
-                     const int depth,
-                     void **framebuffers,
-                     const int numbuffers)
-{
-  ostgl_context *context;
-  int i;
-  ZBuffer *zb;
-   
-  assert(depth == 16); /* support for other depths must include bpp 
-                          convertion */
-  assert(numbuffers >= 1);
-  
-  context = gl_malloc(sizeof(ostgl_context));
-  assert(context);
-  context->zbs = gl_malloc(sizeof(void*)*numbuffers);
-  context->framebuffers = gl_malloc(sizeof(void*)*numbuffers);
-  
-  assert(context->zbs != NULL && context->framebuffers != NULL);
-  
-  for (i = 0; i < numbuffers; i++) {
-    context->framebuffers[i] = framebuffers[i];
-    zb = ZB_open(xsize, ysize, ZB_MODE_5R6G5B, 0, NULL, NULL, framebuffers[i]);
-    if (zb == NULL) {
-      fprintf(stderr, "Error while initializing Z buffer\n");
-      exit(1);
-    }
-    context->zbs[i] = zb;
-  }
-  if (++buffercnt == 1) {
-    glInit(context->zbs[0]);
-  }
-  context->xsize = xsize;
-  context->ysize = ysize;
-  context->numbuffers = numbuffers;
-  return context;
-}
-
-void
-ostgl_delete_context(ostgl_context *context)
-{
-  int i;
-  for (i = 0; i < context->numbuffers; i++) {
-    ZB_close(context->zbs[i]);
-  }
-  gl_free(context->zbs);
-  gl_free(context->framebuffers);
-  gl_free(context);
-  
-  if (--buffercnt == 0) {
-    glClose();
-  }
-}
-
-void
-ostgl_make_current(ostgl_context *oscontext, const int idx)
-{
-  GLContext *context = gl_get_context();
-  assert(idx < oscontext->numbuffers);
-  context->zb = oscontext->zbs[idx];
-}
-
-void
-ostgl_resize(ostgl_context *context,
-             const int xsize,
-             const int ysize,
-             void **framebuffers)
-{
-  int i;
-  for (i = 0; i < context->numbuffers; i++) {
-    ZB_resize(context->zbs[i], framebuffers[i], xsize, ysize);
-  }
-}
--- a/src/zdither.c
+++ b/src/zdither.c
@@ -34,7 +34,7 @@
 	GLint c, r, g, b, i, index, r1, g1, b1;
 
 	if (nb_colors < (_R * _G * _B)) {
-//		fprintf(stderr, "zdither: not enough colors\n");
+//		tgl_fixme("zdither: not enough colors\n");
 		exit(1);
 	}
 
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -325,7 +325,7 @@
 
 #ifdef DEBUG
 
-#define dprintf(format, args...) fprintf(stderr, "In '%s': " format "\n", __FUNCTION__, ##args);
+#define dprintf(format, args...) tgl_warning("In '%s': " format "\n", __FUNCTION__, ##args);
 
 #else