|
Dear Friends
I am wirting an application for drawing a rectangle on the screen using opengl and mfc. So I implemented the OnPaint function, OnDraw function is also giving the same problem. It's drawing fine. I want to implement pan, zoom, and rotate functionalities. Now everytime the mouse moves I am calling Invalidate() or otherwise I can call Invalidate() in the ::OnDraw function. Pan, zoom and rotate everything is happening but its heavily flickering. I have serached a lot and tried all means like return 1 in the OnEraseBackground() functio for WM_ERASEBACKGROUND etc. But I am getting still flickering . Please help getting rid of this problem. Check the code snippet below.
void CRevolutionProjView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect RectAff;
GetClientRect(RectAff);
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
glPushMatrix( ) ;
glTranslatef(trans[0], trans[1], trans[2]);
glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
drawcube();
glPopMatrix( ) ;
glFinish( ) ;
glFlush();
SwapBuffers(hDC);
Invalidate(false);
// Do not call CView::OnPaint() for painting messages
}
void CRevolutionProjView::OnMouseMove(UINT nFlags, CPoint point)
{
newP = point;
// TODO: Add your message handler code here and/or call default
int dx = oldP.x - newP.x;
int dy = newP.y - oldP.y;
switch(STATE)
{
case PAN:
{
trans[0] -= dx/100.0f;
trans[1] -= dy/100.0f;
// Invalidate();
}
break;
case ZOOM:
{
trans[2] -= (dx+dy) / 100.0f;
// Invalidate();
}
break;
case ROTATE:
{
rot[0] += (dy * 180.0f) / 500.0f;
rot[1] -= (dx * 180.0f) / 500.0f;
#define clamp(x) x = x > 360.0f ? x-360.0f : x < -360.0f ? x+=360.0f : x
clamp(rot[0]);
clamp(rot[1]);
// Invalidate();
}
break;
}
oldP = newP;
CView::OnMouseMove(nFlags, point);
}
|
|
|
|
|
|
I would recommend that you create an off screen bitmap, render the open GL image to that and then StretchBlt or equivalent to the display.
I recently developed a 2d/3d graphing system that supported 3d by openGL and it worked well using this method.
If you vote me down, my score will only get lower
|
|
|
|
|
Hi,
I thought I'd cracked this problem but it seems that I was wrong. Although I know now that the problem lies with the operating system.
I want to display a web page in a window. I realized that this is possible with the ShowHTMLDialog function, however it only works in windows XP not windows 7. There is something else though: I can get a web page to display when I run the program directly in visual studio but not when I run it as a stand-alone application(in windows 7). So I think the problem is that some required dlls are being loaded when I run it in visual studio but not as standalone.
It seems that the only dll i need for ShowHTMLDialog is mshtml.dll but I'm not sure if other dlls with different versions from windows XP are being used.
What's going on when I run the program from visual studio that is different from running the program on it's own ? How do I get ShowHTMLDialog to work in windows 7 ?
(I'm not using MFC)
thanks,
|
|
|
|
|
What kind of error are you getting? Not really sure what you mean when you say it only works on Windows XP, not Windows 7. You might be able to try using the dependancy walker application to find out what DLLs are needed by your application, thouhg.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
the error is that the program crashes on a call to ShowHTMLDialog(only on windows 7) and no dialog window appears.
thanks, I will check out the dependancy walker
|
|
|
|
|
Now that I checked here[^], I doubt that Dependancy Walker will help. You are going to have step through your code and find out which line of code is failing. My wild-ass guess would be that a call to GetProcAddress is probably not behaving as you expect it to.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Ah, the problem is where I convert a char string to wide char string. I need to convert the url I want to display to a wide char string and if I leave that code out and just specify google as the url, the program works in windows 7.
I'm not sure what I'm doing wrong with the conversion ?
char url[MAX_PATH];
_getcwd(url, MAX_PATH);
std::string file = url;
file += "\\Help.html\0";
OLECHAR* oleChar = NULL;
oleChar = (OLECHAR*)calloc(file.length(), sizeof(OLECHAR));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, file.c_str(), -1, oleChar, sizeof(OLECHAR)*file.length());
BSTR bstrURL = SysAllocString(oleChar);
|
|
|
|
|
hi,
how do i know index of an iterator of a map?
map<int, int>::iterator it = mymap.find(3);
i want to know index of 'it' in mymap???
Zo.Naderi-Iran
|
|
|
|
|
You can increment a counter in a loop.
But why do you need this.
std::map always works on the key and so you must not use the index to perform any operations on the map.
Here is something you could do -
map<int, string> num;
int j = 0;
for (auto i = num.begin(); i != num.end(); ++i, ++j)
{
if ((*i).first == 5)
cout << j << endl;
}
Don't know if there is any other way to do this.
|
|
|
|
|
maps are not arranged in a simple linear order (they are trees), so there is no 'index' for an item.
|
|
|
|
|
int a[33*1024];
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
HANDLE hReadThread = NULL;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
hReadThread = AfxBeginThread(ThreadWrite,0);
}
WaitForSingleObject(hReadThread,INFINITE);
return nRetCode;
}
UINT ThreadWrite(LPVOID lParam)
{
for(int i=0; i < 32*1024; i++)
{
a[i]=i;
cout<<"Write:" << a[i];
}
return 1;
}
Why in above program,
WaitForSingleObject() is not wating for thread comletion?
|
|
|
|
|
Because AfxBeginThread returns a pointer to a CWinThread object, not a thread handle (see "AfxBeginThread" at MSDN[^]).
You have to change from:
john5632 wrote: hReadThread = AfxBeginThread(ThreadWrite,0);
to (error checks left to the reader)
CWinThread * pWinThread = AfxBeginThread(ThreadWrite,0);
hReadThread = pWinThread->m_hThread;
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]
|
|
|
|
|
|
You are welcome.
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]
|
|
|
|
|
Yep...
|
|
|
|
|
Can you tell me where I found the CHKBOOK sample project ? Because here [^] I found only documentation, not project source ... Thank you.
|
|
|
|
|
|
Sorry, I didn't see any CHKBOOK sample ...
|
|
|
|
|
You need to use the links on that page to go and find it. Somewhere in there it will also explain where the sample source code can be found.
|
|
|
|
|
Of course that I use these links, but still, I didn't find it ... I found something newer but not CHKBOOK ... maybe microsoft get rid of ... I don't know.
|
|
|
|
|
Information on CHKBOOK is here[^] but it looks like the source has been removed. You should check your Visual Studio and SDK installation directories as some samples are shipped with the software.
|
|
|
|
|
Hello everybody,
i am working with VS 2008. I would like to change the Path dynamically in Additional Include Directories (Project Properties->Linker). Is that possible?
I would like to work with two set of SDKs'. After comparing the version, i would like to include appropriate versions of SDK. This is my situation.
Thanks in Advance.
Regards,
A. Gopinath.
|
|
|
|
|
I don't know how you could do this dynamically; an easier way would be to create a copy of the project with all the same settings except for this one value.
|
|
|
|
|
Hello Richard,
Thanks for your reply. Right now i am doing like that only. I just want to know whether it is possible or not. so only i posted here.
Thanks again.
Regards,
A. Gopinath.
|
|
|
|