绘制文本后无法绘制任何四边形?
Can't draw any quads after drawing text?
所以我正在制作一款 3d 游戏,我现在正在 3d 上的 2d 上工作,但在我完成它之前只有一个问题,那就是:我无法在绘制后绘制任何 2d 四边形文字?
这是渲染器代码:
changeto2D();
for (Face2D face : tds){
face.initializeEdges();
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor4f(face.c.red, face.c.green, face.c.blue, (float) Math.sin(Math.toRadians(face.transparency)));
for (Location l : face.edges){
GL11.glVertex2f(l.x, l.y);
}
GL11.glEnd();
}
for (Text t : texts){
t.draw();
}
fps++;
for (GUI gui : openGUIs){
gui.draw();
}
for (GUI gui : removing){
if (openGUIs.contains(gui)) openGUIs.remove(gui);
}
removing.clear();
这是 changeTo2D();
的代码:
public void changeto2D() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
}
并绘制文本:
public Text(Location loc, String text, float size, Color color){
try {
InputStream inputStream = ResourceLoader.getResourceAsStream("res\AGENCYR.TTF");
Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
awtFont2 = awtFont2.deriveFont(size);
font = new TrueTypeFont(awtFont2, false);
} catch (Exception e) {
e.printStackTrace();
}
c = new org.newdawn.slick.Color(color.red, color.green, color.blue);
this.loc = loc;
this.text = text;
this.size = size;
}
public void draw(){
font.drawString(loc.x, loc.y, text, c);
if (td != null){
td.draw();
}
}
现在我的问题是:
我想制作一个包含四边形的 GUI,但即使其他四边形绘制得很好,它也不会绘制?我还尝试在绘制文本后放置所有四边形的代码,四边形根本不会绘制。
我修好了,只是给自己做了另一种渲染技术。先绘制所有四边形,最后绘制文本。
所以我正在制作一款 3d 游戏,我现在正在 3d 上的 2d 上工作,但在我完成它之前只有一个问题,那就是:我无法在绘制后绘制任何 2d 四边形文字? 这是渲染器代码:
changeto2D();
for (Face2D face : tds){
face.initializeEdges();
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor4f(face.c.red, face.c.green, face.c.blue, (float) Math.sin(Math.toRadians(face.transparency)));
for (Location l : face.edges){
GL11.glVertex2f(l.x, l.y);
}
GL11.glEnd();
}
for (Text t : texts){
t.draw();
}
fps++;
for (GUI gui : openGUIs){
gui.draw();
}
for (GUI gui : removing){
if (openGUIs.contains(gui)) openGUIs.remove(gui);
}
removing.clear();
这是 changeTo2D();
的代码:
public void changeto2D() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());
}
并绘制文本:
public Text(Location loc, String text, float size, Color color){
try {
InputStream inputStream = ResourceLoader.getResourceAsStream("res\AGENCYR.TTF");
Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
awtFont2 = awtFont2.deriveFont(size);
font = new TrueTypeFont(awtFont2, false);
} catch (Exception e) {
e.printStackTrace();
}
c = new org.newdawn.slick.Color(color.red, color.green, color.blue);
this.loc = loc;
this.text = text;
this.size = size;
}
public void draw(){
font.drawString(loc.x, loc.y, text, c);
if (td != null){
td.draw();
}
}
现在我的问题是: 我想制作一个包含四边形的 GUI,但即使其他四边形绘制得很好,它也不会绘制?我还尝试在绘制文本后放置所有四边形的代码,四边形根本不会绘制。
我修好了,只是给自己做了另一种渲染技术。先绘制所有四边形,最后绘制文本。