I have been working on a small game test. I have several classes.
A class for the First Person Control.
A class to get the frame-rate from cached frame times.
A class that is the World-Render Manager.
An abstract class that is used to define different pre-made shapes.
Several classes that extend that class. These are the Shape classes.
A settings class that holds stuff like fps sensitivity, is game paused, key controls, etc...
And my main class.
there are a few other classes.
the process is. In the main loop I use a method of the world renderer, which at this point just calls the render method on the shape object I pass through, plus setting color.
- Main Loop passes a RenderShape object into the world renderer
- World Renderer runs the render method on the shape after setting up some stuff
- RenderShape object render method sets all the vertices up and etc...
My problem is that even though I render the objects (and the debug shows they render) the objects do not appear on the screen.
Everything else works perfectly.
Here are my codes that deal with anything with rendering.
----------------------------------------------------------------
In my main loop: render is a WorldRenderer object.
DisplayMain.java(Part of it at least)
render.addShape ( RenderShape.CUBE, 0F, 0F, 0F);
render.addShape ( RenderShape.CUBE, 2F, 4F, 2F);
render.addShape ( RenderShape.CUBE, 3F, 6F, 2F);
render.addRGBShape ( RenderShape.CUBE, 1F, 0F, 1F, 1F, 0.4F, 0F);
render.addRGBShape ( RenderShape.CUBE, 1F, 0F, 1F, 1F, 0.4F, 0F);
render.addRGBShape ( RenderShape.CUBE, 2F, 1F, 6F, 1F, 0.4F, 0F);
WorldRenderer.java
public class WorldRender {
public WorldRender(){
}
public void addShape(RenderShape s, Float x, Float y, Float z){
GL11.glColor3f(1.0f,0.25f,0.25f);
s.render(x, y, z);
}
public void addRGBShape(RenderShape s, Float x, Float y, Float z, Float r, Float g, Float b){
GL11.glColor3f(r,g,b);
s.render(x, y, z);
}
}
RenderShape.java
public abstract class RenderShape{
public RenderShape(){}
public abstract void render(float x, float y, float z);
public abstract void scale(float f);
//Define Shapes
public static RenderShape UVSPHERE;// NOT MADE YET
public static RenderShape CUBE = new RenderBox();
public static RenderShape PLANE = new RenderPlane();
public static RenderShape ICOSPHERE;// NOT MADE YET
public static RenderShape CYLINDER_8;// NOT MADE YET
public static RenderShape CYLINDER_16;// NOT MADE YET
public static RenderShape CYLINDER_32;// NOT MADE YET
public static RenderShape CONE;// NOT MADE YET
public static RenderShape CIRCLE;// NOT MADE YET
}
RenderBox.java
public class RenderBox extends RenderShape{
public RenderBox() {
}
public void render(float x, float y, float z){
Vertex v1 = Shape.makeVertice(x+(1F*scale), y+(1F*scale), z+(1F*scale));
Vertex v2 = Shape.makeVertice(x+(1F*scale), y-(1F*scale), z+(1F*scale));
Vertex v3 = Shape.makeVertice(x-(1F*scale), y-(1F*scale), z+(1F*scale));
Vertex v4 = Shape.makeVertice(x-(1F*scale), y+(1F*scale), z+(1F*scale));
Vertex v5 = Shape.makeVertice(x+(1F*scale), y+(1F*scale), z-(1F*scale));
Vertex v6 = Shape.makeVertice(x+(1F*scale), y-(1F*scale), z-(1F*scale));
Vertex v7 = Shape.makeVertice(x-(1F*scale), y-(1F*scale), z-(1F*scale));
Vertex v8 = Shape.makeVertice(x-(1F*scale), y+(1F*scale), z-(1F*scale));
GL11.glBegin(GL11.GL_QUADS);
Face.RENDERFACE_QUAD(v1, v2, v3, v4);
Face.RENDERFACE_QUAD(v5, v6, v7, v8);
Face.RENDERFACE_QUAD(v1, v2, v5, v6);
Face.RENDERFACE_QUAD(v3, v4, v7, v8);
Face.RENDERFACE_QUAD(v2, v3, v6, v7);
Face.RENDERFACE_QUAD(v1, v4, v5, v8);
GL11.glEnd();
}
public void scale(float i){
scale=i;
}
private float scale;
}
RenderPlane.java
public class RenderPlane extends RenderShape{
public RenderPlane() {
}
public void render(float x, float y, float z){
Vertex v1 = new Vertex(x+(1F*scale), y, z+(1F*scale));
Vertex v2 = new Vertex(x-(1F*scale), y, z+(1F*scale));
Vertex v3 = new Vertex(x+(1F*scale), y, z-(1F*scale));
Vertex v4 = new Vertex(x-(1F*scale), y, z-(1F*scale));
GL11.glBegin(GL11.GL_QUADS);
Face.RENDERFACE_QUAD(v1, v2, v3, v4);
GL11.glEnd();
}
public void scale(float i){
scale=i;
}
private float scale;
}
Vertex.java
public class Vertex{
public Vertex(Float x, Float y, Float z){
_x=x;
_y=y;
_z=z;
}
public Float getX(){
return _x;
}
public Float getY(){
return _y;
}
public Float getZ(){
return _z;
}
public void setXYZ(Float x, Float y, Float z){
_x=x;
_y=y;
_z=z;
}
public Float[] getXYZ(){
return new Float[]{_x, _y, _z};
}
private Float _x;
private Float _y;
private Float _z;
}
Face.java
package org.ic3d;
import org.lwjgl.opengl.GL11;
public class Face{
public static void RENDERFACE_QUAD(Vertex v1, Vertex v2, Vertex v3, Vertex v4){
GL11.glVertex3f(v1.getX(), v1.getY(), v1.getZ());
GL11.glVertex3f(v2.getX(), v2.getY(), v2.getZ());
GL11.glVertex3f(v3.getX(), v3.getY(), v3.getZ());
GL11.glVertex3f(v4.getX(), v4.getY(), v4.getZ());
}
public static void RENDERFACE_TRI(Vertex v1, Vertex v2, Vertex v3){
GL11.glVertex3f(v1.getX(), v1.getY(), v1.getZ());
GL11.glVertex3f(v2.getX(), v2.getY(), v2.getZ());
GL11.glVertex3f(v3.getX(), v3.getY(), v3.getZ());
}
}
If anyone sees why this is not working please tell me.