/* SolidBgVob.java * * Copyright (c) 2002, Matti Katila and Tuomas J. Lukka * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the README * file for more details. * */ /* * Written by Matti Katila and Tuomas J. Lukka */ package gzz.vob.vobs; import gzz.vob.*; import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; import gzz.gfx.gl.*; import gzz.client.GraphicsAPI; import gzz.util.ColorUtil; /** A solid clear-and-paint-background vob. * CONFUSING NAME: NOT TO BE USED FOR BOX BACKGROUNDS, THIS IS FOR WHOLE * VOBSCENES ONLY */ public class SolidBgVob extends Vob{ public static boolean dbg = false; private static void pa(String s) { System.err.println(s); } public Color color; /** Create a new SolidBgVob. */ public SolidBgVob(Color color) { this.color = color; } // AWT static Rectangle rect = new Rectangle(); public void render(Graphics g, boolean fast, Vob.RenderInfo info1, Vob.RenderInfo info2) { if(dbg) pa("Render solidbg"); g.setColor(color); g.fillRect(0, 0, 2000, 2000); g.setColor(Color.black); } // GL private String getGLStr() { return "ClearColor " + ColorUtil.colorGLString(color) + " 0\n"+ "ColorMask 1 1 1 1\n"+ "DepthMask 1\n"+ "StencilMask 255\n"+ "Clear COLOR_BUFFER_BIT DEPTH_BUFFER_BIT STENCIL_BUFFER_BIT\n"+ "Enable TEXTURE_2D\n"+ "Enable ALPHA_TEST\n"+ "AlphaFunc GREATER 0.1\n"+ "Disable BLEND\n"+ // Don't want to enable this by default // as it's fairly expensive "Enable DEPTH_TEST\n"+ "DepthFunc LEQUAL\n"+ "BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA\n"+ "Color 1 1 1 1\n"+ ""; } Vob glList; public int addToListGL(gzz.client.GraphicsAPI.Window win, int[] list, int curs, int coordsys1, int coordsys2) { if(glList == null) { glList = GLRen.createCallList( getGLStr() ); } curs = glList.addToListGL( win, list, curs, coordsys1, coordsys2); return curs; } }