This function will limit the rendering to a given region.. everything outside this region will be cliped..
the second funktion will clear all cliping, so that rendering will continue like before..
#include <SFML/Graphics.hpp>
#include <iostream>
void SetClipRegion(sf::FloatRect Region)
{
glEnable(GL_CLIP_PLANE0);
glEnable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE2);
glEnable(GL_CLIP_PLANE3);
double plane [4]={0,0,0,0};
plane[1]=1;
plane[3]=-Region.Top;
glClipPlane(GL_CLIP_PLANE0, &plane[0]);
plane[1]=-1;
plane[3]=Region.Bottom;
glClipPlane(GL_CLIP_PLANE1, &plane[0]);
plane[0]=1;
plane[1]=0;
plane[3]=-Region.Left;
glClipPlane(GL_CLIP_PLANE2, &plane[0]);
plane[0]=-1;
plane[3]=Region.Right;
glClipPlane(GL_CLIP_PLANE3, &plane[0]);
}
void ClearClipRegion()
{
glDisable(GL_CLIP_PLANE0);
glDisable(GL_CLIP_PLANE1);
glDisable(GL_CLIP_PLANE2);
glDisable(GL_CLIP_PLANE3);
}
greetz TGM