Valentin Vit How to resize Opengles Surface ?
Posts 16
Added by Valentin Vit almost 2 years ago

Hello,

I am trying to resize the window and the opengl Surface;

I did the following modification in CCEGL_View_win32.cpp
1.In bool CCEGLView::Create(LPCTSTR pTitle, int w, int h)
i have added the resize button to the window
// create window
m_hWnd = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
kWindowClassName, // Class Name
pTitle, // Window Title
WS_CAPTION | WS_POPUPWINDOW|*WS_MAXIMIZEBOX|WS_MINIMIZEBOX*,* // Defined Window Style
0, 0, // Window Position
0, // Window Width
0, // Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL );
2.In LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

I have added resize event and viewport size modifications .

case WM_SIZE: {
//do {
//wSizeType = wParam;
//nWidth = LOWORD;
//nHeight = HIWORD;
POINT pt = {(short)LOWORD, (short)HIWORD};

resize(pt.x, pt.y);
CCSize size;
size.width=(float)pt.x*m_fScreenScaleFactor;
size.height=(float)pt.y*m_fScreenScaleFactor;
setViewPortInPoints(0, 0, size.width, size.height);
//glViewport(0, 0, size.width, size.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
ccglOrtho(0, size.width, 0, size.height, -1024*m_fScreenScaleFactor,
1024*m_fScreenScaleFactor );
// Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
} //while (0);
}

The window is resized but the opengles surface does not.
What I am missing ?

I need to destroy the surface and recreate it ? It is not enough to change the viewport dimensions ?

WenSheng Yang RE: How to resize Opengles Surface ?
Posts 30
Added by WenSheng Yang almost 2 years ago

Yes, you need delete the CCEGL and recreate it.
Because the EGL has a frame buffer which's size equal with window size, need recreate it after change the window size for make the size of frame buffer match the size of window.


(1-1/1)