lll
This commit is contained in:
parent
bea49b5e64
commit
229e86a56a
|
@ -153,11 +153,10 @@ void duk_dump_stack(duk_context *duk)
|
||||||
duk_ret_t duk_gui_text(duk_context *duk) {
|
duk_ret_t duk_gui_text(duk_context *duk) {
|
||||||
const char *s = duk_to_string(duk, 0);
|
const char *s = duk_to_string(duk, 0);
|
||||||
cpVect pos = duk2vec2(duk, 1);
|
cpVect pos = duk2vec2(duk, 1);
|
||||||
float fpos[2] = {pos.x, pos.y};
|
|
||||||
|
|
||||||
float size = duk_to_number(duk, 2);
|
float size = duk_to_number(duk, 2);
|
||||||
const float white[3] = {1.f, 1.f, 1.f};
|
const float white[3] = {1.f, 1.f, 1.f};
|
||||||
renderText(s, fpos, size, white, 1800);
|
renderText(s, &pos, size, white, 500);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,6 @@ struct sFont *MakeFont(const char *fontfile, int height)
|
||||||
glBindTexture(GL_TEXTURE_2D, newfont->texID);
|
glBindTexture(GL_TEXTURE_2D, newfont->texID);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, packsize, packsize, 0, GL_RED, GL_UNSIGNED_BYTE, bitmap);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, packsize, packsize, 0, GL_RED, GL_UNSIGNED_BYTE, bitmap);
|
||||||
|
|
||||||
|
|
||||||
//glGenerateMipmap(GL_TEXTURE_2D);
|
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
@ -179,13 +178,15 @@ void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct
|
||||||
xpos, ypos + h, c.rect.s0, c.rect.t0,
|
xpos, ypos + h, c.rect.s0, c.rect.t0,
|
||||||
xpos + w, ypos + h, c.rect.s1, c.rect.t0
|
xpos + w, ypos + h, c.rect.s1, c.rect.t0
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Check if the vertex is off screen */
|
/* Check if the vertex is off screen */
|
||||||
if (verts[5] < 0 || verts[10] < 0 || verts[0] > window_i(0)->width || verts[1] > window_i(0)->height)
|
if (verts[5] < 0 || verts[10] < 0 || verts[0] > window_i(0)->width || verts[1] > window_i(0)->height)
|
||||||
return;
|
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++;
|
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);
|
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, len*16*sizeof(float), NULL, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, len*16*sizeof(float), NULL, GL_STREAM_DRAW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const unsigned char *line, *wordstart;
|
const unsigned char *line, *wordstart;
|
||||||
line = (unsigned char*)text;
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,6 @@ struct gameobject *id2go(int id) {
|
||||||
return &gameobjects[id];
|
return &gameobjects[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int pos2gameobject(cpVect pos)
|
int pos2gameobject(cpVect pos)
|
||||||
{
|
{
|
||||||
cpShape *hit = phys2d_query_pos(pos);
|
cpShape *hit = phys2d_query_pos(pos);
|
||||||
|
|
|
@ -187,7 +187,8 @@ int main(int argc, char **args) {
|
||||||
window_all_handle_events();
|
window_all_handle_events();
|
||||||
|
|
||||||
framems[framei++] = elapsed;
|
framems[framei++] = elapsed;
|
||||||
if (framei == FPSBUF) framei = 0;
|
|
||||||
|
if (framei == FPSBUF) framei = 0;
|
||||||
|
|
||||||
if (sim_play) {
|
if (sim_play) {
|
||||||
timer_update(elapsed);
|
timer_update(elapsed);
|
||||||
|
@ -202,7 +203,31 @@ int main(int argc, char **args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renderlag += elapsed;
|
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) {
|
if (renderlag >= renderMS) {
|
||||||
renderlag -= renderMS;
|
renderlag -= renderMS;
|
||||||
window_renderall();
|
window_renderall();
|
||||||
|
@ -218,11 +243,11 @@ int main(int argc, char **args) {
|
||||||
int frame_fps()
|
int frame_fps()
|
||||||
{
|
{
|
||||||
double fpsms = 0;
|
double fpsms = 0;
|
||||||
for (int i = 0; i < FPSBUF; i++) {
|
for (int i = 0; i < FPSBUF; i++) {
|
||||||
fpsms += framems[i];
|
fpsms += framems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return floor((float)FPSBUF / fpsms);
|
return FPSBUF / fpsms;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sim_playing() { return sim_play; }
|
int sim_playing() { return sim_play; }
|
||||||
|
|
|
@ -10,6 +10,6 @@ void main()
|
||||||
//vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
|
//vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
|
||||||
//color = vec4(textColor, 1.0) * sampled;
|
//color = vec4(textColor, 1.0) * sampled;
|
||||||
color = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
|
color = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
|
||||||
//if (color.a <= 0.1f)
|
/* if (color.a <= 0.1f)
|
||||||
//discard;
|
discard;*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,4 @@ void main()
|
||||||
{
|
{
|
||||||
gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);
|
gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);
|
||||||
TexCoords = vertex.zw;
|
TexCoords = vertex.zw;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue