egl/sfegltest/src/eglrendering.cpp
branchbug235_bringup_0
changeset 203 71a455a885b7
parent 202 5b9bcf58d962
child 204 3f7664f3b0f4
equal deleted inserted replaced
202:5b9bcf58d962 203:71a455a885b7
    19 
    19 
    20 const TInt KTimerDelay = 0;
    20 const TInt KTimerDelay = 0;
    21 
    21 
    22 
    22 
    23 /** Attributes to be passed into eglChooseConfig */
    23 /** Attributes to be passed into eglChooseConfig */
    24 const EGLint	KColorRGB565AttribList[] =
    24 const EGLint	KColorRGBA8888AttribList[] =
    25 		{
    25 		{
    26 		EGL_RED_SIZE,			5,
    26 		EGL_RED_SIZE,			8,
    27 		EGL_GREEN_SIZE,			6,
    27 		EGL_GREEN_SIZE,			8,
    28 		EGL_BLUE_SIZE,			5,
    28 		EGL_BLUE_SIZE,			8,
       
    29         EGL_ALPHA_SIZE,         8,
    29 		EGL_SURFACE_TYPE,		EGL_WINDOW_BIT,
    30 		EGL_SURFACE_TYPE,		EGL_WINDOW_BIT,
    30 		EGL_RENDERABLE_TYPE, 	EGL_OPENVG_BIT,
    31 		EGL_RENDERABLE_TYPE, 	EGL_OPENVG_BIT,
    31 		EGL_NONE
    32 		EGL_NONE
    32 		};
    33 		};
    33 
    34 
   176 
   177 
   177 	EGLint numConfigs;
   178 	EGLint numConfigs;
   178 	EGLConfig chosenConfig = 0;
   179 	EGLConfig chosenConfig = 0;
   179 
   180 
   180 	// Choose the config to use
   181 	// Choose the config to use
   181 	EGLCheckReturnError(eglChooseConfig(iDisplay, KColorRGB565AttribList, &chosenConfig, 1, &numConfigs));
   182 	EGLCheckReturnError(eglChooseConfig(iDisplay, KColorRGBA8888AttribList, &chosenConfig, 1, &numConfigs));
   182 	RDebug::Printf("CEGLRendering::ConstructL 3");
   183 	RDebug::Printf("CEGLRendering::ConstructL 3");
   183 	if (numConfigs == 0)
   184 	if (numConfigs == 0)
   184 		{
   185 		{
   185 		RDebug::Printf("No matching configs found", eglQueryString(iDisplay, EGL_EXTENSIONS));
   186 		RDebug::Printf("No matching configs found", eglQueryString(iDisplay, EGL_EXTENSIONS));
   186 		User::Leave(KErrNotSupported);
   187 		User::Leave(KErrNotSupported);
   208 	RDebug::Printf("CEGLRendering::ConstructL 7");
   209 	RDebug::Printf("CEGLRendering::ConstructL 7");
   209 	EGLCheckError();
   210 	EGLCheckError();
   210 	
   211 	
   211 	CEGLRendering::EGLCheckReturnError(eglMakeCurrent(iDisplay, iSurface, iSurface, iContextVG));
   212 	CEGLRendering::EGLCheckReturnError(eglMakeCurrent(iDisplay, iSurface, iSurface, iContextVG));
   212 	RDebug::Printf("CEGLRendering::ConstructL 8");
   213 	RDebug::Printf("CEGLRendering::ConstructL 8");
   213 	
   214 
   214     VGfloat clearColour[] = { 0.5f, 0.5f, 0.5f, 1.0f };
   215     // Now try and draw a line (blue)
   215     vgSetfv(VG_CLEAR_COLOR, 4, clearColour);
   216     static VGubyte const starSegments[] = 
   216     RDebug::Printf("CEGLRendering::ConstructL 9");
   217         {
   217     vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED);
   218         VG_MOVE_TO_ABS,
   218     RDebug::Printf("CEGLRendering::ConstructL 10");
   219         VG_LINE_TO_REL,
   219     vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
   220         VG_CLOSE_PATH
   220     RDebug::Printf("CEGLRendering::ConstructL 11");
   221         };
   221     vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
   222     
   222     RDebug::Printf("CEGLRendering::ConstructL 12");
   223     static VGfloat const starCoords[] = 
   223     vgClear(0, 0, windowSize.iWidth, windowSize.iHeight);
   224         {
   224     RDebug::Printf("CEGLRendering::ConstructL 13");
   225         110, 35,
       
   226         50, 160,
       
   227         };
       
   228         
       
   229         
       
   230     VGfloat strokeColor[4]  = {1.f, 0.f, 0.f, 1.f};
       
   231     
       
   232     VGPaint strokePaint = vgCreatePaint();
       
   233 
       
   234     vgSetParameteri(strokePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
       
   235     vgSetParameterfv(strokePaint, VG_PAINT_COLOR, 4, strokeColor);
       
   236     
       
   237     VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
       
   238                             VG_PATH_DATATYPE_F,
       
   239                             1.0f, // scale
       
   240                             0.0f, // bias
       
   241                             3,    // segmentCapacityHint
       
   242                             4,   // coordCapacityHint
       
   243                             VG_PATH_CAPABILITY_ALL);
       
   244                             
       
   245     ASSERT(vgGetError() == VG_NO_ERROR);
       
   246     RDebug::Printf("vgCreatePath");
       
   247     
       
   248                             
       
   249     vgAppendPathData(path, sizeof(starSegments), starSegments, starCoords);
       
   250     ASSERT(vgGetError() == VG_NO_ERROR);
       
   251     RDebug::Printf("vgAppendPathData");
       
   252     
       
   253     // Draw the star directly using the OpenVG API.
       
   254     vgDrawPath(path, VG_FILL_PATH | VG_STROKE_PATH);
       
   255     ASSERT(vgGetError() == VG_NO_ERROR);
       
   256     RDebug::Printf("vgDrawPath");
       
   257     
   225     eglSwapBuffers(iDisplay, iSurface);
   258     eglSwapBuffers(iDisplay, iSurface);
   226     RDebug::Printf("CEGLRendering::ConstructL 14");
   259     RDebug::Printf("eglSwapBuffers");
       
   260     EGLCheckError();
   227 	}
   261 	}
   228 
   262 
   229 
   263 
   230 /** Update the display */
   264 /** Update the display */
   231 void CEGLRendering::UpdateDisplay()
   265 void CEGLRendering::UpdateDisplay()