Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GLES2 demo #590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions example/example_gles2.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "nanovg_gl.h"
#include "nanovg_gl_utils.h"
#include "demo.h"
#include "perf.h"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gles2 does not support API functionality used in perf.h - commented out for now

//#include "perf.h"


void errorcb(int error, const char* desc)
Expand Down Expand Up @@ -56,19 +56,20 @@ int main()
GLFWwindow* window;
DemoData data;
NVGcontext* vg = NULL;
PerfGraph fps;
//PerfGraph fps;
double prevt = 0;

if (!glfwInit()) {
printf("Failed to init GLFW.");
return -1;
}

initGraph(&fps, GRAPH_RENDER_FPS, "Frame Time");
//initGraph(&fps, GRAPH_RENDER_FPS, "Frame Time");

glfwSetErrorCallback(errorcb);

glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed by GLFW to use EGL on Windows (e.g. for Angle)

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

Expand All @@ -92,7 +93,7 @@ int main()
if (loadDemoData(vg, &data) == -1)
return -1;

glfwSwapInterval(0);
glfwSwapInterval(1);

glfwSetTime(0);
prevt = glfwGetTime();
Expand All @@ -107,7 +108,7 @@ int main()
t = glfwGetTime();
dt = t - prevt;
prevt = t;
updateGraph(&fps, dt);
//updateGraph(&fps, dt);

glfwGetCursorPos(window, &mx, &my);
glfwGetWindowSize(window, &winWidth, &winHeight);
Expand All @@ -131,7 +132,7 @@ int main()
nvgBeginFrame(vg, winWidth, winHeight, pxRatio);

renderDemo(vg, mx,my, winWidth,winHeight, t, blowup, &data);
renderGraph(vg, 5,5, &fps);
//renderGraph(vg, 5,5, &fps);

nvgEndFrame(vg);

Expand Down
2 changes: 1 addition & 1 deletion src/nanovg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string,
if (end == NULL)
end = string + strlen(string);

if (string == end)
if (string >= end)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cover the case that start is before end

return 0;

fonsSetSize(ctx->fs, state->fontSize*scale);
Expand Down