So I want to start doing stuff with OpenGL using LWJGL.
I understand the basic way of setting up a window, openGL, rendering loop.
But in all the tutorials I have read, not one shows how to render with OpenGL outside of a class. Its all hard coded.
The flow in java using the Graphics object basically goes
tell objects to draw themselves by passing them the Graphics object from your draw method.
Example:
public void drawSelf( Graphics g )
{
if(alive)
{
double x1 = (int)size >> 1;
double y1 = (int)size >> 1;
Graphics2D g2d = (Graphics2D)g.create();
Composite alphaComp = AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, (float) fade);
g2d.setComposite(alphaComp);
g2d.drawImage(texture, (int)(loc.x - x1), (int)(loc.y - y1), (int)size, (int)size, null);
g2d.dispose();
}
}
So what is the flow for OpenGl? I know how to hardcode something in it like this
Example:
while (!Display.isCloseRequested())
{
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glColor3f(0.2f,0.1f,1.0f);
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(100,100);
GL11.glVertex2f(100+200,100);
GL11.glVertex2f(100+200,100+200);
GL11.glVertex2f(100,100+200);
GL11.glEnd();
Display.update();
}
But how would you draw say a list of square objects?
Can you not pass them the resources they need to draw themselves?
Do you have to get their drawing information and then use that to drraw them?
I am lost and any help would be fantastic.