ref: 8c3305a219d4ed99a13dd49ea86c67204d0df1af
parent: 67a5468e01cce119ddb9080300374ebfb96cb109
author: David <gek@katherine>
date: Thu Feb 18 15:11:38 EST 2021
Added version, vendor, and renderer strings
--- a/SDL_Examples/Makefile
+++ b/SDL_Examples/Makefile
@@ -12,12 +12,12 @@
rm -f $(ALL_T) *.exe
rm -f menu
texture:
- gcc texture.c $(LIB) -o texture $(GL_INCLUDES) $(SDL_LIBS) $(SDL_MIXERLIBS) $(GL_LIBS) $(CFLAGS) -lm
+ $(CC) texture.c $(LIB) -o texture $(GL_INCLUDES) $(SDL_LIBS) $(SDL_MIXERLIBS) $(GL_LIBS) $(CFLAGS) -lm
menu:
- gcc menu.c $(LIB) -o menu $(GL_INCLUDES) $(SDL_LIBS) $(SDL_MIXERLIBS) $(GL_LIBS) $(CFLAGS) -lm
+ $(CC) menu.c $(LIB) -o menu $(GL_INCLUDES) $(SDL_LIBS) $(SDL_MIXERLIBS) $(GL_LIBS) $(CFLAGS) -lm
helloworld:
- gcc helloworld.c $(LIB) -o helloworld $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) $(SDL_LIBS) $(SDL_MIXERLIBS) -lm
+ $(CC) helloworld.c $(LIB) -o helloworld $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) $(SDL_LIBS) $(SDL_MIXERLIBS) -lm
model:
- gcc model.c $(LIB) -o model $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) $(SDL_LIBS) $(SDL_MIXERLIBS) -lm
+ $(CC) model.c $(LIB) -o model $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) $(SDL_LIBS) $(SDL_MIXERLIBS) -lm
gears:
- gcc gears.c $(LIB) -o gears $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) $(SDL_LIBS) $(SDL_MIXERLIBS) -lm
+ $(CC) gears.c $(LIB) -o gears $(GL_INCLUDES) $(GL_LIBS) $(CFLAGS) $(SDL_LIBS) $(SDL_MIXERLIBS) -lm
--- a/SDL_Examples/gears.c
+++ b/SDL_Examples/gears.c
@@ -374,6 +374,11 @@
if(!frameBuffer){printf("\nZB_open failed!");exit(1);}
glInit(frameBuffer);
+ //Print version info
+ printf("\nVersion string:\n%s",glGetString(GL_VERSION));
+ printf("\nVendor string:\n%s",glGetString(GL_VENDOR));
+ printf("\nRenderer string:\n%s",glGetString(GL_RENDERER));
+ printf("\nExtensions string:\n%s",glGetString(GL_EXTENSIONS));
// initialize GL:
glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, winSizeX, winSizeY);
--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -590,6 +590,7 @@
GL_CONSTANT_ALPHA_EXT = 0x8003,
GL_ONE_MINUS_CONSTANT_ALPHA_EXT = 0x8004,
GL_BLEND_EQUATION_EXT = 0x8009,
+ GL_BLEND_EQUATION = 0x8009,
GL_MIN_EXT = 0x8007,
GL_MAX_EXT = 0x8008,
GL_FUNC_ADD_EXT = 0x8006,
@@ -840,6 +841,7 @@
void glHint(GLint target,GLint mode);
void glGetIntegerv(GLint pname,GLint *params);
void glGetFloatv(GLint pname, GLfloat *v);
+const GLubyte* glGetString(GLenum name);
void glFrontFace(GLint mode);
/* opengl 1.2 arrays */
--- a/src/get.c
+++ b/src/get.c
@@ -4,6 +4,18 @@
GLContext* c = gl_get_context();
switch (pname) {
+ case GL_BLEND:
+ *params = c->zb->enable_blend;
+ break;
+ case GL_BLEND_DST:
+ *params = c->zb->dfactor;
+ break;
+ case GL_BLEND_SRC:
+ *params = c->zb->sfactor;
+ break;
+ case GL_BLEND_EQUATION:
+ *params = c->zb->blendeq;
+ break;
case GL_VIEWPORT:
params[0] = c->viewport.xmin;
params[1] = c->viewport.ymin;
@@ -16,6 +28,10 @@
case GL_MAX_PROJECTION_STACK_DEPTH:
*params = MAX_PROJECTION_STACK_DEPTH;
break;
+
+ case GL_CULL_FACE_MODE:
+ *params = c->current_cull_face;
+ break;
case GL_MAX_LIGHTS:
*params = MAX_LIGHTS;
break;
@@ -22,15 +38,108 @@
case GL_MAX_TEXTURE_SIZE:
*params = 256; /* not completely true, but... */
break;
+ case GL_CULL_FACE:
+ *params = c->cull_face_enabled;
+ break;
case GL_MAX_TEXTURE_STACK_DEPTH:
*params = MAX_TEXTURE_STACK_DEPTH;
break;
+ case GL_CURRENT_RASTER_POSITION_VALID:
+ *params = c->rasterposvalid;
+ break;
default:
- gl_fatal_error("glGet: option not implemented");
+ tgl_warning("glGet: option not implemented");
break;
}
}
+#define xstr(s) str(s)
+#define str(s) #s
+const GLubyte* vendor_string = (const GLubyte*)"Fabrice Bellard, Gek, and the C-Chads";
+const GLubyte* renderer_string = (const GLubyte*)"TinyGL v0.8, Maintainer: Gek (DMHSW)";
+const GLubyte* version_string = (const GLubyte*)""
+"0.8 TinyGLv0.8 "
+#ifdef __DATE__
+"Compiled on "
+__DATE__
+#ifdef __TIME__
+" at "
+__TIME__
+#endif
+#ifdef __GNUC__
+" using GCC "
+__VERSION__
+#endif
+#ifdef __TINYC__
+" using Tiny C Compiler "
+xstr(__TINYC__)
+#endif
+#ifdef _MSVC_VER
+" using the worst compiler on earth, M$VC"
+#endif
+#endif //Endof date.
+;
+const GLubyte* extensions_string = (const GLubyte*)"TGL_TEXTURE "
+"TGL_SMOOTHSHADING "
+"TGL_LIGHTING "
+#if TGL_FEATURE_ARRAYS == 1
+"TGL_FEATURE_ARRAYS "
+#endif
+#if TGL_FEATURE_DISPLAYLISTS == 1
+"TGL_FEATURE_DISPLAYLISTS "
+#endif
+#if TGL_FEATURE_LIT_TEXTURES == 1
+"TGL_FEATURE_LIT_TEXTURES "
+#endif
+
+#if TGL_FEATURE_POLYGON_OFFSET == 1
+"TGL_FEATURE_POLYGON_OFFSET "
+#endif
+
+#if TGL_FEATURE_POLYGON_STIPPLE == 1
+"TGL_FEATURE_POLYGON_STIPPLE "
+#endif
+
+
+#if TGL_FEATURE_NO_COPY_COLOR == 1
+"TGL_FEATURE_NO_COPY_COLOR "
+#endif
+
+
+#if TGL_FEATURE_BLEND == 1
+"TGL_FEATURE_BLEND "
+#endif
+
+#if TGL_FEATURE_NO_DRAW_COLOR == 1
+"TGL_FEATURE_NO_DRAW_COLOR "
+#endif
+
+#if TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR == 1
+"TGL_FEATURE_FORCE_CLEAR_NO_COPY_COLOR "
+#endif
+
+#if TGL_FEATURE_16_BITS == 1
+"TGL_FEATURE_16_BITS "
+#endif
+
+#if TGL_FEATURE_32_BITS == 1
+"TGL_FEATURE_32_BITS "
+#endif
+#if COMPILETIME_TINYGL_COMPAT_TEST == 1
+"TGL_COMPILETIME_TINYGL_COMPAT_TEST "
+#endif
+
+"TGL_SOFTWARE_ACCELERATED";
+const GLubyte* glGetString(GLenum name){
+ switch(name){
+ case GL_VENDOR: return vendor_string;
+ case GL_RENDERER: return renderer_string;
+ case GL_VERSION: return version_string;
+ case GL_EXTENSIONS: return extensions_string;
+ }
+ return (const GLubyte*)"Erroneous input to glGetString";
+}
+
void glGetFloatv(GLint pname, GLfloat* v) {
GLint i;
GLint mnr = 0; /* just a trick to return the correct matrix */
@@ -58,7 +167,7 @@
v[0] = v[1] = 1.0f;
break;
case GL_POINT_SIZE:
- *v = 1.0f;
+ *v = c->zb->pointsize;
break;
case GL_POINT_SIZE_RANGE:
v[0] = v[1] = 1.0f;
--- a/src/misc.c
+++ b/src/misc.c
@@ -131,9 +131,7 @@
if (code >= GL_LIGHT0 && code < GL_LIGHT0 + MAX_LIGHTS) {
gl_enable_disable_light(c, code - GL_LIGHT0, v);
} else {
- /*
- fpr_ntf(stderr,"glEnableDisable: 0x%X not supported.\n",code);
- */
+ tgl_warning("glEnableDisable: 0x%X not supported.\n",code);
}
break;
}
--- a/src/msghandling.c
+++ b/src/msghandling.c
@@ -1,7 +1,7 @@
#include "../include/GL/gl.h"
#include "zgl.h"
#include <stdarg.h>
-#include <stdio.h>
+//#include <stdio.h>
#define NDEBUG
#ifdef NDEBUG
--- a/src/zraster.c
+++ b/src/zraster.c
@@ -66,7 +66,7 @@
void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void* data){
- /* TODO */
+ /* TODO: Come up with a clever scheme for storing the data to avoid pointer dependency. */
#if TGL_FEATURE_RENDER_BITS == 32
if( type != GL_UNSIGNED_INT &&
type != GL_UNSIGNED_INT_8_8_8_8 )
@@ -100,13 +100,10 @@
if(!c->rasterposvalid) return;
GLint w = p[1].i;
GLint h = p[2].i;
-#if TGL_FEATURE_RENDER_BITS == 32
- unsigned int* d = p[3].p;
-#elif TGL_FEATURE_RENDER_BITS == 16
- unsigned short* d = p[3].p;
-#else
-#error "bad TGL_FEATURE_RENDER_BITS"
-#endif
+ V3 rastpos = c->rasterpos;
+ PIXEL* d = p[3].p;
+ PIXEL* targ = c->zb->pbuf;
+
/*GLint mult = textsize;
for (GLint i = 0; i < mult; i++)
for (GLint j = 0; j < mult; j++)