fast graphics library in c++

W

WE

Hi, I was hoping someone might help me.

I have developed code that generates 1000+ small objects on the
screen. These are, for example, simple circles with small radii. A
circle with zero radii is a single pixel. The objects move abount on
the screen at various speeds.

In the simplese case I have a single red pixel moving across the
screen with a white background. What I have done is that:

1) I place the red pixel on the screen at position x.
2) I then place a white pixel at x and a red pixel at x+1.

In this manner the red dot moves across the screen. Now with 1000
objects on the screen the objects seem to flicker and there is no
smooth progression from state x to state x+1.

I am using VC++ Windows GDI. I guess the MS GDI is half my problem. Is
there an optimal approach to this?

Many thanks
 
M

Mumia W.

Hi, I was hoping someone might help me.

I have developed code that generates 1000+ small objects on the
screen. These are, for example, simple circles with small radii. A
circle with zero radii is a single pixel. The objects move abount on
the screen at various speeds.

In the simplese case I have a single red pixel moving across the
screen with a white background. What I have done is that:

1) I place the red pixel on the screen at position x.
2) I then place a white pixel at x and a red pixel at x+1.

In this manner the red dot moves across the screen. Now with 1000
objects on the screen the objects seem to flicker and there is no
smooth progression from state x to state x+1.

I am using VC++ Windows GDI. I guess the MS GDI is half my problem. Is
there an optimal approach to this?

Many thanks,
magikus

<OffTopic>

This question is off topic for this newsgroup because ISO standard C++
has no concept of graphical displays.

However, back when I was doing WIN32 programming, the technique to
reduce flicker was to write a new image into a memory display context,
then to blast the memory display context onto the real display context
(the screen).
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

> Hi, I was hoping someone might help me.
> I have developed code that generates 1000+ small objects on the
> screen. These are, for example, simple circles with small radii. A
> circle with zero radii is a single pixel. The objects move abount on
> the screen at various speeds.
> In the simplese case I have a single red pixel moving across the
> screen with a white background. What I have done is that:
> 1) I place the red pixel on the screen at position x.
> 2) I then place a white pixel at x and a red pixel at x+1.
> In this manner the red dot moves across the screen. Now with 1000
> objects on the screen the objects seem to flicker and there is no
> smooth progression from state x to state x+1.
> I am using VC++ Windows GDI. I guess the MS GDI is half my problem. Is
> there an optimal approach to this?

This is off topic here since it is concerned with platform-specific
libraries, next time try one of the microsoft.public.*-groups.

First of, your approach of painting over the old location and then
painting the new is probably not optimal. What you should do is to
clear the whole canvas and then repaint all the circles. You probably
also want some kind of double-buffering if your don't already have
that.

Should this still not suffice you'll probably have to use some kind of
hardware accelerated solution, DirectDraw or Direct3D could be used,
but I don't think that should be necessary.
 
J

Jim Langston

Hi, I was hoping someone might help me.

I have developed code that generates 1000+ small objects on the
screen. These are, for example, simple circles with small radii. A
circle with zero radii is a single pixel. The objects move abount on
the screen at various speeds.

In the simplese case I have a single red pixel moving across the
screen with a white background. What I have done is that:

1) I place the red pixel on the screen at position x.
2) I then place a white pixel at x and a red pixel at x+1.

In this manner the red dot moves across the screen. Now with 1000
objects on the screen the objects seem to flicker and there is no
smooth progression from state x to state x+1.

I am using VC++ Windows GDI. I guess the MS GDI is half my problem. Is
there an optimal approach to this?

To do it the way you are doing it, first draw the new location, then erase
the old one.

A better way, however, is to write to a back buffer. That is, a bitmap or
whatever you are displaying that is stored in memory. Make the changes
there, then swap buffers. Usually just the change of a pointer will make
the new image appear. You may need to wait for screen refresh.

Other that that, ask in a windows newsgroup for specifics on GDI.
 
P

pwalker

Thanks everyone for your input, some very handy hints there!

I shall remember to post in more specific newsgroups in the future.

cheers, magikus
 
?

=?ISO-8859-2?Q?Rafa=B3?= Maj

(e-mail address removed)
I am using VC++ Windows GDI. I guess the MS GDI is half my problem. Is
there an optimal approach to this?

You need a 3rd party library.

I recommend allegro or SDL.

Both are actually C libs but can be of course used in C++ program.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,298
Messages
2,571,540
Members
48,275
Latest member
tetedenuit01

Latest Threads

Top