Exemplo n.º 1
0
// Create rendering window.
bool cInterfaceEGL::Create(void *window_handle, bool core, bool use565) {
	EGLint egl_major, egl_minor;

	egl_dpy = OpenDisplay();

	if (!egl_dpy) {
		EGL_ILOG("Error: eglGetDisplay() failed\n");
		return false;
	}

	if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
		EGL_ILOG("Error: eglInitialize() failed\n");
		return false;
	}
	EGL_ILOG("eglInitialize() succeeded (use565=%d)\n", (int)use565);

	if (s_opengl_mode == MODE_DETECT || s_opengl_mode == MODE_DETECT_ES)
		DetectMode();

	if (!ChooseAndCreate(window_handle, core, use565) && s_opengl_mode == MODE_OPENGLES3) {
		// Fallback to ES 2.0 and try again.
		s_opengl_mode = MODE_OPENGLES2;
		if (!ChooseAndCreate(window_handle, core, use565)) {
			eglTerminate(egl_dpy);
			egl_dpy = nullptr;
			return false;
		}
	}

	return true;
}
Exemplo n.º 2
0
void OSD::Init()
{
    //PIN_MODE(PORTB, PB3,OUTPUT);
    //PIN_MODE(MAX7456_VSYNC, INPUT);
    //DIGITAL_WRITE(MAX7456_VSYNC,HIGH); //enabling pull-up resistor
    DDRB |= _BV(PB3);

    DetectMode();

    //DIGITAL_WRITE(PORTB, PB3,LOW);
    Select();;
    //read black level register
    spi_transfer(MAX7456_OSDBL_reg_read);//black level read register
    byte osdbl_r = spi_transfer(0xff);
    spi_transfer(MAX7456_VM0_reg);
    spi_transfer(MAX7456_RESET | video_mode);
    delay(50);
    //set black level
    byte osdbl_w = (osdbl_r & 0xef); //Set bit 4 to zero 11101111
    spi_transfer(MAX7456_OSDBL_reg); //black level write register
    spi_transfer(osdbl_w);

    // set all rows to same charactor white level, 90%
    for (uint8_t x = 0; x < MAX7456_screen_rows; x++)
    {
        spi_transfer(x + 0x10);
        spi_transfer(MAX7456_WHITE_level_120);
    }
    // define sync (auto,int,ext) and
    // making sure the Max7456 is enabled
    Control(1);
}
Exemplo n.º 3
0
// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceEGL::Create(void *window_handle)
{
	const char *s;
	EGLint egl_major, egl_minor;

	egl_dpy = OpenDisplay();

	if (!egl_dpy)
	{
		INFO_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
		return false;
	}

	if (!eglInitialize(egl_dpy, &egl_major, &egl_minor))
	{
		INFO_LOG(VIDEO, "Error: eglInitialize() failed\n");
		return false;
	}

	/* Detection code */
	EGLConfig config;
	EGLint num_configs;

	DetectMode();

	// attributes for a visual in RGBA format with at least
	// 8 bits per color
	int attribs[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_NONE };

	EGLint ctx_attribs[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE
	};
	switch (s_opengl_mode)
	{
		case MODE_OPENGL:
			attribs[1] = EGL_OPENGL_BIT;
			ctx_attribs[0] = EGL_NONE;
		break;
		case MODE_OPENGLES2:
			attribs[1] = EGL_OPENGL_ES2_BIT;
			ctx_attribs[1] = 2;
		break;
		case MODE_OPENGLES3:
			attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */
			ctx_attribs[1] = 3;
		break;
		default:
			ERROR_LOG(VIDEO, "Unknown opengl mode set\n");
			return false;
		break;
	}

	if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs))
	{
		INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
		exit(1);
	}

	if (s_opengl_mode == MODE_OPENGL)
		eglBindAPI(EGL_OPENGL_API);
	else
		eglBindAPI(EGL_OPENGL_ES_API);

	EGLNativeWindowType host_window = (EGLNativeWindowType) window_handle;
	EGLNativeWindowType native_window = InitializePlatform(host_window, config);

	s = eglQueryString(egl_dpy, EGL_VERSION);
	INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s);

	s = eglQueryString(egl_dpy, EGL_VENDOR);
	INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", s);

	s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
	INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", s);

	s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
	INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", s);

	egl_ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
	if (!egl_ctx)
	{
		INFO_LOG(VIDEO, "Error: eglCreateContext failed\n");
		exit(1);
	}

	egl_surf = eglCreateWindowSurface(egl_dpy, config, native_window, nullptr);
	if (!egl_surf)
	{
		INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
		exit(1);
	}

	return true;
}
Exemplo n.º 4
0
// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceEGL::Create(void *&window_handle)
{
	const char *s;
	EGLint egl_major, egl_minor;

	if (!Platform.SelectDisplay())
		return false;

	GLWin.egl_dpy = Platform.EGLGetDisplay();

	if (!GLWin.egl_dpy)
	{
		INFO_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
		return false;
	}

	GLWin.platform = Platform.platform;

	if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor))
	{
		INFO_LOG(VIDEO, "Error: eglInitialize() failed\n");
		return false;
	}

	/* Detection code */
	EGLConfig config;
	EGLint num_configs;

	DetectMode();

	// attributes for a visual in RGBA format with at least
	// 8 bits per color
	int attribs[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_NONE };

	EGLint ctx_attribs[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE
	};
	switch (s_opengl_mode)
	{
	case MODE_OPENGL:
		attribs[1] = EGL_OPENGL_BIT;
		ctx_attribs[0] = EGL_NONE;
		break;
	case MODE_OPENGLES2:
		attribs[1] = EGL_OPENGL_ES2_BIT;
		ctx_attribs[1] = 2;
		break;
	case MODE_OPENGLES3:
		attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */
		ctx_attribs[1] = 3;
		break;
	default:
		ERROR_LOG(VIDEO, "Unknown opengl mode set\n");
		return false;
		break;
	}

	if (!eglChooseConfig(GLWin.egl_dpy, attribs, &config, 1, &num_configs))
	{
		INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
		exit(1);
	}

	if (s_opengl_mode == MODE_OPENGL)
		eglBindAPI(EGL_OPENGL_API);
	else
		eglBindAPI(EGL_OPENGL_ES_API);

	if (!Platform.Init(config, window_handle))
		return false;

	s = eglQueryString(GLWin.egl_dpy, EGL_VERSION);
	INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s);

	s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR);
	INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", s);

	s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS);
	INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", s);

	s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS);
	INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", s);

	GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs);
	if (!GLWin.egl_ctx)
	{
		INFO_LOG(VIDEO, "Error: eglCreateContext failed\n");
		exit(1);
	}

	GLWin.native_window = Platform.CreateWindow();

	GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, GLWin.native_window, nullptr);
	if (!GLWin.egl_surf)
	{
		INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
		exit(1);
	}

	Platform.ToggleFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);

	window_handle = (void *)GLWin.native_window;
	return true;
}
Exemplo n.º 5
0
// Create rendering window.
bool cInterfaceEGL::Create(void *window_handle, bool core, bool use16bit)
{
	const char *s;
	EGLint egl_major, egl_minor;

	egl_dpy = OpenDisplay();

	if (!egl_dpy)
	{
		INFO_LOG(G3D, "Error: eglGetDisplay() failed\n");
		return false;
	}

	if (!eglInitialize(egl_dpy, &egl_major, &egl_minor))
	{
		INFO_LOG(G3D, "Error: eglInitialize() failed\n");
		return false;
	}
	INFO_LOG(G3D, "eglInitialize() succeeded\n");

	if (s_opengl_mode == MODE_DETECT || s_opengl_mode == MODE_DETECT_ES)
		DetectMode();

	int attribs32[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,  // Keep this first!
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_ALPHA_SIZE, 8,
		EGL_DEPTH_SIZE, 16,
		EGL_STENCIL_SIZE, 8,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_TRANSPARENT_TYPE, EGL_NONE,
		EGL_SAMPLES, 0,
		EGL_NONE, 0
	};
	int attribs16[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,  // Keep this first!
		EGL_RED_SIZE, 5,
		EGL_GREEN_SIZE, 6,
		EGL_BLUE_SIZE, 5,
		EGL_ALPHA_SIZE, 0,
		EGL_DEPTH_SIZE, 16,
		EGL_STENCIL_SIZE, 8,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_TRANSPARENT_TYPE, EGL_NONE,
		EGL_SAMPLES, 0,
		EGL_NONE, 0
	};
	int *attribs = attribs32;
	if (use16bit) {
		attribs = attribs16;
	}

	EGLint ctx_attribs[] = {
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE, 0
	};

	switch (s_opengl_mode) {
		case MODE_OPENGL:
			attribs[1] = EGL_OPENGL_BIT;
			ctx_attribs[0] = EGL_NONE;
		break;
		case MODE_OPENGLES2:
			attribs[1] = EGL_OPENGL_ES2_BIT;
			ctx_attribs[1] = 2;
		break;
		case MODE_OPENGLES3:
			attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */
			ctx_attribs[1] = 3;
		break;
		default:
			ERROR_LOG(G3D, "Unknown OpenGL mode set\n");
			return false;
		break;
	}

	EGLConfig *configs;
	EGLint num_configs;
	if (!eglChooseConfig(egl_dpy, attribs, NULL, 0, &num_configs) || num_configs == 0) {
		INFO_LOG(G3D, "Error: couldn't get a number of configs\n");
		eglTerminate(egl_dpy);
		return false;
	}

	configs = new EGLConfig[num_configs];

	if (!eglChooseConfig(egl_dpy, attribs, configs, num_configs, &num_configs)) {
		INFO_LOG(G3D, "Error: couldn't get an EGL visual config\n");
		eglTerminate(egl_dpy);
		return false;
	}

	INFO_LOG(G3D, "eglChooseConfig successful: num_configs=%d, choosing config 0", num_configs);
	for (int i = 0; i < num_configs; i++) {
		INFO_LOG(G3D, "Config %d:", i);
		LogEGLConfig(egl_dpy, configs[i]);
	}

	if (s_opengl_mode == MODE_OPENGL)
		eglBindAPI(EGL_OPENGL_API);
	else
		eglBindAPI(EGL_OPENGL_ES_API);

	EGLNativeWindowType host_window = (EGLNativeWindowType) window_handle;
	EGLNativeWindowType native_window = InitializePlatform(host_window, configs[0]);

	s = eglQueryString(egl_dpy, EGL_VERSION);
	INFO_LOG(G3D, "EGL_VERSION = %s\n", s);

	s = eglQueryString(egl_dpy, EGL_VENDOR);
	INFO_LOG(G3D, "EGL_VENDOR = %s\n", s);

	s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
	INFO_LOG(G3D, "EGL_EXTENSIONS = %s\n", s);

	s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
	INFO_LOG(G3D, "EGL_CLIENT_APIS = %s\n", s);

	egl_ctx = eglCreateContext(egl_dpy, configs[0], EGL_NO_CONTEXT, ctx_attribs);
	if (!egl_ctx) {
		INFO_LOG(G3D, "Error: eglCreateContext failed: %s\n", EGLGetErrorString(eglGetError()));
		eglTerminate(egl_dpy);
		delete[] configs;
		return false;
	}

	egl_surf = eglCreateWindowSurface(egl_dpy, configs[0], native_window, nullptr);
	if (!egl_surf) {
		INFO_LOG(G3D, "Error: eglCreateWindowSurface failed: native_window=%p error=%s ctx_attribs[1]==%d\n", native_window, EGLGetErrorString(eglGetError()), ctx_attribs[1]);

		eglDestroyContext(egl_dpy, egl_ctx);
		eglTerminate(egl_dpy);
		delete[] configs;
		return false;
	}

	delete[] configs;
	return true;
}