Rewriting a simple Pygame 2D drawing function in C++ -


I have a list of 2D vectors (say 20x20 / 400 points) and I want to put these points on one screen like this Dragging: For the line in the grid,

 : for the row in point: pygame.draw.circle (window, white, (particle.x, particle.y), 2, 0) Pygame.display.flip () #REDRO to the screen  

It works perfectly, but it is very slow I hope.

I want to rewrite it in C ++ and hopefully some stuff is doing a unit on C ++ ATM, this will help in this way. What is the easiest way to approach this approach ? I have seen Direct X, and so far have followed a set of tutorials and pulled some basic triangles. Even though I can not find a simple dot point.

DirectX does not have a function for drawing, only one point is running on top and index buffers . If you just want an easy way to make a point, then you have to write a cover.
You will need to use DropPrintive (, ...) to draw points lists. However, there will be no easy way to plot just one point. You have to prepare the buffer, lock it, fill it with data, then drag the buffer. Or you can use dynamic vertical buffers - there is a DrawPrimitiveUP call to customize the display that should be able to render the primitive stored in system memory (instead of using buffers), but as far as I know It does not work (can quietly abandon the antique), so you will have to use software vertex processing.

In OpenGL you have more glVertex3f your call will look like this (no typo or syntax error - I have not compiled / run it):

  glBegin ( GL_POINTS); GlColor3f (1.0, 1.0, 1.0); (Int x = 0; x & lt; width; x ++) glVertex2f (number [or] [x] X, for the number of (for int y = 0; y & lt; height; y ++) Or] [x] .y); // Plot Point Glend ();  

Compared to OpenGL DirectX, it is easy to play around and use. I would recommend it to see, and used it together with OpenGL. Or you can use GLUT instead of SDL.

Or can you try to use QT4. It has a very good 2D rendering routine.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -