Skip to main content
GameDev.net gamedev.net
🔒 Locked

GDI

Started by Crispy Jul 20, 2003 at 11:47 AM 3 replies 600+ views
Original Post
Crispy
Crispy
I''ve never taken too much interest in using GDI to create a user interface object. What I want to do now is create a waveform viewer. Looking at any such program one can see that a huge waveform can be loaded and displayed without much slowdown. Here''s what I''ve figured out so far on my own: 1) respond to the WM_PAINT message and draw the waveform line-by-line into the window''s DC. 2) set a clip region to the DC to prevent Windows from drawing outside of the designated area 3) if the logical coordinates on the waveform are moved (the view window is scrolled left or right), update the clip region and invalidate the window by sending it the WM_PAINT message Loading a MegaByte waveform will yield app. one million points that have to be connected with lines (that means that a million LineTo()''s have to be called each time a WM_PAINT message is processed). This hardly seems rational. What I though I''d do is create a compatible DC for the window, draw the whole mess into it and every time a WM_PAINT message is received, load the DC into the window''s actual DC and update the clip region as necessary. In addition to the fact that I don''t see how to replace a window''s DC, this doesn''t seem to be working either. How are large GDI objects handled rationally without relying too much on the CPU and the OS? If that didn''t make much sense let me know and I''ll elaborate. Cheers
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
C-Junkie
C-Junkie
it is possible to just draw the tiny tiny little part of the waveform that''s visible on screen, atm...

forgot all that stuff since i haven''t written windows apps in ages.
Crispy
Crispy
Thanks for the replies. I''d like to load a whole waveform into memory and render an arbitrary part of it depending on the zoom factor and offset. I guess dynamically updating it is better, though rather than rendering the whole thing to texture.

Here''s one of the resulting problems I can think of at first glance:

Suppose I have a 3 megasample or larger waveform that cannot be rendered with sample precision. What I''d need to do is downsample it to fit the screen (and possibly save a lot of CPU time) which would require me create a new set of points for Polyline() every time WM_PAINT is processed (which can quite often, for instance when another window is moved over the control''s client area).

I''m just wondering if regular wave editors do it the same way as the amount of samples that can be loaded into memory can be very large and processing them a lot can put quite a strain on the CPU.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.