Fix memory leak in demo and example code.
Clear cmds nk_buffer after each frame to stop it growing over time.
This commit is contained in:
parent
05edc452af
commit
9818f642da
@ -161,7 +161,8 @@ nk_d3d11_render(ID3D11DeviceContext *context, enum nk_anti_aliasing AA)
|
||||
ID3D11DeviceContext_DrawIndexed(context, (UINT)cmd->elem_count, offset, 0);
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&d3d11.ctx);}
|
||||
nk_clear(&d3d11.ctx);
|
||||
nk_buffer_clear(&d3d11.cmds);}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -190,6 +190,7 @@ nk_d3d9_render(enum nk_anti_aliasing AA)
|
||||
}
|
||||
|
||||
nk_clear(&d3d9.ctx);
|
||||
nk_buffer_clear(&d3d9.cmds);
|
||||
|
||||
IDirect3DStateBlock9_Apply(d3d9.state);
|
||||
IDirect3DStateBlock9_Release(d3d9.state);
|
||||
|
@ -174,6 +174,7 @@ nk_glfw3_render(enum nk_anti_aliasing AA)
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&glfw.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
nk_buffer_free(&vbuf);
|
||||
nk_buffer_free(&ebuf);
|
||||
}
|
||||
|
@ -295,6 +295,7 @@ nk_glfw3_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&glfw.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
/* default OpenGL state */
|
||||
|
@ -446,6 +446,7 @@ nk_glfw3_render(enum nk_anti_aliasing AA)
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&glfw.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
/* default OpenGL state */
|
||||
glUseProgram(0);
|
||||
|
@ -154,6 +154,7 @@ nk_sdl_render(enum nk_anti_aliasing AA)
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&sdl.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
nk_buffer_free(&vbuf);
|
||||
nk_buffer_free(&ebuf);
|
||||
}
|
||||
|
@ -275,6 +275,7 @@ nk_sdl_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&sdl.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
glUseProgram(0);
|
||||
|
@ -276,6 +276,7 @@ nk_sdl_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&sdl.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
glUseProgram(0);
|
||||
|
@ -152,6 +152,7 @@ nk_sfml_render(enum nk_anti_aliasing AA)
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&sfml.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
nk_buffer_free(&vbuf);
|
||||
nk_buffer_free(&ebuf);
|
||||
}
|
||||
|
@ -279,6 +279,7 @@ nk_sfml_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&sfml.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
glUseProgram(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
@ -184,6 +184,7 @@ nk_x11_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&x11.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
nk_buffer_free(&vbuf);
|
||||
nk_buffer_free(&ebuf);
|
||||
}
|
||||
|
@ -566,6 +566,7 @@ nk_x11_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(&x11.ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
/* default OpenGL state */
|
||||
|
@ -293,6 +293,7 @@ device_draw(struct device *dev, struct nk_context *ctx, int width, int height,
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
/* default OpenGL state */
|
||||
|
@ -717,6 +717,7 @@ device_draw(struct device *dev, struct nk_context *ctx, int width, int height,
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
/* default OpenGL state */
|
||||
|
@ -747,6 +747,7 @@ device_draw(struct device *dev, struct nk_context *ctx, int width, int height,
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
/* default OpenGL state */
|
||||
|
@ -317,6 +317,7 @@ device_draw(struct device *dev, struct nk_context *ctx, int width, int height,
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(ctx);
|
||||
nk_buffer_clear(&dev->cmds);
|
||||
}
|
||||
|
||||
/* default OpenGL state */
|
||||
|
Loading…
Reference in New Issue
Block a user