Browse Source

Improve VC support

shared-context
Caleb Gingles 11 years ago
parent
commit
fbdc947802
3 changed files with 12 additions and 9 deletions
  1. +2
    -1
      example/demo.c
  2. +6
    -4
      example/perf.c
  3. +4
    -4
      src/nanovg_gl2.h

+ 2
- 1
example/demo.c View File

@@ -491,6 +491,7 @@ void drawThumbnails(struct NVGcontext* vg, float x, float y, float w, float h, c
float stackh = (nimages/2) * (thumb+10) + 10;
int i;
float u = (1+cosf(t*0.5f))*0.5f;
float scrollh;

nvgSave(vg);
// nvgClearState(vg);
@@ -578,7 +579,7 @@ void drawThumbnails(struct NVGcontext* vg, float x, float y, float w, float h, c
// nvgFillColor(vg, nvgRGBA(255,0,0,128));
nvgFill(vg);

float scrollh = (h/stackh) * (h-8);
scrollh = (h/stackh) * (h-8);
shadowPaint = nvgBoxGradient(vg, x+w-12-1,y+4+(h-8-scrollh)*u-1, 8,scrollh, 3,4, nvgRGBA(220,220,220,255), nvgRGBA(128,128,128,255));
nvgBeginPath(vg);
nvgRoundedRect(vg, x+w-12+1,y+4+1 + (h-8-scrollh)*u, 8-2,scrollh-2, 2);


+ 6
- 4
example/perf.c View File

@@ -116,17 +116,19 @@ void renderGraph(struct NVGcontext* vg, float x, float y, struct PerfGraph* fps)
if (fps->style == GRAPH_RENDER_FPS) {
for (i = 0; i < GRAPH_HISTORY_COUNT; i++) {
float v = 1.0f / (0.00001f + fps->values[(fps->head+i) % GRAPH_HISTORY_COUNT]);
float vx, vy;
if (v > 80.0f) v = 80.0f;
float vx = x + ((float)i/(GRAPH_HISTORY_COUNT-1)) * w;
float vy = y + h - ((v / 80.0f) * h);
vx = x + ((float)i/(GRAPH_HISTORY_COUNT-1)) * w;
vy = y + h - ((v / 80.0f) * h);
nvgLineTo(vg, vx, vy);
}
} else {
for (i = 0; i < GRAPH_HISTORY_COUNT; i++) {
float v = fps->values[(fps->head+i) % GRAPH_HISTORY_COUNT] * 1000.0f;
float vx, vy;
if (v > 20.0f) v = 20.0f;
float vx = x + ((float)i/(GRAPH_HISTORY_COUNT-1)) * w;
float vy = y + h - ((v / 20.0f) * h);
vx = x + ((float)i/(GRAPH_HISTORY_COUNT-1)) * w;
vy = y + h - ((v / 20.0f) * h);
nvgLineTo(vg, vx, vy);
}
}


+ 4
- 4
src/nanovg_gl2.h View File

@@ -720,6 +720,10 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis
glDisableVertexAttribArray(1);

} else {
float quad[6*2] = {
bounds[0], bounds[3], bounds[2], bounds[3], bounds[2], bounds[1],
bounds[0], bounds[3], bounds[2], bounds[1], bounds[0], bounds[1],
};

glEnable(GL_CULL_FACE);

@@ -782,10 +786,6 @@ static void glnvg__renderFill(void* uptr, struct NVGpaint* paint, struct NVGscis

glDisableVertexAttribArray(1);

float quad[6*2] = {
bounds[0], bounds[3], bounds[2], bounds[3], bounds[2], bounds[1],
bounds[0], bounds[3], bounds[2], bounds[1], bounds[0], bounds[1],
};
glBufferSubData(GL_ARRAY_BUFFER, 0, 6 * 2*sizeof(float), quad);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2*sizeof(float), (const GLvoid*)0);
glVertexAttrib2f(1, 0.5f, 1.0f);


Loading…
Cancel
Save