|
I'm making an appliaction that generates a timeline using open gl to display the graphics. At one time I had open gl do a translation based on the mouse position. However it was not turning out the way I wanted it to, and the project needs to be done by Monday. So i decided to throw it out and just use scroll bars since its only 2D.... and the scroll bars work.... almost.
My problem is that when you drag the scroll bar everything works right, but the second you let go. The bar goes back to 0. I'm curious what i need to add, or change so that the bar keeps its position when you let go of the bar.
C++ using MFC in visual studio 2003. If you need any thing else to help me debug send a line. I'm in the office until 5, so if you need some source code i can have that when i get home Thanks for the help,
Steve
|
|
|
|
|
you probably need to call SetScrollInfo on the scroll bar that moved, to set its position.
|
|
|
|
|
You need to handle the WM_HSCROLL or WM_VSCROLL message and set the thumb position. While you are dragging the thumb you will get SB_THUMBPOSITION notifcation messages, simple set the scroll position when that happens.
Regards,
Alex
|
|
|
|
|
Image distortion algorithms are hard to find, and c/c++ examples are very rare. I am rendering a ripple effect (stone into a pond) onto a bitmap. The algorithm itself is quite easy yet I have noticed an annoyance (and also noticed it in every example I have found.
When the bitmap is distorted the top and bottom is pulled away from the edge, revealing the origional bitmap beneath, also the left and right edges are 'how to say' wrapped around, ie the void space is filled using pixels from the opposit edge. I know that GIMP allows the option of either filling the void with the opposite edge, or filling with a brush. But both of these solutions don't look realistic.
I'm open to suggestions.
|
|
|
|
|
waldermort wrote: But both of these solutions don't look realistic.
what should happen ?
if the source data is being pulled towards the center, it seems odd that it should also be pulled outwards, to fill in holes.
one option is to let the ripple happen as the math demands, but then crop the output to get rid of the problem areas.
in my stuff, i like to fill the blank areas with pixels from the edge of the source.
|
|
|
|
|
you could enlarge the source image by wrapping the opposite edges some ammount of pixels, so that you ripple a larger image, but it will be clipped to the source image size; but you might have some problems with the corners
Attempt to some ASCII art drawing showing what I mean :
source image
+-----------+
| |
| |
| |
| |
+-----------+
enlarge source image
aaaaaaaaaaaaa
aaaaaaaaaaaaa
+-------------+
yy|xx yy|xx
yy|xx yy|xx
yy|xx yy|xx
yy|xx yy|xx
+-------------+
bbbbbbbbbbbbb
bbbbbbbbbbbbb
does that make sense ?
|
|
|
|
|
Both solutions had occured to me, and they both come with drawbacks. Enlarging he area will cause visual problems when the ripples bounce off the edges. Nevertheless, I will try all the solutions. Then settle on the better looking one
|
|
|
|
|
ideally, you could do that enlargement at the same time you're doing the ripple. that way, you only have one interpolation step.
in effect, you output to a larger rectangle than your input. should be a simple matter of scaling the coordinates on one side of the transformation. or, at least that's what it would be in my code - i obviously don't know how you do it
|
|
|
|
|
I could do the enlargment before I even touch into the ripple code, since I'm loading the bitmap and dealing directly with the dibsection. That way I would only need to crop the outpu slighlty. I'm also thinking of adding a depth algorithm to reduce the amount of warping at the edges, but this may cause problems with a ripple after it has bounced.
|
|
|
|
|
waldermort wrote: I could do the enlargment before I even touch into the ripple code
sure. but i think doing them at the same time would be faster (though speed isn't the top priority in all situations).
ex. my code does something like this:
for each output pixel (x,y):
run the ripple calculations backwards to find the source pixel (a,b)
since a and b are fractions
interpolate from multiple source pixels to find the output color
if the source image is 100x100 to scale based on crop rect (10,10, 90,90) (for example), i would do this:
for each output pixel (x,y):
run the ripple calculations backwards to find the source pixel (a,b)
scale a,b from the source rect into the crop/zoom rect
interpolate from a,b ...
just a thought...
|
|
|
|
|
It's worth a try. Since I have a screwdriver in my hand I might aswell give it a try.
|
|
|
|
|
what is best way to share data among classes? such as
CView s & CDocument s ?
what about use static data in stdfx.h?
Best Regards.
MJM.
|
|
|
|
|
mostafa_pasha wrote: what is best way to share data among classes? such as
CView s & CDocument s ?
The document 'tells' the view that data needs to be rendered. The view 'asks' the document for the data that is to be rendered.
mostafa_pasha wrote: what about use static data in stdfx.h?
Why?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
mostafa_pasha wrote: what is best way to share data among classes? such as
CView s & CDocument s ?
what about use static data in stdfx.h?
there have inbuilt function for access CView from CDocument and Viceversa.. like GetDocument et
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi, thanks i know GetDocument every view belong to one document!
if i wanna use data from two document & alter view what happen!
7 and how can i do that?
i found for that i can use document template & for some data can share
between all of my object i can declare in C...App the use throw my project
with theApp.Data !
is that right?
|
|
|
|
|
Hi, you know under Windows XP you can do fast switch to another user without logging out the current user. So at some point there might be more than one user that have logged in but only one of them is active.
So my question is, how can I detect if there's another user has been logged in. Is there an API that can do this thing?
Thanks!
|
|
|
|
|
try these
NetUserEnum()
NetQueryDisplayInformation()
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
Tanvon wrote:
try these
NetUserEnum()
NetQueryDisplayInformation()
this will not help!, this jsut enumerate the UserDatabase of the Computer
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
gydong22 wrote: So my question is, how can I detect if there's another user has been logged in. Is there an API that can do this thing?
Write WinNotification Package!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi all,
When CreateViewObject is called in my namespace extension I use SHCreateShellFolderView to create a system folder view. However, when the user double clicks on folder whithin this view, CreateViewObject is called again, and a new window pops up- instead of repopulating the old one. I've tried having a single instance of the IShellView from SHCreateShellFolderView and using it each time, but that just means that when the user opens a subfolder, nothing happens..
Any ideas anyone? I'm tearing my hair out over this...
Dave Kerr
codechamber@hotmail.com
http://www.codechamber.com
|
|
|
|
|
I have an app that eats up a bunch of memory with objects (created with "new"), then releases it back to the system (using "delete").
I am monitoring the memory usage with taskmanager, and noticed something strange... the memory does not seem to be given back to the system.
If I minimize the app, the memory is magically recovered by the system, and all is well, even after restoring the app.
Is the memory actually given back, but taskmanager is just out of the loop until the minimize, or is the memory not released until the app is minimized? if so, am I supposed to call some sort of "flush" function to give it back?
Thanks
|
|
|
|
|
MS's memory manager is greedy. it hangs onto memory you've free'd in anticipation that you might need it again before your program exits. this makes subsequent allocations faster.
|
|
|
|
|
nadiric wrote: ...the memory does not seem to be given back to the system.
Right, and this is perfectly normal behavior.
nadiric wrote: ...but taskmanager is just out of the loop...
TM is actually showing you the address space in use. This has nothing to do with the amount of that address space your program is actually using.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
An occasional call to _heapmin can be helpful.
|
|
|
|
|
Hello all,
I need to write some application in C++ that act like some chat application.
When client connect to the server - the server need to open new thread for the connection.
My main problem is the communication issue ... i don't know a lot about communication programming in C++ and i need to learn how to do it (specially the issue of open thread).
I looking in Google and i don't find anything.
Thanks for any help.
|
|
|
|