Open GLES application displays black screen

Hi,
I developed an Open GLES application to draw a triangle for ARM platform. The application is a win32 application.When i launched the application in my target device, a black screen is displayed. Any one please help me how to solve this problem.

Thanks and Regards,
Sowmya

Can you post your code here? Cann’t guess the exact problem with this much info :slight_smile:

Hi ,

Find my code:
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
WNDCLASS wc;

hInst = hInstance;
bool done = false;

if(hWnd = FindWindow(szAppName,szAppName))
{
	SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
	return 0;
}

wc.style         = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hInstance;
wc.hIcon         = LoadIcon(hInstance, NULL);
wc.hCursor       = 0;
wc.hbrBackground = 0;
wc.lpszMenuName  = NULL;
wc.lpszClassName = szAppName;

if(!RegisterClass(&wc))
{                                                                                                                         
	return false;
}
hWnd = CreateWindow(szAppName, 
	szAppName, 
	WS_VISIBLE|WS_SYSMENU,
            200, 
	150, 
	400, 
	200, 
	NULL, NULL, 
	hInst, NULL);
if (!hWnd)
{
    return FALSE;
}
if(!InitOGLES())
{
	return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while(!done)
{
	if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
	{
		RETAILMSG(DEBUG,(_T("Entered13

")));
if(msg.message == WM_QUIT)
{
done = true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
Render();
}

Clean();
return 0;

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

switch (message) 
{
     case WM_PAINT:
		ValidateRect(hWnd,NULL);            
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;

}

BOOL InitOGLES()
{
EGLConfig configs;
EGLint matchingConfigs;

const EGLint configAttribs[] =
{
	EGL_RED_SIZE, 8, 
	EGL_GREEN_SIZE, 8, 
	EGL_BLUE_SIZE, 8, 
	EGL_ALPHA_SIZE, EGL_DONT_CARE,
	EGL_DEPTH_SIZE, 16,
	EGL_STENCIL_SIZE, EGL_DONT_CARE,
	EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
	EGL_NONE, EGL_NONE
};
	EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };

hDC = GetDC(hWnd);

glesDisplay = eglGetDisplay(hDC);

eglInitialize(glesDisplay, NULL, NULL);
assert(eglGetError() == EGL_SUCCESS);
eglBindAPI(EGL_OPENGL_API);
assert(eglGetError() == EGL_SUCCESS);
eglChooseConfig(glesDisplay, configAttribs, &configs, 1, &matchingConfigs);
assert(eglGetError() == EGL_SUCCESS);
assert(matchingConfigs == 1);

glesSurface = eglCreateWindowSurface(glesDisplay, configs, hWnd, NULL);
assert(eglGetError() == EGL_SUCCESS);

glesContext=eglCreateContext(glesDisplay,configs,NULL,contextAttribs);
assert(eglGetError() == EGL_SUCCESS);

eglMakeCurrent(glesDisplay, glesSurface, glesSurface, glesContext);
assert(eglGetError() == EGL_SUCCESS);
glClearColorx(0, 0, 0, 0);
glShadeModel(GL_SMOOTH);

RECT r;
GetWindowRect(hWnd, &r);
glViewport(r.left, r.top, r.right - r.left, r.bottom - r.top);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthox(FixedFromInt(-50), FixedFromInt(50),FixedFromInt(-50), FixedFromInt(50), FixedFromInt(-50), FixedFromInt(50));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

return TRUE;

}

void Render()
{
static int rotation = 0;
GLshort vertexArray[9] = {-25,-25,0, 25,-25,0, 0,25,0 };
GLubyte colorArray[12] = {1,0,0,1, 0,1,0,1, 0,0,1,1};

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatex(0, 0, FixedFromInt(-10));
glRotatex(FixedFromInt(rotation++), 0, ONE,0);

glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(3, GL_SHORT, 0, vertexArray);

glEnableClientState(GL_COLOR_ARRAY);

glColorPointer(4,GL_UNSIGNED_BYTE, 0, colorArray);

glDrawArrays(GL_TRIANGLES, 0, 3);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

eglSwapBuffers(glesDisplay, glesSurface);

}

Regards,
Sowmya

As far as i can tell, you have cleared color buffer bit by calling glClear(GL_COLOR_BUFFER_BIT); But have not called glClearColor(0.25f,0.25f,0.5f,1.0f);
glclear() clears the framebuffer with colors you have loaded. And you have to first load the colors by calling glClearColor().

So add glClearColor(0.25f,0.25f,0.5f,1.0f); this call before glClear(GL_COLOR_BUFFER_BIT); . It will serve the purpose. Let me know, whether it clears your issue.

Hi,

Thank you for the reply. I added glClearColor(0.25f,0.25f,0.5f,1.0f); but still the problem exists. Only black screen is displayed. Please give me some other suggestion.
Note: OS iam used in the target device is WinCE 7.0. platform is iMX51.

Thanks and Regards,
Sowmya

hmm… I think that code needs debugging.
Actually, i don’t have windows platform to do it. If possible send me linux port of app.

Try by removing glviewport() and glclearcolorx() call in your code.

Regards,
debinar

sorry.I don’t have linux port of the application

Is your issue solved…?
Can you try by adding " EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT," in array "const EGLint configAttribs[].

Hi,

My issue got solved. There is no enough memory in the system. I increased the memory then it started working.

Regards,
Sowmya

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.