The code downloaded and when built, produced numerous warnings and two errors. From file OpenGLWnd.cpp:
void COpenGLWnd::StartStockDListDef()
{
// check if we aren't inside another couple begin/end
if(!m_bInsideDispList)
{
// search a free slot
for (int c=0;m_DispListVector[c]!=0;c++);
// check if we are inside a drawing session or not....
if(!( m_hRC==wglGetCurrentContext() && m_pCDC->GetSafeHdc()==wglGetCurrentDC() ))
{
// ...if not specify the target DeviceContext of the subsequent OGL calls
wglMakeCurrent(m_pCDC->GetSafeHdc(), m_hRC);
// set a warning for EndDispList
m_bExternDispListCall=TRUE;
};
// create a handle to the disp list (actually an integer)
m_DispListVector[c]=glGenLists(1);
// set a semaphore
m_bInsideDispList=TRUE;
// start the disp list: all subsequent OGL calls will be redirected to the list
glNewList(m_DispListVector[c],GL_COMPILE);
};
}
In this line:
for (int c=0;m_DispListVector[c]!=0;c++);
variable C is declared, but is only local.
In these two lines:
m_DispListVector[c]=glGenLists(1);
glNewList(m_DispListVector[c],GL_COMPILE);
It is referenced, but no longer valid. I will move the declaration out of the for loop and see what happens. The original code needs a correction.
I should have compiled and run first. It did compile and run so far as I can tell. Still playing with it. Other than the numerous warnings, looks good. Oh, environment is Windows XP, Visual Studio 2008.
ReplySome body know how to make the function change the color of X, Y Z axis and make gird for the coordinate ? Thanks in advance !
Replyhow to blink a point in a scatter plot. waiting for ur answers. Thank u all.
ReplyYour work is helpful. But I would like to use it as an embeded object, could you tell me how to modify the Scatter3DDlg to Formview? I tried several times but didn't work. Best Regards Mark
ReplyHow to put the left side in a pane and the other side in another pane? Thanks in advance!
ReplyMy email address is: mark.ming.ma@gmail.com
William: thanks a lot, it's really helpful! Best Regards, Mark
ReplyPutting the 3D graph into a property page is just like putting it into a standard dialog.
In the *.h file you forward declare the class, and define a pointer to an instance:
class CGLSelectableScatterGraph;
class MyPropPage
{
...
CGLSelectableScatterGraph m_p3DGraph;
...
};
In your resource file draw a frame in the location (e.g. IDC_3D) where you want the graph to appear, but make it invisible.
In OnInitDialog of the property page have code something like this
...
CRect r;
CWnd *pW=GetDlgItem(IDC_3D);
pW->GetWindowRect(&r); // top left marker
ScreenToClient(r);
m_p3DGraph= new CGLSelectableScatterGraph;
if (!m_p3DGraph->Create( NULL, //CWnd default
NULL, //has no name
WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,
r,
this, //this is the parent
1002)) //this should really be a different number... check resource.h
{
TRACE("Failed to create Histogram window\n");
ASSERT(FALSE);
}
m_p3DGraph->SetProjection(0);
m_p3DGraph->SetSymbolSize(5.f);
m_p3DGraph->SetClearCol(RGB(255,255,255));
m_p3DGraph->SetRotationType(1);
// some fake data
static float fake_data[]= {
0., 0., 0.,
1., 1., 1.,
0.5, 1, 0.,
0.5, 0.5, 0.5
};
static COLORREF fake_colList[] = {
RGB(255,0,0), // red
RGB(255,255,0), // yellow
RGB(0,255,255), // cyan
RGB(255,0,255)
};
m_p3DGraph->SetData(4,fake_data,fake_colList);
...
That should do it.
Reply
I'm new to OpenGL and find this article very useful to begin with.
ReplyOriginally posted by: Dr. Ian D Wilson
Very useful indeed!
I am using it to generate topological graphs for a range of optimisation functions that will be 'solved' by final year mathematics under-graduates using genetic algorithms.
If you can find the time to add a wire-frame to your scatter-graph I would be very grateful indeed (I simply cannot find the time at the moment).
Best wishes
Ian
ReplyOriginally posted by: Thomas Markas
Just what I needed to get into OpenGL on the Windows environment. Its many moon again that I used OpenGL on a Unix box.
Originally posted by: Min Xu
I have to question need help from you:
1. how to change the box size easily by x, y, z.( eg.x=5cm, y=6cm z=8cm)
2. how to move the image inside the box, up ,down, left, right, maybe controlled by keyboad?
Thanks you very much!
Reply