Skip to content
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
6 changes: 5 additions & 1 deletion example/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#ifdef NANOVG_GLEW
# include <GL/glew.h>
#endif
#include <GLFW/glfw3.h>
#ifdef DEMO_OPENGL
# include <GLFW/glfw3.h>
#endif
#include "nanovg.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
Expand Down Expand Up @@ -1212,6 +1214,7 @@ static void flipHorizontal(unsigned char* image, int w, int h, int stride)

void saveScreenShot(int w, int h, int premult, const char* name)
{
#ifdef DEMO_OPENGL
unsigned char* image = (unsigned char*)malloc(w*h*4);
if (image == NULL)
return;
Expand All @@ -1223,4 +1226,5 @@ void saveScreenShot(int w, int h, int premult, const char* name)
flipHorizontal(image, w, h, w*4);
stbi_write_png(name, w, h, 4, image, w*4);
free(image);
#endif
}
10 changes: 9 additions & 1 deletion example/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#ifdef NANOVG_GLEW
# include <GL/glew.h>
#endif
#include <GLFW/glfw3.h>
#ifdef DEMO_OPENGL
# include <GLFW/glfw3.h>
#endif
#include "nanovg.h"

#ifdef _MSC_VER
Expand Down Expand Up @@ -43,14 +45,17 @@ void startGPUTimer(GPUtimer* timer)
{
if (!timer->supported)
return;
#ifdef DEMO_OPENGL
glBeginQuery(GL_TIME_ELAPSED, timer->queries[timer->cur % GPU_QUERY_COUNT] );
timer->cur++;
#endif
}

int stopGPUTimer(GPUtimer* timer, float* times, int maxTimes)
{
NVG_NOTUSED(times);
NVG_NOTUSED(maxTimes);
#ifdef DEMO_OPENGL
GLint available = 1;
int n = 0;
if (!timer->supported)
Expand All @@ -71,6 +76,9 @@ int stopGPUTimer(GPUtimer* timer, float* times, int maxTimes)
}
}
return n;
#else
return 0;
#endif
}


Expand Down
9 changes: 7 additions & 2 deletions premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ solution "nanovg"

kind "ConsoleApp"
language "C"
defines { "DEMO_OPENGL" }
files { "example/example_gl2.c", "example/demo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down Expand Up @@ -55,6 +56,7 @@ solution "nanovg"
project "example_gl3"
kind "ConsoleApp"
language "C"
defines { "DEMO_OPENGL" }
files { "example/example_gl3.c", "example/demo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down Expand Up @@ -84,7 +86,7 @@ solution "nanovg"
project "example_gl2_msaa"
kind "ConsoleApp"
language "C"
defines { "DEMO_MSAA" }
defines { "DEMO_OPENGL", "DEMO_MSAA" }
files { "example/example_gl2.c", "example/demo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down Expand Up @@ -114,7 +116,7 @@ solution "nanovg"
project "example_gl3_msaa"
kind "ConsoleApp"
language "C"
defines { "DEMO_MSAA" }
defines { "DEMO_OPENGL", "DEMO_MSAA" }
files { "example/example_gl3.c", "example/demo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down Expand Up @@ -144,6 +146,7 @@ solution "nanovg"
project "example_fbo"
kind "ConsoleApp"
language "C"
defines { "DEMO_OPENGL" }
files { "example/example_fbo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down Expand Up @@ -172,6 +175,7 @@ solution "nanovg"
project "example_gles2"
kind "ConsoleApp"
language "C"
defines { "DEMO_OPENGL" }
files { "example/example_gles2.c", "example/demo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down Expand Up @@ -200,6 +204,7 @@ solution "nanovg"
project "example_gles3"
kind "ConsoleApp"
language "C"
defines { "DEMO_OPENGL" }
files { "example/example_gles3.c", "example/demo.c", "example/perf.c" }
includedirs { "src", "example" }
targetdir("build")
Expand Down