mk.persia
mk.persia

Reputation: 49

OpenGL auto code generator from a vector image

Is there any kind of application, tool, lib, ... that generates OpenGL functions from a vector image? To avoid any misunderstanding: I don't want to render something like an SVG file in my 2D OpenGL project, I want to create vector image in my favourite vector app and convert it to OpenGL code instead of create it by code. That will saves lots of time.

Upvotes: 2

Views: 2953

Answers (1)

Marcelo Cantos
Marcelo Cantos

Reputation: 186118

Don't generate OpenGL code. Store the vertex data in a form that's ready to load into a VBO. It's OK to generate code for the data — something like this:

struct { float position[3]; float texcoord[2]; float color[4]; } vertices[] =
{
    // Auto-gen code here...
    { {1, 1, 0}, {0, 1}, {1, 0, 1, 1} },
    ...
};

But you might find that it's just as easy (and faster to compile) if you memory map the data straight in from a binary data file. Of course, the code version has the advantage of living right inside your executable without having to mess around with app resources, which in turn has the disadvantage of not letting you change the vector image without a recompile.

Upvotes: 5

Related Questions