Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm writing a framework in Haskell where I'd like to use OpenGL to draw lines, shapes... I'm encountering a problem defining the structure of my program. I have for example a Polyline type which holds a list of points and to draw it I need to make a VAO with OpenGL.

My question is how can I design my program to associate a Polyline with its OpenGL representation?

For example, I first defined my polyline like this:

data Polyline = Polyline { points :: [Point], vao :: Vao }

I hide the implementation of Polyline and I use a constructor polyline :: Polyline and functions like addPoints :: [Point] -> Polyline -> Polyline to modify it.

But if I use my polyline in the rendering loop, a new VAO is created at each iteration. How can I avoid this? And how can I decouple a Polyline from the VAO containing its points?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.