hello,
what should i do to call opengl methods directly after jPCT has done ? for example the code below doesnt draw a line
while (loop) {
// do jPCT things
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
// do lwjgl things
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex2f(10, 10);
GL11.glVertex2f(50, 50);
GL11.glEnd();
buffer.displayGLOnly();
Thread.sleep(10);
}
Hmmm...looks fine to me. If it doesn't work out, you may try to wrap your code into an IPostProcessor instead.
onfortunately didnt help ??? this is version 1.17
buffer.addPostProcessor(new IPostProcessor(){
private boolean initialized = false;
public void dispose() {
initialized = false;
}
public void init(FrameBuffer buffer) {
initialized = true;
}
public boolean isInitialized() {
return initialized;
}
public void process() {
GL11.glColor3f(255, 255, 255);
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex2f(10, 10);
GL11.glVertex2f(50, 50);
GL11.glEnd();
}
});
Which renderer is this? GL or AWTGL?
GL. just a simple addition to HelloWorldOGL sample
Have you tried to add a
GL11.glDisable(GL11.GL_DEPTH_TEST);
before and a
GL11.glEnable(GL11.GL_DEPTH_TEST);
after your code?
didnt help neither ??? i know nothing about opengl so i may be forgotting something stupid.. does it work for you ?
This works:
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glOrtho(0, 1, 1, 0, 0.1, 100);
GL11.glColor3f(255, 255, 255);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBegin(GL11.GL_LINES);
GL11.glVertex3f(0.0f, 0.0f, -1f);
GL11.glVertex3f(1.0f, 1.0f, -1f);
GL11.glEnd();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
i.e. switch to Ortho-mode, use normalized screen coordinates and disable texturing.
that worked for me too ;D but are all that stuff necessary ? and why glVertex3f ? i tried different z values, seems as a negative value is necessary but why ?
sorry, i know this is not a jPCT thing but ::)
It's required to give it a z-value that won't be clipped. I'm sure it's possible to set up OpenGL in a way that this isn't needed anymore, but that would require even more state changes before and after. Ortho mode is required, because otherwise the normal perspective transformations apply for your line, which isn't what you want for a 2d line.
i see thank you :D and i guess this is the way to set it it up for 2D: (looking at FengGui source)
GLU.gluOrtho2D(0, 800, 600, 00);
I still prefer the normalized coordinates. If you want to get rid of the z-value, try this instead:
GL11.glOrtho(0, 1, 1, 0, 0.0f, 0.1f);
In addition, this doesn't force you to include GLU.
indeed i need exact coordinates. so will it be like
GL11.glOrtho(0, width, height, 0, 0.0f, 0.1f);
Quote from: raft on March 30, 2009, 11:13:26 AM
indeed i need exact coordinates. so will it be like
GL11.glOrtho(0, width, height, 0, 0.0f, 0.1f);
In that case, yes!
that code makes y axis increase downwards. is it also possible to convert mouse coordinate system ?
Quote from: raft on March 30, 2009, 02:11:51 PM
that code makes y axis increase downwards. is it also possible to convert mouse coordinate system ?
Which is natural IMHO. If you want it reversed, just do something like this:
GL11.glOrtho(0, 800, 0, 600, 0.0f, 0.1f);
QuoteWhich is natural IMHO. If you want it reversed, just do something like this:
GL11.glOrtho(0, 800, 0, 600, 0.0f, 0.1f);
no, i'm happy it reverses Y coordinate. i just wonder if same can be done for lwjgl Mouse class ?
Quote from: raft on March 30, 2009, 07:56:50 PM
no, i'm happy it reverses Y coordinate. i just wonder if same can be done for lwjgl Mouse class ?
I don't really know, but i don't think so.