473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

fast graphics library in c++

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

Apr 26 '07 #1
5 2358
On 04/25/2007 11:05 PM, wa*********@gmail.com wrote:
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).

Apr 26 '07 #2
On 26 Apr, 06:05, wanengin...@gmail.com wrote:
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.

--
Erik Wikström

Apr 26 '07 #3
<wa*********@gmail.comwrote in message
news:11**********************@c18g2000prb.googlegr oups.com...
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.
Apr 26 '07 #4
Thanks everyone for your input, some very handy hints there!

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

cheers, magikus
Apr 26 '07 #5
wa*********@gmail.com
<11**********************@c18g2000prb.googlegroups .comThursday 26 of
April 2007 06:05
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.

Apr 26 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steven Feil | last post by:
I am wondering if there is a light weight Python library for producing web graphics on-the-fly. There is a C-language library called gd that can be used in a CGI program to produce gif images. The...
5
by: Markus Elfring | last post by:
Hello, A lot of clipart libraries offer free raster images. I am looking for a similar collection for vector graphics. Do you know a gallery or archive for the following formats? - Scalable...
2
by: qumpus | last post by:
My program right now generates USPS style shipping label using System.Drawing.Graphics. It works fine except that the printer prints really slowly. I want to make my program take advantage of true...
1
by: _R | last post by:
I'm porting an old app from VC++6 to .NET and need to update the bitblt functions from DibSection to managed code. The older functions ran fine but I may as well opt for the fastest, most...
2
by: predseda | last post by:
I would like to ask you, if you know about something like Tanner Helland's graphic tutorials (http://tannerhelland.tripod.com/VBGraphicsTutorial.htm)but VB.Net compatibile. I need to create...
8
by: Nathan Sokalski | last post by:
I am trying to write code to rotate a graphic that I have. Here is the code I am currently using: Dim frogbitmap As New Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif"))) Dim...
2
by: Lloyd Dupont | last post by:
In my .NET application I have some text rendered through GDI. It draws and print nicely. Now I would like to implement image export. So I create a new System.Drawing.Bitmap(width, height) then...
3
by: cartoper | last post by:
I am working on writing an Apache Module (in C/C++) that needs to resize (down) large images (4MB to 16MB) VERY quickly. The objective is not to make the images look great for printing, just look...
3
by: t | last post by:
I have been learning C++ on my own. For some projects, I would like to use graphics. What is the easiest way to do this? (I am using Visual Studio Express 2005.) Separate from the ease of use...
7
by: dave | last post by:
Hi All. I've been formulating in my head a simple image editor. I actually started prototyping is some time ago in Java, but am liking Python more and more. My editor will be nowhere near the level...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.