Hi, everyone!
I want to replace the program with a blank open animation when loading data!so I informed the setup adds a thread to load data.So I opened a thread to load the data, but there is a mistake,
“GL frame buffer object not supported by this graphics card”
how can I do
//------------------------------------------------------------------------------------------
/*
name : cxw
date : 2015/7/8
function: 添加启动动画
*/
#include “process.h”
#include “tchar.h”
void setBorderless( bool borderless )
{
bool mBorderless;
mBorderless=false;
DWORD mWindowExStyle,mWindowStyle;
if( mBorderless != borderless ) {
mBorderless = borderless;
if( mBorderless ) {
mWindowExStyle = WS_EX_APPWINDOW;
mWindowStyle = WS_POPUP;
}
else {
mWindowExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
mWindowStyle = ( true ) ? WS_OVERLAPPEDWINDOW
: ( WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME ); // Windows Style
}
POINT upperLeft;
upperLeft.x = upperLeft.y = 0;
::ClientToScreen(WindowFromDC(wglGetCurrentDC()), &upperLeft );
RECT windowRect;
::GetClientRect( WindowFromDC(wglGetCurrentDC()), &windowRect );
// windowRect.left += upperLeft.x; windowRect.right += upperLeft.x;
// windowRect.top += upperLeft.y; windowRect.bottom += upperLeft.y;
// ::AdjustWindowRectEx( &windowRect, mWindowStyle, FALSE, mWindowExStyle ); // Adjust Window To True Requested Size
::SetWindowLongA( WindowFromDC(wglGetCurrentDC()), GWL_STYLE, mWindowStyle );
::SetWindowLongA( WindowFromDC(wglGetCurrentDC()), GWL_EXSTYLE, mWindowExStyle );
::SetWindowPos( WindowFromDC(wglGetCurrentDC()), HWND_TOP, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOZORDER );
if( mBorderless )
::InvalidateRect( 0, NULL, TRUE);
cout<<windowRect.top<<" "<<windowRect.bottom<<endl;
}
}
static int i_cxw = 0;
PluxOne_game_playHamster_frame f;
void __cdecl beginThreadFunc( LPVOID )
{
f.setup();
cout << “cxw1111111” << endl;
i_cxw = 1;
cout << i_cxw << endl;
_endthread();
}
void drawStartAnimation()
{
HWND hwnd = FindWindow(NULL, _T(“Game”));
HDC hDC = GetDC(hwnd); //获得系统绘图设备
HDC memDC = CreateCompatibleDC(0); //创建辅助绘图设备
HBITMAP bmpBack = CreateCompatibleBitmap(hDC,ofGetWidth(),ofGetHeight());//创建掩码位图(画布)
SelectObject(memDC,bmpBack); //将画布贴到绘图设备上
HPEN penBack = CreatePen(PS_SOLID,1,RGB(255,0,255));//创建画笔
SelectObject(memDC,penBack); //将画笔选到绘图设备上
HBRUSH brushBack = CreateSolidBrush(RGB(255,255,255));//创建画刷
SelectObject(memDC,brushBack); //将画刷选到绘图设备上
// //擦除背景
RECT rcClient;//区域结构
GetClientRect(hwnd,&rcClient);//获得客户区域
HBRUSH brushTemp = (HBRUSH)GetStockObject(WHITE_BRUSH);//获得库存物体,白色画刷。
FillRect(memDC,&rcClient,brushTemp);//填充客户区域。
//////////////////////////////////////////////////////////////////////////
HBRUSH brushObj = CreateSolidBrush(RGB(0,255,0));//创建物体画刷
//绘制背景图片
HBITMAP bg = (HBITMAP)LoadImage(NULL, _T("D://back.bmp"), IMAGE_BITMAP, ofGetScreenWidth(), ofGetScreenHeight(), LR_LOADFROMFILE);
SelectObject(memDC, bg);
BitBlt(hDC,0,0,ofGetWidth(),ofGetHeight(),memDC,0,0,SRCCOPY);//复制到系统设备上显示
static int i_img = 1;
// HBITMAP bg_load = (HBITMAP)LoadImage(NULL, _T(“E://1//001.bmp”), IMAGE_BITMAP, 307, 305, LR_LOADFROMFILE);
// SelectObject(memDC, bg_load);
// BitBlt(hDC,0, 0,ofGetWidth(),ofGetHeight(),memDC,0,0,SRCCOPY);//复制到系统设备上显示
//绘制维网格,矩形画法。
// int dw = 30;
// int rows = ofGetHeight()/dw;
// int cols = ofGetWidth()/dw;
// for (int r=0; r<rows; ++ r)
// {
// for (int c=0; c<cols; ++c)
// {
// if (r == c)
// {
// //SelectObject(memDC,brushObj);
// }
// else
// {
// SelectObject(memDC,brushBack);
// }
// Rectangle(memDC,cdw,rdw,(c+1)*dw,(r+1)*dw);
// }
// }
DeleteObject(brushObj);
//////////////////////////////////////////////////////////////////////////
DeleteObject(penBack); //释放画笔资源
DeleteObject(brushBack);//释放画刷资源
DeleteObject(bmpBack); //释放位图资源
DeleteDC(memDC); //释放辅助绘图设备
ReleaseDC(hwnd,hDC); //归还系统绘图设备
}
//------------------------------------------------------------------------------------------
//--------------------------------------------------------------
void ofApp::setup(){
setBorderless(true);
_beginthread(beginThreadFunc, 0, 0);
for(; ;)
{
drawStartAnimation();
if(i_cxw == 1) {
break;
}
}
//ofSetFullscreen(true);
ofHideCursor();
}