diff --git a/tools/emulator/opengl/tests/emulator_test_renderer/Android.mk b/tools/emulator/opengl/tests/emulator_test_renderer/Android.mk new file mode 100644 index 000000000..307dd9a0b --- /dev/null +++ b/tools/emulator/opengl/tests/emulator_test_renderer/Android.mk @@ -0,0 +1,33 @@ +LOCAL_PATH:=$(call my-dir) + +# test opengl renderer driver ########################### +include $(CLEAR_VARS) + +emulatorOpengl := $(LOCAL_PATH)/../.. + +LOCAL_MODULE := emulator_test_renderer +LOCAL_MODULE_TAGS := debug + +LOCAL_SRC_FILES := \ + main.cpp + +PREBUILT := $(HOST_PREBUILT_TAG) +SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config +SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags) +SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs)) + +LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0 +LOCAL_LDLIBS += $(SDL_LDLIBS) + +LOCAL_C_INCLUDES := $(emulatorOpengl)/host/include \ + $(emulatorOpengl)/host/include/libOpenglRender \ + $(emulatorOpengl)/shared/OpenglCodecCommon \ + $(emulatorOpengl)/host/libs/libOpenglRender + +LOCAL_SHARED_LIBRARIES := libOpenglRender \ + libGLESv1_dec \ + lib_renderControl_dec + +LOCAL_STATIC_LIBRARIES += libSDL libSDLmain + +include $(BUILD_HOST_EXECUTABLE) diff --git a/tools/emulator/opengl/tests/emulator_test_renderer/main.cpp b/tools/emulator/opengl/tests/emulator_test_renderer/main.cpp new file mode 100644 index 000000000..744acf4d1 --- /dev/null +++ b/tools/emulator/opengl/tests/emulator_test_renderer/main.cpp @@ -0,0 +1,84 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#undef HAVE_MALLOC_H +#include +#include +#include +#include +#include "libOpenglRender/render_api.h" + +#ifdef _WIN32 +int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) +#else +int main(int argc, char *argv[]) +#endif +{ + int portNum = 4141; + int winWidth = 320; + int winHeight = 480; + FBNativeWindowType windowId = NULL; + + // + // Inialize SDL window + // + if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_VIDEO)) { + fprintf(stderr,"SDL init failed: %s\n", SDL_GetError()); + return -1; + } + + SDL_Surface *surface = SDL_SetVideoMode(winWidth, winHeight, 32, SDL_SWSURFACE); + if (surface == NULL) { + fprintf(stderr,"Failed to set video mode: %s\n", SDL_GetError()); + return -1; + } + + SDL_SysWMinfo wminfo; + memset(&wminfo, 0, sizeof(wminfo)); + SDL_GetWMInfo(&wminfo); +#ifdef _WIN32 + windowId = wminfo.window; +#else + windowId = wminfo.info.x11.window; +#endif + + printf("initializing renderer process\n"); + + // + // initialize OpenGL renderer to render in our window + // + bool inited = initOpenGLRenderer(windowId, 0, 0, + winWidth, winHeight, portNum); + if (!inited) { + return -1; + } + printf("renderer process started\n"); + + // Just wait until the window is closed + SDL_Event ev; + while( SDL_WaitEvent(&ev) ) { + if (ev.type == SDL_QUIT) { + break; + } + } + + // + // stop the renderer + // + printf("stopping the renderer process\n"); + stopOpenGLRenderer(); + + return 0; +}