ref: 7a5e0254da444c2f3eb38872b5549042839f0f1f
parent: 8c3305a219d4ed99a13dd49ea86c67204d0df1af
author: David <gek@katherine>
date: Thu Feb 18 16:30:44 EST 2021
glDrawPixels implemented
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
Copyright notice:
- (C) 1997-2020 Fabrice Bellard, C-Chads
+ (C) 1997-2020 Fabrice Bellard, Gek (DMHSW), C-Chads
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -20,5 +20,3 @@
If you redistribute modified sources, I would appreciate that you
include in the files history information documenting your changes.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Version: TinyGL 0.8-CCHADS
--- a/README.md
+++ b/README.md
@@ -69,6 +69,14 @@
* ADDED BLENDING SUPPORT!
+* Added glDrawPixels
+
+* Added glPixelZoom
+
+* Added glRasterPos2f,3f,4f,2fv,3fv,4fv
+
+* Added glGetString() for GL_VENDOR, GL_RENDERER, GL_VERSION, and GL_LICENSE
+
* Fixed a myriad of bugs and... weirdnesses
--- a/SDL_Examples/gears.c
+++ b/SDL_Examples/gears.c
@@ -379,6 +379,7 @@
printf("\nVendor string:\n%s",glGetString(GL_VENDOR));
printf("\nRenderer string:\n%s",glGetString(GL_RENDERER));
printf("\nExtensions string:\n%s",glGetString(GL_EXTENSIONS));
+ printf("\nLicense string:\n%s",glGetString(GL_LICENSE));
// initialize GL:
glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, winSizeX, winSizeY);
--- a/SDL_Examples/texture.c
+++ b/SDL_Examples/texture.c
@@ -1,8 +1,7 @@
-/* sdlGears.c */
+/* texture.c */
/*
- * 3-D gear wheels by Brian Paul. This program is in the public domain.
- *
- * ported to libSDL/TinyGL by Gerald Franz (gfz@o2online.de)
+ * Texture test written by Gek
+ *
*/
//#define PLAY_MUSIC
@@ -239,6 +238,16 @@
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
draw();
glDrawText((unsigned char*)"\nBlitting text\nto the screen!", 0, 0, 0x000000FF);
+ glPixelZoom(0.5,1);
+ glRasterPos2f(-1,-1);
+ {
+ GLint xsize, ysize;
+ void* data = glGetTexturePixmap(tex, 0, &xsize, &ysize);
+ if(data)
+ glDrawPixels(xsize,ysize, GL_RGB,
+ (TGL_FEATURE_RENDER_BITS==32)?GL_UNSIGNED_INT:GL_UNSIGNED_SHORT, data
+ );
+ }
// swap buffers:
if (SDL_MUSTLOCK(screen) && (SDL_LockSurface(screen) < 0)) {
fprintf(stderr, "SDL ERROR: Can't lock screen: %s\n", SDL_GetError());
--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -572,6 +572,7 @@
GL_RENDERER = 0x1F01,
GL_VERSION = 0x1F02,
GL_EXTENSIONS = 0x1F03,
+ GL_LICENSE = 0x1F04,
/* Errors */
GL_INVALID_VALUE = 0x0501,
@@ -875,7 +876,7 @@
void glRasterPos3fv(GLfloat* v);
void glRasterPos4fv(GLfloat* v);
void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void* data);
-
+void glPixelZoom(GLfloat x, GLfloat y);
/* not implemented, just added to compile */
/*
inline void glPointSize(GLfloat) {}
--- a/include/zfeatures.h
+++ b/include/zfeatures.h
@@ -31,27 +31,7 @@
#define TGL_COLOR_MASK 0x00ffffff
//^ mask to check for while drawing/copying.
-/*
- * Matrix of internal and external pixel formats supported. 'Y' means
- * supported.
- *
- * External 8 16 24 32
- * Internal
- * 15 . . . .
- * 16 . Y . .
- * 24 . . . . (Stupid and pointless)
- * 32 . . . Y
- *
- *
- * 15 bpp does not work yet (although it is easy to add it - ask me if
- * you need it).
- *
- * Internal pixel format: see TGL_FEATURE_RENDER_BITS
- * External pixel format: see TGL_FEATURE_xxx_BITS
- */
-/* enable various convertion code from internal pixel format (usually
- 16 bits per pixel) to any external format */
#define TGL_FEATURE_8_BITS 0
#define TGL_FEATURE_24_BITS 0
//These are the only maintained modes.
--- a/src/get.c
+++ b/src/get.c
@@ -54,6 +54,32 @@
}
#define xstr(s) str(s)
#define str(s) #s
+
+const GLubyte* license_string = (const GLubyte*)""
+"Copyright notice:\n"
+"\n"
+" (C) 1997-2021 Fabrice Bellard, Gek (DMHSW), C-Chads\n"
+"\n"
+" This software is provided 'as-is', without any express or implied\n"
+" warranty. In no event will the authors be held liable for any damages\n"
+" arising from the use of this software.\n"
+"\n"
+" Permission is granted to anyone to use this software for any purpose,\n"
+" including commercial applications, and to alter it and redistribute it\n"
+" freely, subject to the following restrictions:\n"
+"\n"
+" 1. The origin of this software must not be misrepresented; you must not\n"
+" claim that you wrote the original software. If you use this software\n"
+" in a product, an acknowledgment in the product and its documentation \n"
+" *is* required.\n"
+" 2. Altered source versions must be plainly marked as such, and must not be\n"
+" misrepresented as being the original software.\n"
+" 3. This notice may not be removed or altered from any source distribution.\n"
+"\n"
+"If you redistribute modified sources, I would appreciate that you\n"
+"include in the files history information documenting your changes.";
+
+
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*)""
@@ -136,6 +162,7 @@
case GL_RENDERER: return renderer_string;
case GL_VERSION: return version_string;
case GL_EXTENSIONS: return extensions_string;
+ case GL_LICENSE: return license_string;
}
return (const GLubyte*)"Erroneous input to glGetString";
}
@@ -168,6 +195,12 @@
break;
case GL_POINT_SIZE:
*v = c->zb->pointsize;
+ break;
+ case GL_ZOOM_X:
+ *v = c->pzoomx;
+ break;
+ case GL_ZOOM_Y:
+ *v = c->pzoomy;
break;
case GL_POINT_SIZE_RANGE:
v[0] = v[1] = 1.0f;
--- a/src/zraster.c
+++ b/src/zraster.c
@@ -40,7 +40,7 @@
v.coord.Z = p[3].f;
v.coord.W = p[4].f;
gl_vertex_transform_raster(c, &v);
- if (v.clip_code == 0)
+// if (v.clip_code == 0)
{
{
GLfloat winv = 1.0 / v.pc.W;
@@ -53,8 +53,8 @@
c->rasterpos.v[2] = v.zp.z;
c->rasterposvalid = 1;
}
- else
- c->rasterposvalid = 0;
+// else
+// c->rasterposvalid = 0;
}
void glRasterPos2f(GLfloat x, GLfloat y){glRasterPos4f(x,y,0,1);}
@@ -95,6 +95,7 @@
p[3].p = data;
gl_add_op(p);
}
+#define CLIPTEST(_x,_y,_w,_h)((0<=_x) && (_w>_x) && (0<=_y) && (_h>_y))
void glopDrawPixels(GLContext* c, GLParam* p){
// p[3]
if(!c->rasterposvalid) return;
@@ -102,8 +103,28 @@
GLint h = p[2].i;
V3 rastpos = c->rasterpos;
PIXEL* d = p[3].p;
- PIXEL* targ = c->zb->pbuf;
-
+ PIXEL* pbuf = c->zb->pbuf;
+ GLint tw = c->zb->xsize;
+ GLint th = c->zb->ysize;
+ GLfloat pzoomx = c->pzoomx;
+ GLfloat pzoomy = c->pzoomy;
+ V4 rastoffset;
+ rastoffset.v[0] = rastpos.v[0];
+ rastoffset.v[1] = rastpos.v[1];
+ //Looping over the source pixels.
+ for(GLint sx = 0; sx < w; sx++)
+ for(GLint sy = 0; sy < h; sy++)
+ {
+ PIXEL col = d[sy*w+sx];
+ rastoffset.v[0] = rastpos.v[0] + (GLfloat)sx * pzoomx;
+ rastoffset.v[1] = rastpos.v[1] - ((GLfloat)(h-sy) * pzoomy);
+ rastoffset.v[2] = rastoffset.v[0] + pzoomx;
+ rastoffset.v[3] = rastoffset.v[1] - pzoomy;
+ for(GLint tx = rastoffset.v[0]; (GLfloat)tx < rastoffset.v[2];tx++)
+ for(GLint ty = rastoffset.v[1]; (GLfloat)ty > rastoffset.v[3];ty--)
+ if(CLIPTEST(tx,ty,tw,th))
+ pbuf[tx+ty*tw] = col;
+ }
/*GLint mult = textsize;
for (GLint i = 0; i < mult; i++)
for (GLint j = 0; j < mult; j++)
@@ -124,5 +145,5 @@
void glopPixelZoom(GLContext* c, GLParam* p){
c->pzoomx = p[1].f;
- c->pzoomx = p[2].f;
+ c->pzoomy = p[2].f;
}