Beispiel #1
0
void
AG_GLViewDraw(void *obj)
{
    AG_GLView *glv = obj;
    AG_Driver *drv = WIDGET(glv)->drv;
    GLint vpSave[4];
    Uint hView;

    glGetIntegerv(GL_VIEWPORT, vpSave);

    if (glv->flags & AG_GLVIEW_INIT_MATRICES) {
        glv->flags &= ~(AG_GLVIEW_INIT_MATRICES);
        SetIdentity(glv->mProjection, GL_PROJECTION);
        SetIdentity(glv->mModelview, GL_MODELVIEW);
        SetIdentity(glv->mTexture, GL_TEXTURE);
    }
    if (glv->flags & AG_GLVIEW_RESHAPE) {
        glv->flags &= ~(AG_GLVIEW_RESHAPE);
        AG_GLViewReshape(glv);
    }

    if (AGDRIVER_SINGLE(drv)) {
        hView = AGDRIVER_SW(drv)->h;
    } else {
        hView = HEIGHT(WIDGET(glv)->window);
    }
    glViewport(WIDGET(glv)->rView.x1,
               hView - WIDGET(glv)->rView.y2,
               WIDTH(glv), HEIGHT(glv));

    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glLoadMatrixf(glv->mTexture);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadMatrixf(glv->mProjection);

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadMatrixf(glv->mModelview);

    glPushAttrib(GL_TRANSFORM_BIT);
    glDisable(GL_CLIP_PLANE0);
    glDisable(GL_CLIP_PLANE1);
    glDisable(GL_CLIP_PLANE2);
    glDisable(GL_CLIP_PLANE3);

    if (glv->draw_ev != NULL)
        glv->draw_ev->handler(glv->draw_ev);

    glPopAttrib();

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glMatrixMode(GL_TEXTURE);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();

    glViewport(vpSave[0], vpSave[1], vpSave[2], vpSave[3]);

    if (glv->overlay_ev != NULL)
        glv->overlay_ev->handler(glv->overlay_ev);
}
Beispiel #2
0
void
AG_GLViewDraw(void *obj)
{
	AG_GLView *glv = obj;
	AG_Driver *drv = WIDGET(glv)->drv;
	Uint hView;
	
	if (glv->flags & AG_GLVIEW_BGFILL) {
		AG_DrawRect(glv,
		    AG_RECT(0,0, WIDTH(glv), HEIGHT(glv)),
		    glv->bgColor);
	}
	if (glv->underlay_ev != NULL)
		glv->underlay_ev->handler(glv->underlay_ev);

	glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);

	if (glv->flags & AG_GLVIEW_INIT_MATRICES) {
		glv->flags &= ~(AG_GLVIEW_INIT_MATRICES);
		SetIdentity(glv->mProjection, GL_PROJECTION);
		SetIdentity(glv->mModelview, GL_MODELVIEW);
		SetIdentity(glv->mTexture, GL_TEXTURE);
	}
	if (glv->flags & AG_GLVIEW_RESHAPE) {
		glv->flags &= ~(AG_GLVIEW_RESHAPE);
		AG_GLViewReshape(glv);
	}

	if (AGDRIVER_SINGLE(drv)) {
		hView = AGDRIVER_SW(drv)->h;
	} else {
		hView = HEIGHT(WIDGET(glv)->window);
	}
	glViewport(WIDGET(glv)->rView.x1,
	           hView - WIDGET(glv)->rView.y2,
	           WIDTH(glv), HEIGHT(glv));
	
	glMatrixMode(GL_TEXTURE);
	glPushMatrix();
	glLoadMatrixf(glv->mTexture);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadMatrixf(glv->mProjection);
	
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadMatrixf(glv->mModelview);

	glDisable(GL_CLIP_PLANE0);
	glDisable(GL_CLIP_PLANE1);
	glDisable(GL_CLIP_PLANE2);
	glDisable(GL_CLIP_PLANE3);
	
	if (glv->draw_ev != NULL)
		glv->draw_ev->handler(glv->draw_ev);
	
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_TEXTURE);
	glPopMatrix();

	/* restore transform and viewport */
	glPopAttrib();

	if (glv->overlay_ev != NULL) {
		glPushAttrib(GL_TRANSFORM_BIT);
		glv->overlay_ev->handler(glv->overlay_ev);
		glPopAttrib();
	}
}