Here is a simple example. On my machine I see memory usage steadily increasing over time.
Deleted first example in favour of this one. This may be a problem with AppGameKit itself as I see a similar memory usage increase when I run the equivalent code in appgamekit directly.
using System;
using AgkSharp;
using AGKCore;
namespace ErrorDemo2
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Core.CreateWin32Window("AGK-Title", 640, 480, false);
if (!Core.InitAGK())
return;
Agk.SetVirtualResolution(320, 480);
// Calculate the number o
int NumVertices =3;
int NumTriangles = 1;
int VertexSize = 36; // Size of a vertex = 8 floats x 4 bytes = 32 bytes + 4 byte color x,y,z,nx,ny,nz,u,v,rgba
// calculate the size of memblock we will need
int VertexOffset = 72;// 24 + 36;
int IndexOffset = VertexOffset + (NumVertices * VertexSize);
int MemSize = IndexOffset + (NumTriangles * 4 * 3);
// create the memblock
uint msblk = Agk.CreateMemblock((uint)MemSize);
// Start filling it up with relevant info
Agk.SetMemblockInt(msblk, 0, 3);
Agk.SetMemblockInt(msblk, 4, 1 * 3);
Agk.SetMemblockInt(msblk, 8, 4); // number of attributes (3)
Agk.SetMemblockInt(msblk, 12, VertexSize); // Bytes per vertex (32)
Agk.SetMemblockInt(msblk, 16, VertexOffset); // should be (60)
Agk.SetMemblockInt(msblk, 20, IndexOffset); // varies
// Set the attribute Data
// VERTEX ATTRIBUTES
Agk.SetMemblockByte(msblk, 24, 0); // float
Agk.SetMemblockByte(msblk, 25, 3); // component count
Agk.SetMemblockByte(msblk, 26, 0); // normalize
Agk.SetMemblockByte(msblk, 27, 12); // string length
Agk.SetMemblockString(msblk, 28, "position");
// NORMALS ATTRIBUTES
Agk.SetMemblockByte(msblk, 40, 0); // float
Agk.SetMemblockByte(msblk, 41, 3); // component count
Agk.SetMemblockByte(msblk, 42, 0); // normalize
Agk.SetMemblockByte(msblk, 43, 8); // string length
Agk.SetMemblockString(msblk, 44, "normal");
// UV ATTRIBUTES
Agk.SetMemblockByte(msblk, 52, 0); // float
Agk.SetMemblockByte(msblk, 53, 2); // component count
Agk.SetMemblockByte(msblk, 54, 0); // normalize
Agk.SetMemblockByte(msblk, 55, 4); // string length
Agk.SetMemblockString(msblk, 56, "uv");
//// COLOUR ATTRIBUTES
Agk.SetMemblockByte(msblk, 60, 1); // int
Agk.SetMemblockByte(msblk, 61, 4); // component count
Agk.SetMemblockByte(msblk, 62, 1); // normalize
Agk.SetMemblockByte(msblk, 63, 8); // string length
Agk.SetMemblockString(msblk, 64, "color");
int red = 0;
int green = 0;
int blue = 0;
int alpha = 0;
while (Core.LoopAGK() && Agk.GetRawKeyState(27) !=1)
{
for (uint i = 0; i < 3; i++)
{
red = Agk.GetMeshMemblockVertexRed(msblk, i);
green = Agk.GetMeshMemblockVertexGreen(msblk, i);
blue = Agk.GetMeshMemblockVertexBlue(msblk, i);
alpha = Agk.GetMeshMemblockVertexAlpha(msblk, i);
}
Agk.Sync();
}
Core.CleanUp();
}
}
}