GRIM: Create Iris with TRIANGLE_STRIP for OpenGL

This commit is contained in:
Einar Johan T. Sømåen 2011-07-28 01:36:27 +02:00
parent cc4fcd3ffc
commit fd95d82ae1
6 changed files with 66 additions and 5 deletions

View File

@ -107,6 +107,15 @@ public:
virtual void copyStoredToDisplay() = 0;
virtual void dimScreen() = 0;
virtual void dimRegion(int x, int y, int w, int h, float level) = 0;
/**
* Draw a completely opaque Iris around the specified rectangle.
* the arguments specify the distance from the screen-edge to the first
* non-iris pixel.
*
* @param x the width of the Iris
* @param y the height of the Iris
*/
virtual void irisAroundRegion(int x, int y) = 0;
virtual void drawEmergString(int x, int y, const char *text, const Color &fgColor) = 0;
virtual void loadEmergFont() = 0;

View File

@ -1273,7 +1273,51 @@ void GfxOpenGL::dimRegion(int x, int yReal, int w, int h, float level) {
delete[] data;
}
void GfxOpenGL::irisAroundRegion(int x, int y)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, _screenWidth, _screenHeight, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
glDepthMask(GL_FALSE);
glColor3f(0.0f, 0.0f, 0.0f);
float points[] = {
0.0f, 0.0f, 0.0f,
0.0f, y, 0.0f,
_screenWidth, 0.0f, 0.0f,
_screenWidth, y, 0.0f,
_screenWidth - x, y, 0.0f,
_screenWidth, _screenHeight, 0.0f,
_screenWidth - x, _screenHeight, 0.0f,
_screenWidth - x, _screenHeight - y, 0.0f,
0.0f, _screenHeight, 0.0f,
0.0f, _screenHeight - y, 0.0f,
0.0f + x, _screenHeight - y, 0.0f,
0.0f, y, 0.0f,
x, y, 0.0f
};
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0 ;i < 13; i++) {
glVertex3fv(points+3*i);
}
glEnd();
glColor3f(1.0f,1.0f,1.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glDepthMask(GL_TRUE);
}
void GfxOpenGL::drawRectangle(PrimitiveObject *primitive) {
int x1 = primitive->getP1().x;
int y1 = primitive->getP1().y;

View File

@ -103,6 +103,7 @@ public:
void copyStoredToDisplay();
void dimScreen();
void dimRegion(int x, int y, int w, int h, float level);
void irisAroundRegion(int x, int y);
void drawEmergString(int x, int y, const char *text, const Color &fgColor);
void loadEmergFont();

View File

@ -959,6 +959,16 @@ void GfxTinyGL::dimRegion(int x, int y, int w, int h, float level) {
}
}
}
void GfxTinyGL::irisAroundRegion(int x, int y)
{
//TODO: Simplify this to one double loop
dimRegion(0, 0, 640, y, 0);
dimRegion(0, y, x, 479 - y, 0);
dimRegion(x, 479 - y, 640 - x, y, 0);
dimRegion(640 - x, y, x, 479 - y, 0);
}
void GfxTinyGL::drawRectangle(PrimitiveObject *primitive) {
uint16 *dst = (uint16 *)_zb->pbuf;

View File

@ -91,6 +91,7 @@ public:
void dimScreen();
void dimRegion(int x, int y, int w, int h, float level);
void irisAroundRegion(int x, int y);
Bitmap *getScreenshot(int w, int h);
void storeDisplay();

View File

@ -53,11 +53,7 @@ void Iris::draw() {
return;
}
// Why doesn't 480 work here??
g_driver->dimRegion(0, 0, 640, _y, 0);
g_driver->dimRegion(0, _y, _x, 479 - _y, 0);
g_driver->dimRegion(_x, 479 - _y, 640 - _x, _y, 0);
g_driver->dimRegion(640 - _x, _y, _x, 479 - _y, 0);
g_driver->irisAroundRegion(_x, _y);
}
void Iris::update(int frameTime) {