ref: 8ef11f40e6f394aa471d57a048737d8dca24eac8
parent: 546bda8d302bad8045a09de766fd66616db084de
author: David <gek@katherine>
date: Thu Feb 11 13:49:24 EST 2021
Now added the ability to RESIZE text you render!
--- a/src/SDL_Examples/gears.c
+++ b/src/SDL_Examples/gears.c
@@ -188,7 +188,7 @@
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
glEnable( GL_DEPTH_TEST );
-
+ glTextSize(GL_TEXT_SIZE16x16);
/* make the gears */
gear1 = glGenLists(1);
glNewList(gear1, GL_COMPILE);
--- a/src/include/GL/gl.h
+++ b/src/include/GL/gl.h
@@ -633,6 +633,16 @@
};
+typedef enum {
+ GL_TEXT_SIZE8x8 = 1,
+ GL_TEXT_SIZE16x16 = 2,
+ GL_TEXT_SIZE24x24 = 3,
+ GL_TEXT_SIZE32x32 = 4,
+ GL_TEXT_SIZE40x40 = 5,
+ GL_TEXT_SIZE48x48 = 6,
+ GL_TEXT_SIZE56x56 = 7,
+ GL_TEXT_SIZE64x64 = 8
+} GLTEXTSIZE;
enum {
GL_CURRENT_BIT = 0x00000001,
GL_POINT_BIT = 0x00000002,
@@ -689,6 +699,7 @@
void glSetEnableSpecular(int s); //Toggle specular rendering (Speedup!!!)
void* glGetTexturePixmap(int text, int level, int* xsize, int* ysize); //Get the raw data of a texture!
void glDrawText(const unsigned char* text, int x, int y, unsigned int pixel); //Blit 8x8 text to he screen
+void glTextSize(GLTEXTSIZE mode); //Set text size
void glPlotPixel(int x, int y, unsigned int pixel); //plot a pixel to the screen.
#define PROTO_GL1(name) \
--- a/src/ztext.c
+++ b/src/ztext.c
@@ -6,15 +6,21 @@
#include "include/GL/gl.h"
#include "zgl.h"
#include "font8x8_basic.h"
+GLTEXTSIZE textsize;
+
+void glTextSize(GLTEXTSIZE mode){textsize = mode;}//Set text size
void renderchar(char *bitmap, int _x, int _y, PIXEL p) {
int x,y;
int set;
//int mask;
+ int mult = textsize;
for (x=0; x < 8; x++) {
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
if(set)
- glPlotPixel(y + _x, x + _y, p);
+ for(int i = 0; i < mult; i++)
+ for(int j = 0; j < mult; j++)
+ glPlotPixel(y*mult + i + _x, x*mult + j + _y, p);
}
}
}
@@ -33,14 +39,15 @@
int h = gl_get_context()->zb->ysize;
int xoff = 0;
int yoff = 0;
+ int mult = textsize;
for(int i = 0; text[i] != '\0' && y+7 < h; i++){
if(text[i] != '\n' && text[i] < 127 && xoff+x < w)
{
renderchar(font8x8_basic[text[i]],x+xoff,y+yoff, p);
- xoff+=8;
+ xoff+=8*mult;
}else if(text[i] == '\n'){
xoff=0;
- yoff+=8;
+ yoff+=8*mult;
}
}
}