This commit is contained in:
John Alanbrook 2023-02-04 04:18:19 +00:00
parent bea49b5e64
commit 229e86a56a
6 changed files with 41 additions and 20 deletions

View file

@ -153,11 +153,10 @@ void duk_dump_stack(duk_context *duk)
duk_ret_t duk_gui_text(duk_context *duk) {
const char *s = duk_to_string(duk, 0);
cpVect pos = duk2vec2(duk, 1);
float fpos[2] = {pos.x, pos.y};
float size = duk_to_number(duk, 2);
const float white[3] = {1.f, 1.f, 1.f};
renderText(s, fpos, size, white, 1800);
renderText(s, &pos, size, white, 500);
return 0;
}

View file

@ -132,7 +132,6 @@ struct sFont *MakeFont(const char *fontfile, int height)
glBindTexture(GL_TEXTURE_2D, newfont->texID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, packsize, packsize, 0, GL_RED, GL_UNSIGNED_BYTE, bitmap);
//glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
@ -184,8 +183,10 @@ void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct
if (verts[5] < 0 || verts[10] < 0 || verts[0] > window_i(0)->width || verts[1] > window_i(0)->height)
return;
glBufferSubData(GL_ARRAY_BUFFER, curchar*sizeof(verts), sizeof(verts), verts);
// glBufferSubData(GL_ARRAY_BUFFER, curchar*sizeof(verts), sizeof(verts), verts);
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STREAM_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
curchar++;
}
@ -211,8 +212,6 @@ void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, len*16*sizeof(float), NULL, GL_STREAM_DRAW);
const unsigned char *line, *wordstart;
line = (unsigned char*)text;
@ -254,5 +253,5 @@ void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3
}
}
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4*curchar);
// glDrawArrays(GL_TRIANGLE_STRIP, 0, 4*2);
}

View file

@ -32,8 +32,6 @@ struct gameobject *id2go(int id) {
return &gameobjects[id];
}
int pos2gameobject(cpVect pos)
{
cpShape *hit = phys2d_query_pos(pos);

View file

@ -187,6 +187,7 @@ int main(int argc, char **args) {
window_all_handle_events();
framems[framei++] = elapsed;
if (framei == FPSBUF) framei = 0;
if (sim_play) {
@ -202,7 +203,31 @@ int main(int argc, char **args) {
}
}
renderlag += elapsed;
if (renderlag >= renderMS) {
renderlag -= renderMS;
window_renderall();
}
gameobjects_cleanup();
}
renderlag += elapsed;
if (renderlag >= renderMS) {
renderlag -= renderMS;
window_renderall();
}
gameobjects_cleanup();
}
renderlag += elapsed;
if (renderlag >= renderMS) {
renderlag -= renderMS;
window_renderall();
@ -222,7 +247,7 @@ int frame_fps()
fpsms += framems[i];
}
return floor((float)FPSBUF / fpsms);
return FPSBUF / fpsms;
}
int sim_playing() { return sim_play; }

View file

@ -10,6 +10,6 @@ void main()
//vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
//color = vec4(textColor, 1.0) * sampled;
color = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
//if (color.a <= 0.1f)
//discard;
/* if (color.a <= 0.1f)
discard;*/
}