|
MPTP wrote: What is the problem plz suggest me?
Have you called CoInitialize() or OleInitialize() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I am trying to render multiple texts in different fonts and sizes using OpenGL.
but the use of wglusefontbitmaps seems to cause some memory leakage? How can I avoid this. I am attaching the code for rendering below
void M4DScreenData::RenderOverlayData( HWND hWnd_i )
{
GLint nDisplayList = glGenLists( 128 );
HDC hDC = ::GetDC( hWnd_i );
HFONT hOldFont;
HFONT hNewFont;
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT);
TextData TextDataobj;
POSITION nPos = m_DataMap.GetStartPosition();
int nID = 0;
glColor3ub( 255, 255, 255 ); // Overlay data color
while( nPos )
{
if( 0 != m_Font.GetSafeHandle())
{
m_Font.DeleteObject();
}
m_DataMap.GetNextAssoc( nPos, nID, TextDataobj ); //Cmap that contains the data,font and size
CString csOverLayData = TextDataobj.GetText();
int nLength = csOverLayData.GetLength();
CPoint Location = TextDataobj.GetPos();
m_Font.CreatePointFont(( TextDataobj.GetFontSize()) * 10, TextDataobj.GetFontName(), NULL );
hNewFont = ( HFONT )m_Font.GetSafeHandle();
hOldFont = ( HFONT )SelectObject( hDC, hNewFont );
wglUseFontBitmaps( hDC, 0, 128, nDisplayList );
glListBase( nDisplayList );
// Position the text in the window, at location (Xcoord, Ycoord)
glRasterPos2d( Location.x, Location.y );
glCallLists( nLength, GL_SHORT, csOverLayData ); // Display overlay data
SelectObject( hDC, hOldFont );
}
if( 0 != nDisplayList )
{
glDeleteLists( nDisplayList, 128 );
}
}
|
|
|
|
|
I have happily and successfully programmed graphics processing for many years using VB, but I want to port the project over to VC++. As a trial a week ago I looked at C# and found no problems. However, C++ proved to be hell . I started with a form (Form1), dressed it up OK and loaded images, scroll bars worked. It all worked OK. I then added a second form (CAMERAFrm) and could not open it from the first one. I tried all sorts of variants of ShowDialog() found on MSDN, in forums and books, to no avail. The error messages summarised say that CAMERAFrm is unknown, even when I include each .h form in the code of the other and spell its name out fully. The project name is cppPOSTERclr and the two forms are said to be - public - and - ref class - but whether I try to use CAMERAFrm as a class-
CAMERAFrm ^ DSLR =gcnew CAMERAFrm
DSLR->ShowDialog(this)
or as an object-
CAMERAFrm->ShowDialog(this)
the project claims CAMERAFrm is undefined.
Intelisense and edit panel titles gives me cppPOSTER::Form1 and cppPOSTER::CAMERAFrm as valid names with global scope. However, even when I try to use cppPOSTER::CAMERAFrm I get messages such as-
error C2039 'CAMERAFrm': is not a member of 'cppPOSTERclr'
error C2039 'CAMERAFrm': is not a member of 'cppPOSTERclr::Form1'
I can open a third new window:-
Form ^ DSLR= gcnew Form()
DSLR->ShowDialog(this)
Can anyone tell me what is happening? I did nothing fancy: just opened two forms and tried to open the second from a button in the first.
Surely VC++ isn't a savant - good for intricate detail but hard to get on with in everday life!
|
|
|
|
|
u need to add the .h file for your CAMERAFrm in Form1.h file and then create a member of CAMERAfrm in Form1.h
Then on button click call DoModal()
This will work for you.
|
|
|
|
|
Hi, all:
There are some good oppotunity in Freeborders, we are search some Sr.C++ Engineer to join us, if you are interested in this position, please move your mouse to send me your CV to pandapam@126.com, maybe i can help you to get a good job!
Thank you for your attention, wish you a good luck.
|
|
|
|
|
Support!
|
|
|
|
|
This is not the right forum.
|
|
|
|
|
Hello,
I am new to the C++ language. How can I make a variable hold its value when enters the function the next time, I don't want to declare it as static, I was wondering how its handled in MFC. Here is the concept of what I want to do:
How can I hold the value of variable m_Val when it exits the function, doesn't reset to zero when it comes back in? (note, can't use static)
Thanks
Class A{
void DoFunction(....)
double m_Val;
...etc
};
void A::DoFunction(....)
{
....
m_Val = x^2/1000 ;
if(flag)
m_Val -= K;
....
}
int main()
{
....
For Loop timer every 15 msecs{
DoFunction(...)
}
}
sft
|
|
|
|
|
Not quite sure if I understand you sft.
Would you like the value of m_Val to be the same after a call to A::DoFunction(....) as it was before?
Or do you simply want m_Val to hold whatever is put into it until it is explicitly changed again?
If the answer is (a) the first one, use some code like this:
void A::DoFunction(....)
{
double m_Temp_Val = m_Val;
....
m_Val = x^2/1000 ;
if(flag)
m_Val -= K;
....
m_Val = m_Temp_Val;
}
If however, the answer is (b), you already have posted code that will allow the value of m_Val to persist, or remain until the next time you choose to change it. Since m_Val is a class member, it's value will remain until either (a) you re-assign a value to it by using the A::DoFunction member(assuming no other member functions modify the value held by m_Val), or (b) the class object is destroyed, either by going out of scope, or explicitly via a call to the delete function.
S.
|
|
|
|
|
Thanks for your explanation, my question was (b), and you are right, I had it working as posted.
I do have a seperate question, I would like to use a flag in MFC that will tell me if the computer/(OS) is using a 10 ms or 15 ms time slices... Is there a way I can find out what time slice does a computer have, or any other method to obtain this? I can use GetTickCount() to calculate the thread updates and find the time slice may be, but it doesn't sound too smart.
Thanks
sft
|
|
|
|
|
From the articles I'm reading, it seems that this should be reasonably easy to determine.
Quoting from Description of Performance Options in Windows[^],
The term "quantum" is a unitless measure of time for each time slice that a thread will run until a "context switch" occurs and another thread (either within the same program or from within another program) is selected to run. This prevents a CPU-bound process from monopolizing the processor. Currently in Windows, 3 quantums are equal to either 10 milliseconds (single processor) or 15 milliseconds (multiple-processor Pentium). This depends on the hardware abstraction layer (HAL) selected for your computer. Original Equipment Manufacturer (OEM) HALs may have a different value. Time slices that are fixed at 36 quantums are currently used when background services are selected (as you might choose in a typical server installation).
The situation become more complex when you enable the Foreground Applications option. This introduces the "variable quantum" concept. In this case, background tasks receive a different quantum than the quantums received by the foreground tasks. Also, both sets of quantums are shorter than a thread would receive on a computer set for background services. Currently, a background process receives a quantum of 3 and a foreground process receives a quantum of 9. Therefore, you can calculate the length of time the thread will run before its timer expires.
Soooo, it seems that all you have to do is determine if the running system contains a single processor, or multiple processors.
If you open up regedit, and take a look at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion , there is a key called CurrentType
On my Celeron D 2.66 Ghz, this has the value "Uniprocessor Free".
On my Pentium D 3.4 Ghz, this same key has the value "Multiprocessor Free"
Perhaps it really is as simple as that??! (hope so )
Simon.
|
|
|
|
|
Thanks again, but if I read that particular key from the registry, it will only work if all the strings are consistent on all computers, otherwise reading the 2 particular strings won't be good enough, correct?
sft
|
|
|
|
|
That's okay. Yup, got it in one. If these strings vary, then this method I propose would suck the big-one.
The only thing I can think of is to try it on a number of different machines, or see if anyone else around the net has anything to say about this (yeah, I know - sorry it's a disingenuous suggestion, but I can't think of any other ways to attack the problem right now)
Here's a page that mentions the key -
http://www.volny.cz/rootshell/hackistry.htm[^]
Hope it helps get you there.
S.
|
|
|
|
|
enhzflep wrote: On my Pentium D 3.4 Ghz, this same key has the value "Multiprocessor Free"
I have an Intel Core Duo that reports the same.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I checked about 6 computers at work between single and dual, it looks to be consistent with your findings. Its good enough for me, I will read the values, if not consistent, I will default to either one of the two.
Thanks again
sft
|
|
|
|
|
Hi;
I have just started to use Dev C++. But I guess I just could not figure out how to use it because I have tried a very simple program, but it did not work. I have just one class
#include <iostream>
using std::cout;
using std::endl;
int main(){
cout<<"endl"<<endl;
return 0;
}
</iostream>
When I try to compile it; it gives the error:
[Linker error] undefined reference to `__cpu_features_init'
ld returned 1 exit status
I know this is gonna sound stupid. But I need some help here. Thank you.
|
|
|
|
|
Hmm, I seem to remember having this error once or twice before. I did solve it, though found the whole suite to be a little dated.
An alternative that I've since switched to that you may enjoy is Code::Blocks.
You can find it here: Code::Blocks download page[^]
(you'll probably want the one with MinGW included, as this simplifies setup)
|
|
|
|
|
im using this example to add a new resource to a PE file
http://www.codeproject.com/KB/cpp/UpdateResource.aspx[^]
well when i use this code or a pre defined file path on the compile the code works perfectly
hFile = CreateFile(L"C:\\Winnt\\System32\\calc.exe", GENERIC_READ, 0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
but if i use a cstring that holds the path of a file (it reads the path from a listview item) the program crashes
CString strFile = m_List.GetItemText(0,3)
hFile = CreateFile(strFile, GENERIC_READ, 0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
how can i fix this?
|
|
|
|
|
Evil_Inside01 wrote: the program crashes
Evil_Inside01 wrote: how can i fix this?
By writing code that handles exceptional conditions and reacts gracefully rather than crashing. You know how to do that correct?
led mike
|
|
|
|
|
no im still a beginner in cpp...
so this isnt a CString error that i have to convert CString to another variable?
modified on Monday, November 24, 2008 3:57 PM
|
|
|
|
|
Evil_Inside01 wrote: no im still a beginner in cpp...
What? And you are trying to add a resource to a PE file? Warning Will Robinson! Does not compute!
Do yourself a favor and stick to beginner stuff until you have a very strong grasp on the basics. Using internet forums to debug your beginner level coding of advanced applications is far Far FAR from productive.
led mike
|
|
|
|
|
Evil_Inside01 wrote: (it reads the path from a listview item)...
Have you verified that it is correct?
Evil_Inside01 wrote: ...the program crashes
Which means what?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
ive fixed the error
thanks for helping
|
|
|
|
|
i is an integer holding an 8 bit value of a joysticks position. How do i get an emulator on my pocket pc to see it as an input/button press?
|
|
|
|
|
Try the Mobile Development forum [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|