|
环境:VS2005 OSG2.8
ref_ptr< osg::Image > rpImgTemp;
sprintf(strPath, "%s\\images\\LeftTop.gif", g_IO.m_ExeResPath);
rpImgTemp = osgDB::readImageFile(strPath);
osg::Image* pImgLabel = new osg::Image;
pImgLabel->allocateImage(512, 512, 1, rpImgTemp->getPixelFormat(), rpImgTemp->getDataType());
pImgLabel->copySubImage(0, 0, 0, rpImgTemp);
在 OSG::Image copySubImage 中gluScaleImage总是返回1285"内存不足",看了这个贴子后
http://bbs.osgchina.org/viewthre ... hlight=copySubImage
也创建了RC,但是还是一样返回1285,创建大致如下:(在VIEW中)
BOOL CGMView:reCreateWindow(CREATESTRUCT& cs)
{
cs.style |= (WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
return CView::PreCreateWindow(cs);
}
int CGMView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
HWND hWnd = this->GetSafeHwnd();
HDC hDC = ::GetDC(hWnd);
if(this->SetWindowPixelFormat(hDC)==FALSE)
return 0;
if(this->CreateViewGLContext(hDC)==FALSE)
return 0;
return 0;
}
BOOL CGMView::SetWindowPixelFormat(HDC hDC)
{
PIXELFORMATDESCRIPTOR pixelDesc=
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|
PFD_DOUBLEBUFFER|PFD_SUPPORT_GDI,
PFD_TYPE_RGBA,
24,
0,0,0,0,0,0,
0,
0,
0,
0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};
this->m_GLPixelIndex = ChoosePixelFormat(hDC,&pixelDesc);
if(this->m_GLPixelIndex==0)
{
this->m_GLPixelIndex = 1;
if(DescribePixelFormat(hDC,this->m_GLPixelIndex,sizeof(PIXELFORMATDESCRIPTOR),&pixelDesc)==0)
return FALSE;
}
if(SetPixelFormat(hDC,this->m_GLPixelIndex,&pixelDesc)==FALSE)
return FALSE;
return TRUE;
}
BOOL CGMView::CreateViewGLContext(HDC hDC)
{
this->m_hGLContext = wglCreateContext(hDC);
if(this->m_hGLContext==NULL)
return FALSE;
if(wglMakeCurrent(hDC,this->m_hGLContext)==FALSE)
return FALSE;
return TRUE;
}
请问还要做什么工作么? 实在不知道怎么回事了 |
|