|
groover4life wrote:
So in essence what you are saying is; Instead of using the WM_TIMER message, create a thread that just performs a basic loop, getting the data and updating the display, and the update rate will be what ever the CPU slice is for that particular thread?
wait, wait, wait... Use the loop in the thjread for data mainpulation only, and pump custom messages out of the thread to the UI thread and handle the redraw and stuff in the UI thread as a message handler. I've had very bad experiences when trying to access stuff outside of my own little thread, but the PostMessage thing works very well. NT should get you pretty accurate down to around 10ms or so, so that is about a 100Hz refresh. (You'll need to do a Sleep(10) or whatever to delay the thread.) Make sure you aren't doing very time consuming stuff here either, as that will begin to affect your performance. Remember, NT is not an RT OS, so you are at the mercy of other higher priority things on the PC. There are some articles around here about using multimedia timers for better precision, but I haven't used any of them yet.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron,
This seems like a viable solution to my performance issue. I believe I will take this approach, then go back into the OpenGL code and see what I can do to optimize there. At least I don't need it to be real time as Windows is not a RTOS, but it should give me the refresh rate which I need.
Also, Do you think it will hurt having to access my document object to dump the data into? I don't have to manipulate the data alot.
do you think this will also help my CPU HOG issue as well? I may have some more questions once I design and implement this method (will take me most of the afternoon as the application is pretty complex in nature).
Thank you so much for the suggestions and comments. Keep 'em coming! Whoo Hooo!
Dan Willis
|
|
|
|
|
groover4life wrote:
create a thread that just performs a basic loop, getting the data and updating the display, and the update rate will be what ever the CPU slice is for that particular thread?
My idea is this one: One thread updates the data periodically (using an infinite loop with a call to SleepEx in it, to allow the OS to activate another thread, especially important with Win9X OSs), another thread displays these data periodically too (with a timer for example), but asynchronously with the first one. Data protection is then required between the two threads, for example by using a mutex.
It enables to smooth the CPU consumption.
groover4life wrote:
What kind of tricks can I use in OpenGL??
There are plenty technics, you should perhaps refer to the OpenGL Red and Blue Books. You may also find some rules to follow on this page[^]
FYI, I call resident textures bitmaps you may "upload" in the video memory of the video card. Using this instead of standard RAM may fasten a lot the rendering, according to the capacity of the video card and the use of textures by the application.
groover4life wrote:
I always test, but in this case I did not write this code base. I was only left to deal with it
What I meant was that you should be careful the end users of your application may have a computer less powerful than yours, so you should probably have to envisage this case.
HTH,
K.
I hurt so bad inside
I wish you could see the world through my eyes
It stays the same
I just wanna laugh again
|
|
|
|
|
KaЯl wrote:
I always test, but in this case I did not write this code base. I was only left to deal with it
What I meant was that you should be careful the end users of your application may have a computer less powerful than yours, so you should probably have to envisage this case.
LOL! Thanks! But I doubt that my company's clients will have a machine slower than a P-3 450 which is what I'm using for my development.
Dan Willis
|
|
|
|
|
When dealing with OpenGL, GPU is often more important than CPU
Following the video card, the framerate may vary considerably (i've still experienced a variation from 1.5 fps to 50 fps !)
I hurt so bad inside
I wish you could see the world through my eyes
It stays the same
I just wanna laugh again
|
|
|
|
|
Hi,
I need to draw some text rotated 90º in the screen, for that, what I did is to transform the normal font, and call ExTextOut...
...But I have a problem, with multiline text... with DrawString was now problem give a rect and make the text fit there... but it seems that DrawString doesn't work for rotated text, and does ExTextout support this ?
Thanks in advance, Greetings
Braulio
|
|
|
|
|
Try here[^].
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I have a CFormView class and I'd like to automatically resize the window when the user turns off the toolbar or status bar. In other words, I don't want the blank area of the form view (usually hidden by the toolbar or status bar) to show up when the user toggles the status of either bar.
I haven't seen any source that does this, so any help would greatly be appreciated.
Thanks!
Jonah Bishop
Visit JGB Productions
http://www4.ncsu.edu/~jgbishop
|
|
|
|
|
Use SetWindowPos()
i.e.:
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
wp.rcNormalPosition.left = rectNewRect.left ;
wp.rcNormalPosition.right = rectNewRect.right ;
wp.rcNormalPosition.bottom = rectNewRect.bottom ;
wp.rcNormalPosition.top = rectNewRect.top ;
wp.showCmd = SW_SHOWNORMAL;
SetWindowPlacement(&wp);
or something similar...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I see how I would use that, but how do I figure out the new window size when hiding or (more importantly) showing the toolbar or status bar? Is there a call to get the view size (with the toolbar) and also get just the toolbar size (to subtract or add to the view size)?
Thanks!
Jonah Bishop
Visit JGB Productions
http://www4.ncsu.edu/~jgbishop
|
|
|
|
|
int x_size = GetSystemMetrics(SM_CXSCREEN);
int y_size = GetSystemMetrics(SM_CYSCREEN);
int x_max = GetSystemMetrics(SM_CXMAXIMIZED);
int y_max = GetSystemMetrics(SM_CYMAXIMIZED);
int yToolbar = y_size - y_max;
I think...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Oops. I should have checked a little more thoroughly here at the site...
I found the exact thing I was looking for in this article.
But thanks for your prompt replies, Nitron. They are certainly appreciated!
Jonah Bishop
Visit JGB Productions
http://www4.ncsu.edu/~jgbishop
|
|
|
|
|
I had in a C dll, that was called by VC++, the following and it worked fine:
#define DllExport __declspec( dllexport )
DllExport void __cdecl Fusion_Method(int *nalg, int *score, int *fusion_score)
{
I wanted to call this dll in a VB program and am told I need to do _stdcall. I searched the web but dont see how to modify the above to make it stdcall instead of __cdecl. Please help!
Appreciate your help,
ns
|
|
|
|
|
Just replace __cdecl with __stdcall in the declaration of FusionMethod . That's all you need to do (hopefully).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Good try. It compiled fine. But the VB callling program stubbornly still says it doesnt know anything about the function from the dll.....
Thanks so much for helping though...
Appreciate your help,
ns
|
|
|
|
|
Am I doing this right?
#define DllExport __stdcall( dllexport )
//#define DllExport __cdecl( dllexport )
//DllExport void __cdecl Fusion_Method(int *nalg, int *score, int *fusion_score)
DllExport void __stdcall Fusion_Method(int *nalg, int *score, int *fusion_score)
This wont even compile!
Thanks though, for the input
Appreciate your help,
ns
|
|
|
|
|
Try this:
#define DllExport __declspec( dllexport )
extern "C" DllExport void __stdcall Fusion_Method(int *nalg, int *score, int *fusion_score)
...
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Compiler says:
c:\pmarmodif\fusionmethod.c(3) : error C2059: syntax error : 'string'<br /> pointing at the extern line.....
Thanks for keeping up with my issue here...
Appreciate your help,
ns
|
|
|
|
|
Ummm.. I guess fusionmethod is C++ code, so change the extension to .cpp . The fact that you're declaring the function as extern "C" does not have to do with the language you use to implement it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The others who respond are correct, I'm only adding on here. One thing I've found when I want to use __stdcall is the need to include a line defining the function in the .def file for the project.
So if your dll project is named "ABC", open "ABC.def", and add the following line to the "EXPORTS" section (it must be on it's own line):
Fusion_Method
Now, build your dll again, and the function should be exported with the correct name.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
Thank you to all who helped. Chris - I did indeed go the .def file route and have it working though its churning out an incorrect result. However it recognises the exported function now. One question though: Dont I need to specify the arguments of Fusion_Method in the def file? Like Fusion_Method( int*a, int* b, int*c) ?
Thanks
Appreciate your help,
ns
|
|
|
|
|
You don't need to specify the arguments in the .def file. When you say "incorrect result" what do you mean? Keep in mind, that you need to take Joaquín's comments into account (by using __stdcall instead of __cdecl).
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I had a slight error in the calling VB program which was making the numerical result incorrect. Once I removed the argument list from the def file and fixed the VB problem, it worked fine.
My next task is to find a compiler for this user who wants to be able to compile the Dll but refuses to install V Studio. SO far the gcc compiler I've looked into (I'm on windows) doesnt tell me how to compile a dll given a .c and a .def file.
Anyways, the coding problem has been resolved, so I thank you for your input.
Appreciate your help,
ns
|
|
|
|
|
Hi,
I have a small question regarding pointers.
I have an 2D array of ints like:
static int ERBaCoeff_22050[2][7] = {
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10}};
I try to do something like this:
int ** a = ERBaCoeff_22050;
The compiler throws an error. Saying cannot convert a int[2][7] to a int**
I thought this was a legal assignment. I even tried something like:
int ** a = &ERBaCoeff_22050;
but no luck.
Also,
int * some = &ERBaCoeff_22050[0][0];
int ** a = &some
This works. But I cannot traverse the array beyond the forst row...
i.e. a call to a[1][1] fails, but a [0][7] works
It works when I do:
char *ptr;
char arrayChars[8] = {'F','r','i','e','n','d','s','\0'};
ptr = arrayChars;
What am I doing wrong??
I would greatly appreciate any help you guys can give me.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
A couple of things strike me.
1. In your first declaration
int **a=ERBaCoeff_22050
You are trying to set a pointer to a pointer to an array. This wont work as the array is not a pointer.
That is why
pankajdaga wrote:
int * some = &ERBaCoeff_22050[0][0];
int ** a = &some
works. You are first setting an int pointer to point to the array then setting the a pointer to point to the pointer. This is the only way you can do it.
2. You cant address the second row because the compiler doesnt know how big the rows are in the array. while a[0][n] always refers to the first row a[x][y] refers to row x and requires the compiler to do the math to find the correct row, it cant do this if it doesnt know the size of the rows.
Look at it like this an int* is a row of int with as many as you like so a[10] and a[0][10] are the same thing all the way to a[0][infinte] but given that the row is infinte in length what does a[1][1] actually mean.
I think this explination is correct. Someone correct me if im wrong
I hope this helps.
|
|
|
|