static void init_gl(Evas_Object *obj) {
    Application *ad = Application::getInstance();

    //save current ctx
    ad->_evasGL = elm_glview_evas_gl_get(obj);
    ad->_ctx = evas_gl_current_context_get(ad->_evasGL);
    ad->_sfc = evas_gl_current_surface_get(ad->_evasGL);

    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if (glview == nullptr) {
        glview = GLViewImpl::create("Cocos2dxTizen");

        int w, h;
        elm_glview_size_get(obj, &w, &h);
        glview->setFrameSize(w, h);
        director->setOpenGLView(glview);
    }

    ad->initGLContextAttrs();
    // Initialize instance and cocos2d.
    if (! ad->applicationDidFinishLaunching())
    {
        return;
    }
}
Beispiel #2
0
// draw callback is where all the main GL rendering happens
static void
_draw_gl(Evas_Object *obj)
{
   Evas_GL_API *gl = elm_glview_gl_api_get(obj);
   GLData *gld = evas_object_data_get(obj, "gld");

   if (!gld) return;
   int w, h;

   elm_glview_size_get(obj, &w, &h);

   gl->glViewport(0, 0, w, h);
   gl->glClearColor(red, 0.8, 0.3, 1);
   gl->glClear(GL_COLOR_BUFFER_BIT);

   // Draw a Triangle
   gl->glEnable(GL_BLEND);

   gl->glUseProgram(gld->program);

   gl->glBindBuffer(GL_ARRAY_BUFFER, gld->vbo);
   gl->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
   gl->glEnableVertexAttribArray(0);

   gl->glDrawArrays(GL_TRIANGLES, 0, 3);

   // Optional - Flush the GL pipeline
   gl->glFinish();

   red -= 0.1;
   if (0.0 > red) red = 1.0;
}
static void
resize_glview(Evas_Object *obj) {
	LOGI_ENTRY;
	appdata_s *ad = static_cast<appdata_s *>(evas_object_data_get(obj, "ad"));
	elm_glview_size_get(obj, &ad->glview_w, &ad->glview_h);
	SampleView *sv = static_cast<SampleView *>(evas_object_data_get(obj, "sv"));
	sv->OnWindowUpdate(ad->glview_w, ad->glview_h);
	LOGI_EXIT;
}
void
init_gles(Evas_Object *obj)
{
	ELEMENTARY_GLVIEW_USE(obj);
	appdata_s *ad = (appdata_s *)evas_object_data_get(obj, APPDATA_KEY);

	int width;
	int height;

	elm_glview_size_get(obj, &width, &height);

	ad->current_tex_index = 0;

	{
		glGenTextures(2, ad->tex_ids);

		glBindTexture(GL_TEXTURE_2D, ad->tex_ids[0]);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, IMAGE_4444_128_128_1);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

		glBindTexture(GL_TEXTURE_2D, ad->tex_ids[1]);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, IMAGE_565_128_128_1);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	}

	glShadeModel(GL_SMOOTH);

	glViewport(0, 0, width, height);

	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);

	{
		glEnable(GL_FOG);
		glFogx(GL_FOG_MODE,     GL_LINEAR);
		glFog(GL_FOG_DENSITY, GetGlUnit(0.25f));
		glFog(GL_FOG_START,   GetGlUnit(4.0f));
		glFog(GL_FOG_END,     GetGlUnit(6.5f));
		glHint(GL_FOG_HINT,     GL_DONT_CARE);
	}

	SetPerspective(obj, 60.0f, 1.0f * width / height, 1.0f, 400.0f);

	glClearColorEx(0, 0, 0, 1);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void
resize_gl(Evas_Object *obj)
{
	ELEMENTARY_GLVIEW_USE(obj);

	int width;
	int height;

	elm_glview_size_get(obj, &width, &height);

	SetPerspective(obj, 60.0f, 1.0f * width / height, 1.0f, 400.0f);
}
static void
_resize_gl(Evas_Object *obj)
{
   int w, h;
   GLData *gld = evas_object_data_get(obj, "gld");

   elm_glview_size_get(obj, &w, &h);

   // GL Viewport stuff. you can avoid doing this if viewport is all the
   // same as last frame if you want
   gears_reshape(gld, w,h);
}
Beispiel #7
0
// resize callback gets called every time object is resized
static void
_resize_gl(Evas_Object *obj)
{
   int w, h;
   GLData *gld = evas_object_data_get(obj, "gld");
   Evas_GL_API *gl = gld->glapi;

   elm_glview_size_get(obj, &w, &h);

   // GL Viewport stuff. you can avoid doing this if viewport is all the
   // same as last frame if you want
   gl->glViewport(0, 0, w, h);
}
static void
init_glview(Evas_Object *obj) {
	LOGI_ENTRY;
	appdata_s *ad = static_cast<appdata_s *>(evas_object_data_get(obj, "ad"));
	SampleView *sv = static_cast<SampleView *>(evas_object_data_get(obj, "sv"));
	elm_glview_size_get(obj, &ad->glview_w, &ad->glview_h);
	LOGI("w,h[%d,%d]",ad->glview_w, ad->glview_h);
	if (sv == nullptr) {
		LOGE("[sv] has null ptr!");
		return;
	}

	sv->Initialize(ad->glview_w, ad->glview_h);
	LOGI_EXIT;
}
Beispiel #9
0
static void resize_gl(Evas_Object *obj)
{
	appdata_s *ad = evas_object_data_get(obj, "ad");

	elm_glview_size_get(obj, &ad->glview_w, &ad->glview_h);
}