<commit_before>#include <stdlib.h>
#include <GL/glut.h>

#include "glchk.h"

#include "textab.h"

#define NDXT	(sizeof(dxt)/sizeof(*dxt))


static
void reshape (int w, int h)
{
	GLCHK(glViewport(0, 0, w, h));
	GLCHK(glMatrixMode(GL_PROJECTION));
	GLCHK(glLoadIdentity());
	GLCHK(glOrtho(-2*1.7, 2*1.7, 2, -2, -2, 2));
	GLCHK(glMatrixMode(GL_MODELVIEW));
	GLCHK(glLoadIdentity());
}


static float delta = 1.0;
static unsigned incdxt = 1;
static unsigned dxtidx = 0;
static unsigned phase;

#define NTEX	5
static GLuint texid[NTEX];

extern unsigned char firefox_mono_start[];
extern unsigned char nosmoking_start[], nosmoking_end[];

static
void display (void)
{
	int i;
	static GLfloat angle;
	unsigned char cmap[256 * 4];

	angle += delta;

	GLCHK(glShadeModel(GL_SMOOTH));

	GLCHK(glClear(GL_COLOR_BUFFER_BIT));

	GLCHK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
	GLCHK(glEnable(GL_BLEND));
	GLCHK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));


	for(i = 0; i < 256; i++) {
		unsigned p = i + phase;
		cmap[i*4+0] = p;
		cmap[i*4+1] = p+(256*1)/3;
		cmap[i*4+2] = p+(256*2)/3;
		cmap[i*4+3] = 255;
	}
	phase++;

	GLCHK(glBindTexture(GL_TEXTURE_2D, texid[4]));

	GLCHK(glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 128, 128, 0, 
				     dxt[dxtidx].end-dxt[dxtidx].start, dxt[dxtidx].start));
	dxtidx = (dxtidx+incdxt)%NDXT;

	GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
	GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));


	for(i = 0; i < NTEX; i++) {
		int x = i % 4;
		int y = i / 4;

		GLCHK(glMatrixMode(GL_MODELVIEW));
		GLCHK(glLoadIdentity());
		GLCHK(glTranslatef(1. * (x - 2), 1. * (y - .5), 0));
		GLCHK(glScalef(2,2,1));
		GLCHK(glRotatef(angle * 1.32f, 0.0f, 0.0f, 1.0f));
		GLCHK(glTranslatef(-.5, -.5, 0));

		GLCHK(glBindTexture(GL_TEXTURE_2D, texid[i]));

		if (i == 0)
			GLCHK(glColorTable(GL_TEXTURE_2D, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, cmap));

		glBegin(GL_TRIANGLE_FAN);
		  glColor3f(1, 0, 0);
		  glTexCoord2f(0, 0);
		  glVertex3f(0, 0, 0);

		  glColor3f(0, 1 ,0);
		  glTexCoord2f(0, 1);
		  glVertex3f(0, 1, 0);

		  glColor3f(0, 0, 1);
		  glTexCoord2f(1, 1);
		  glVertex3f(1, 1, 0);

		  glColor3f(1, 1, 1);
		  glTexCoord2f(1, 0);
		  glVertex3f(1, 0, 0);
		glEnd();
	}
#if SYS
	usleep(100000);
#endif
	glutSwapBuffers();
	glutPostRedisplay();
}


static
void keydown (unsigned char key, int x, int y)
{
	switch (key) {
	case 'd':			/* delta, triangle */
		break;
	case 'o':			/* round */
		delta = 0.0f;
		incdxt = 0;
		break;
	case 'q':			/* square*/
		break;
	case 'x':			/* cross button */<commit_msg>Add a time stats to idxtex<commit_after>#include <stdlib.h>
#include <GL/glut.h>

#include "glchk.h"

#include "textab.h"
#include "perfmeter.h"

#define NDXT	(sizeof(dxt)/sizeof(*dxt))


static
void reshape (int w, int h)
{
	GLCHK(glViewport(0, 0, w, h));
	GLCHK(glMatrixMode(GL_PROJECTION));
	GLCHK(glLoadIdentity());
	GLCHK(glOrtho(-2*1.7, 2*1.7, 2, -2, -2, 2));
	GLCHK(glMatrixMode(GL_MODELVIEW));
	GLCHK(glLoadIdentity());
}


static float delta = 1.0;
static unsigned incdxt = 1;
static unsigned dxtidx = 0;
static unsigned phase;

#define NTEX	5
static GLuint texid[NTEX];

extern unsigned char firefox_mono_start[];
extern unsigned char nosmoking_start[], nosmoking_end[];

static
void display (void)
{
	int i;
	static GLfloat angle;
	unsigned char cmap[256 * 4];

	angle += delta;

	pm_framestart();

	GLCHK(glShadeModel(GL_SMOOTH));

	GLCHK(glClear(GL_COLOR_BUFFER_BIT));

	GLCHK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
	GLCHK(glEnable(GL_BLEND));
	GLCHK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));


	for(i = 0; i < 256; i++) {
		unsigned p = i + phase;
		cmap[i*4+0] = p;
		cmap[i*4+1] = p+(256*1)/3;
		cmap[i*4+2] = p+(256*2)/3;
		cmap[i*4+3] = 255;
	}
	phase++;

	GLCHK(glBindTexture(GL_TEXTURE_2D, texid[4]));

	GLCHK(glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 128, 128, 0, 
				     dxt[dxtidx].end-dxt[dxtidx].start, dxt[dxtidx].start));
	dxtidx = (dxtidx+incdxt)%NDXT;

	GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
	GLCHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));


	for(i = 0; i < NTEX; i++) {
		int x = i % 4;
		int y = i / 4;

		GLCHK(glMatrixMode(GL_MODELVIEW));
		GLCHK(glLoadIdentity());
		GLCHK(glTranslatef(1. * (x - 2), 1. * (y - .5), 0));
		GLCHK(glScalef(2,2,1));
		GLCHK(glRotatef(angle * 1.32f, 0.0f, 0.0f, 1.0f));
		GLCHK(glTranslatef(-.5, -.5, 0));

		GLCHK(glBindTexture(GL_TEXTURE_2D, texid[i]));

		if (i == 0)
			GLCHK(glColorTable(GL_TEXTURE_2D, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, cmap));

		glBegin(GL_TRIANGLE_FAN);
		  glColor3f(1, 0, 0);
		  glTexCoord2f(0, 0);
		  glVertex3f(0, 0, 0);

		  glColor3f(0, 1 ,0);
		  glTexCoord2f(0, 1);
		  glVertex3f(0, 1, 0);

		  glColor3f(0, 0, 1);
		  glTexCoord2f(1, 1);
		  glVertex3f(1, 1, 0);

		  glColor3f(1, 1, 1);
		  glTexCoord2f(1, 0);
		  glVertex3f(1, 0, 0);
		glEnd();
	}
#if SYS
	usleep(100000);
#endif

	pm_frameend();

	glutSwapBuffers();
	glutPostRedisplay();
}


static
void keydown (unsigned char key, int x, int y)
{
	switch (key) {
	case 'd':			/* delta, triangle */
		break;
	case 'o':			/* round */
		delta = 0.0f;
		incdxt = 0;
		break;
	case 'q':			/* square*/
		break;
	case 'x':			/* cross button */
{'fraction_non_alphanumeric': 0.1713436164281732, 'fraction_numerical': 0.053521650250882735, 'mean_word_length': 4.328712871287129, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3985634', 'n_tokens_mistral': 2842, 'n_tokens_neox': 2502, 'n_words': 481}