am fec5d38b: Merge "option to enable multisampling" into gingerbread
Merge commit 'fec5d38baf4487d8ab0143451a3f2c39edeeb5b2' into gingerbread-plus-aosp * commit 'fec5d38baf4487d8ab0143451a3f2c39edeeb5b2': option to enable multisampling
This commit is contained in:
@@ -63,7 +63,7 @@ using namespace android;
|
|||||||
int gAppAlive = 1;
|
int gAppAlive = 1;
|
||||||
|
|
||||||
static const char sAppName[] =
|
static const char sAppName[] =
|
||||||
"San Angeles Observation OpenGL ES version example (Linux)";
|
"San Angeles Observation OpenGL ES version example (Linux)";
|
||||||
|
|
||||||
static int sWindowWidth = WINDOW_DEFAULT_WIDTH;
|
static int sWindowWidth = WINDOW_DEFAULT_WIDTH;
|
||||||
static int sWindowHeight = WINDOW_DEFAULT_HEIGHT;
|
static int sWindowHeight = WINDOW_DEFAULT_HEIGHT;
|
||||||
@@ -74,22 +74,22 @@ static EGLSurface sEglSurface = EGL_NO_SURFACE;
|
|||||||
const char *egl_strerror(unsigned err)
|
const char *egl_strerror(unsigned err)
|
||||||
{
|
{
|
||||||
switch(err){
|
switch(err){
|
||||||
case EGL_SUCCESS: return "SUCCESS";
|
case EGL_SUCCESS: return "SUCCESS";
|
||||||
case EGL_NOT_INITIALIZED: return "NOT INITIALIZED";
|
case EGL_NOT_INITIALIZED: return "NOT INITIALIZED";
|
||||||
case EGL_BAD_ACCESS: return "BAD ACCESS";
|
case EGL_BAD_ACCESS: return "BAD ACCESS";
|
||||||
case EGL_BAD_ALLOC: return "BAD ALLOC";
|
case EGL_BAD_ALLOC: return "BAD ALLOC";
|
||||||
case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE";
|
case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE";
|
||||||
case EGL_BAD_CONFIG: return "BAD CONFIG";
|
case EGL_BAD_CONFIG: return "BAD CONFIG";
|
||||||
case EGL_BAD_CONTEXT: return "BAD CONTEXT";
|
case EGL_BAD_CONTEXT: return "BAD CONTEXT";
|
||||||
case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE";
|
case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE";
|
||||||
case EGL_BAD_DISPLAY: return "BAD DISPLAY";
|
case EGL_BAD_DISPLAY: return "BAD DISPLAY";
|
||||||
case EGL_BAD_MATCH: return "BAD MATCH";
|
case EGL_BAD_MATCH: return "BAD MATCH";
|
||||||
case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP";
|
case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP";
|
||||||
case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW";
|
case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW";
|
||||||
case EGL_BAD_PARAMETER: return "BAD PARAMETER";
|
case EGL_BAD_PARAMETER: return "BAD PARAMETER";
|
||||||
case EGL_BAD_SURFACE: return "BAD_SURFACE";
|
case EGL_BAD_SURFACE: return "BAD_SURFACE";
|
||||||
// case EGL_CONTEXT_LOST: return "CONTEXT LOST";
|
// case EGL_CONTEXT_LOST: return "CONTEXT LOST";
|
||||||
default: return "UNKNOWN";
|
default: return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,52 +118,59 @@ static void checkEGLErrors()
|
|||||||
fprintf(stderr, "EGL Error: 0x%04x\n", (int)error);
|
fprintf(stderr, "EGL Error: 0x%04x\n", (int)error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int initGraphics()
|
static int initGraphics(unsigned samples)
|
||||||
{
|
{
|
||||||
EGLint configAttribs[] = {
|
EGLint configAttribs[] = {
|
||||||
EGL_DEPTH_SIZE, 16,
|
EGL_DEPTH_SIZE, 16,
|
||||||
EGL_NONE
|
EGL_SAMPLE_BUFFERS, samples ? 1 : 0,
|
||||||
};
|
EGL_SAMPLES, samples,
|
||||||
|
EGL_NONE
|
||||||
EGLint majorVersion;
|
};
|
||||||
EGLint minorVersion;
|
|
||||||
EGLContext context;
|
|
||||||
EGLConfig config;
|
|
||||||
EGLSurface surface;
|
|
||||||
EGLint w, h;
|
|
||||||
EGLDisplay dpy;
|
|
||||||
|
|
||||||
EGLNativeWindowType window = android_createDisplaySurface();
|
EGLint majorVersion;
|
||||||
|
EGLint minorVersion;
|
||||||
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
EGLContext context;
|
||||||
eglInitialize(dpy, &majorVersion, &minorVersion);
|
EGLConfig config;
|
||||||
|
EGLSurface surface;
|
||||||
status_t err = EGLUtils::selectConfigForNativeWindow(
|
EGLint w, h;
|
||||||
dpy, configAttribs, window, &config);
|
EGLDisplay dpy;
|
||||||
if (err) {
|
|
||||||
fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
surface = eglCreateWindowSurface(dpy, config, window, NULL);
|
EGLNativeWindowType window = android_createDisplaySurface();
|
||||||
egl_error("eglCreateWindowSurface");
|
|
||||||
|
|
||||||
fprintf(stderr,"surface = %p\n", surface);
|
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
eglInitialize(dpy, &majorVersion, &minorVersion);
|
||||||
|
|
||||||
context = eglCreateContext(dpy, config, NULL, NULL);
|
status_t err = EGLUtils::selectConfigForNativeWindow(
|
||||||
egl_error("eglCreateContext");
|
dpy, configAttribs, window, &config);
|
||||||
fprintf(stderr,"context = %p\n", context);
|
if (err) {
|
||||||
|
fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n");
|
||||||
eglMakeCurrent(dpy, surface, surface, context);
|
return 0;
|
||||||
egl_error("eglMakeCurrent");
|
}
|
||||||
|
|
||||||
eglQuerySurface(dpy, surface, EGL_WIDTH, &sWindowWidth);
|
surface = eglCreateWindowSurface(dpy, config, window, NULL);
|
||||||
eglQuerySurface(dpy, surface, EGL_HEIGHT, &sWindowHeight);
|
egl_error("eglCreateWindowSurface");
|
||||||
|
|
||||||
|
fprintf(stderr,"surface = %p\n", surface);
|
||||||
|
|
||||||
|
context = eglCreateContext(dpy, config, NULL, NULL);
|
||||||
|
egl_error("eglCreateContext");
|
||||||
|
fprintf(stderr,"context = %p\n", context);
|
||||||
|
|
||||||
|
eglMakeCurrent(dpy, surface, surface, context);
|
||||||
|
egl_error("eglMakeCurrent");
|
||||||
|
|
||||||
|
eglQuerySurface(dpy, surface, EGL_WIDTH, &sWindowWidth);
|
||||||
|
eglQuerySurface(dpy, surface, EGL_HEIGHT, &sWindowHeight);
|
||||||
|
|
||||||
sEglDisplay = dpy;
|
sEglDisplay = dpy;
|
||||||
sEglSurface = surface;
|
sEglSurface = surface;
|
||||||
sEglContext = context;
|
sEglContext = context;
|
||||||
|
|
||||||
|
if (samples == 0) {
|
||||||
|
// GL_MULTISAMPLE is enabled by default
|
||||||
|
glDisable(GL_MULTISAMPLE);
|
||||||
|
}
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,11 +186,14 @@ static void deinitGraphics()
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// not referenced:
|
unsigned samples = 0;
|
||||||
argc = argc;
|
printf("usage: %s [samples]\n", argv[0]);
|
||||||
argv = argv;
|
if (argc == 2) {
|
||||||
|
samples = atoi( argv[1] );
|
||||||
|
printf("Multisample enabled: GL_SAMPLES = %u\n", samples);
|
||||||
|
}
|
||||||
|
|
||||||
if (!initGraphics())
|
if (!initGraphics(samples))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Graphics initialization failed.\n");
|
fprintf(stderr, "Graphics initialization failed.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -195,7 +205,7 @@ int main(int argc, char *argv[])
|
|||||||
int frameCount = 0;
|
int frameCount = 0;
|
||||||
gettimeofday(&timeTemp, NULL);
|
gettimeofday(&timeTemp, NULL);
|
||||||
double totalTime = timeTemp.tv_usec/1000000.0 + timeTemp.tv_sec;
|
double totalTime = timeTemp.tv_usec/1000000.0 + timeTemp.tv_sec;
|
||||||
|
|
||||||
while (gAppAlive)
|
while (gAppAlive)
|
||||||
{
|
{
|
||||||
struct timeval timeNow;
|
struct timeval timeNow;
|
||||||
|
|||||||
Reference in New Issue
Block a user