Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSollum

Posted 23 September 2012 - 09:51 AM

Hello!

Recently i stumbled upon one issue. It took me few hours to find out why form is displaying some elements wrongly. I found that issue out, but i don't understand problem in my code.

Here is the code part that i have problem with. I use LWJGL.

[source lang="java"] GL11.glPushMatrix(); // first translate GL11.glTranslatef(100, 0, 0); GL11.glPushMatrix(); //second translate GL11.glTranslatef(0, 100, 0); // first object GL11.glPushMatrix(); glColor4f(1f, 1f, 1f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 2); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT, 0); drawQuad(); GL11.glPopMatrix(); //second object GL11.glPushMatrix(); glColor4f(1f, 0f, 0f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 1); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT / 2, 0); drawQuad(); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix();[/source]


Problem is that second object ignores second glTranslatef in this case. If i would remove first glPushMatrix and last glPopMatrix, everything would work well, but the actuall form rendering code is quite bigger and i would like to know what am i doing wrong.

Maybe someone has any clues to what am i doing wrong?


Edit:
I call function to draw form in this code

[source lang="java"] GL11.glPushMatrix(); glMatrixMode(GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); glOrtho(0, UTILITY.SCREEN_WIDTH, UTILITY.SCREEN_HEIGHT, 0, 5, -5); drawForm(); GL11.glPopMatrix(); glMatrixMode(GL_MODELVIEW); GL11.glPopMatrix();[/source]

#3Sollum

Posted 23 September 2012 - 09:49 AM

Hello!

Recently i stumbled upon one issue. It took me few hours to find out why form is displaying some elements wrongly. I found that issue out, but i don't understand problem in my code.

Here is the code part that i have problem with. I use LWJGL.

[source lang="java"] GL11.glPushMatrix(); // first translate GL11.glTranslatef(100, 0, 0); GL11.glPushMatrix(); //second translate GL11.glTranslatef(0, 100, 0); // first object GL11.glPushMatrix(); glColor4f(1f, 1f, 1f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 2); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT, 0); drawQuad(); GL11.glPopMatrix(); //second object GL11.glPushMatrix(); glColor4f(1f, 0f, 0f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 1); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT / 2, 0); drawQuad(); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix();[/source]


Problem is that second object ignores second glTranslatef in this case. If i would remove first glPushMatrix and last glPopMatrix, everything would work well, but the actuall form rendering code is quite bigger and i would like to know what am i doing wrong.

Maybe someone has any clues to what am i doing wrong?

#2Sollum

Posted 23 September 2012 - 09:48 AM

Hello!

Recently i stumbled upon one issue. It took me few hours to find out why form is displaying some elements wrongly. I found that issue out, but i don't understand problem in my code.

Here is the code part that i have problem with. I use LWJGL.

[source lang="java"] GL11.glPushMatrix(); // first translate GL11.glTranslatef(100, 0, 0); GL11.glPushMatrix(); //second translate GL11.glTranslatef(0, 100, 0); // first object GL11.glPushMatrix(); glColor4f(1f, 1f, 1f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 2); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT, 0); drawQuad(); GL11.glPopMatrix(); //second object GL11.glPushMatrix(); glColor4f(1f, 0f, 0f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 1); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT / 2, 0); drawQuad(); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix();[/source]

Problem is that second object ignores second glTranslatef in this case. If i would remove first glPushMatrix and last glPopMatrix, everything would work well, but the actuall form rendering code is quite bigger and i would like to know what am i doing wrong.

Maybe someone has any clues to what am i doing wrong?

#1Sollum

Posted 23 September 2012 - 09:46 AM

Hello!

Recently i stumbled upon one issue. It took me few hours to find out why form is displaying some elements wrongly. I found that issue out, but i don't understand problem in my code.

Here is the code part that i have problem with. I use LWJGL.

[source lang="java"]GL11.glPushMatrix(); // first translate GL11.glTranslatef(100, 0, 0); GL11.glPushMatrix(); //second translate GL11.glTranslatef(0, 100, 0); // first object GL11.glPushMatrix(); glColor4f(1f, 1f, 1f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 2); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT, 0); drawQuad(); GL11.glPopMatrix(); //second object GL11.glPushMatrix(); glColor4f(1f, 0f, 0f, 1); GL11.glTranslatef(UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, UI_Form_CONFIG.FORM_HEADER_MARGIN_MOVE, 1); GL11.glScalef(UI_Form_CONFIG.FORM_HEADER_BORDER_WIDTH, UI_Form_CONFIG.FORM_HEADER_BORDER_HEIGHT / 2, 0); drawQuad(); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix();[/source]

Problem is that second object ignores second glTranslatef in this case. If i would remove first glPushMatrix and last glPopMatrix, everything would work well, but the actuall form rendering code is quite bigger and i would like to know what am i doing wrong.

Maybe someone has any clues to what am i doing wrong?

PARTNERS