本文整理汇总了C++中Evas_GL_API::glViewport方法的典型用法代码示例。如果您正苦于以下问题:C++ Evas_GL_API::glViewport方法的具体用法?C++ Evas_GL_API::glViewport怎么用?C++ Evas_GL_API::glViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Evas_GL_API
的用法示例。
在下文中一共展示了Evas_GL_API::glViewport方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 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;
}
示例2: createGLSurface
bool EwkView::createGLSurface()
{
if (!m_isAccelerated)
return true;
static Evas_GL_Config evasGLConfig = {
EVAS_GL_RGBA_8888,
EVAS_GL_DEPTH_BIT_8,
EVAS_GL_STENCIL_NONE,
EVAS_GL_OPTIONS_NONE,
EVAS_GL_MULTISAMPLE_NONE,
#if defined(EVAS_GL_API_VERSION) && EVAS_GL_API_VERSION >= 2
EVAS_GL_GLES_2_X
#endif
};
// Recreate to current size: Replaces if non-null, and frees existing surface after (OwnPtr).
if (deviceSize().width() && deviceSize().height()) {
Evas_GL_Surface* surface = nullptr;
surface = evas_gl_surface_create(m_evasGL, &evasGLConfig, deviceSize().width(), deviceSize().height());
if (!surface)
return false;
m_evasGLSurface = std::make_unique<EvasGLSurface>(m_evasGL, surface);
}
if (!m_evasGLSurface)
return false;
Evas_Native_Surface nativeSurface;
evas_gl_native_surface_get(m_evasGL, m_evasGLSurface->surface(), &nativeSurface);
evas_object_image_native_surface_set(smartData()->image, &nativeSurface);
evas_gl_make_current(m_evasGL, m_evasGLSurface->surface(), m_evasGLContext->context());
Evas_GL_API* gl = evas_gl_api_get(m_evasGL);
WKPoint boundsEnd = WKViewUserViewportToScene(wkView(), WKPointMake(deviceSize().width(), deviceSize().height()));
gl->glViewport(0, 0, boundsEnd.x, boundsEnd.y);
gl->glClearColor(1.0, 1.0, 1.0, 0);
gl->glClear(GL_COLOR_BUFFER_BIT);
return true;
}
示例3: memcpy
/* new window size or exposure */
static void
gears_reshape(GLData *gld, int width, int height)
{
Evas_GL_API *gl = gld->glapi;
GLfloat ar, m[16] = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.1, 0.0,
0.0, 0.0, 0.0, 1.0
};
if (width < height)
ar = width;
else
ar = height;
m[0] = 0.1 * ar / width;
m[5] = 0.1 * ar / height;
memcpy(gld->proj, m, sizeof gld->proj);
gl->glViewport(0, 0, (GLint) width, (GLint) height);
}