Click here to Skip to main content
15,881,715 members
Home / Discussions / Graphics
   

Graphics

 
GeneralRe: graphics quality very poor, how to improve? Pin
Tino Fourie12-Jul-14 11:56
Tino Fourie12-Jul-14 11:56 
AnswerRe: graphics quality very poor, how to improve? Pin
Tino Fourie12-Jul-14 12:02
Tino Fourie12-Jul-14 12:02 
QuestionUseage about OPCODE collision detection Pin
Henry Hong4-Jun-13 15:23
Henry Hong4-Jun-13 15:23 
AnswerRe: Useage about OPCODE collision detection - REPOST Pin
Richard MacCutchan4-Jun-13 22:03
mveRichard MacCutchan4-Jun-13 22:03 
GeneralRe: Useage about OPCODE collision detection - REPOST Pin
Henry Hong4-Jun-13 22:09
Henry Hong4-Jun-13 22:09 
GeneralRe: Useage about OPCODE collision detection - REPOST Pin
Richard MacCutchan4-Jun-13 23:31
mveRichard MacCutchan4-Jun-13 23:31 
QuestionOpenGL 3.0 Square is being drawn behind another Square Pin
mrpeed1-May-13 12:51
mrpeed1-May-13 12:51 
AnswerRe: OpenGL 3.0 Square is being drawn behind another Square Pin
Santhosh G_27-May-13 6:23
Santhosh G_27-May-13 6:23 
Enable Depth test to draw objects beyond others.
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LESS ); // Near objects will be displayed. object with z -3 displayed on top of object with z -4

If you are creating an app similar to MSPAINT, setup projection matrix with glOrtho().
glOrtho() is used because it creates an orthographic projection, therefore the size of rendered image of same size with different z value will be same.

Provide different z values for each objects, based on their z order in the screen.
ie, z value of the object drawn at first should be as small, say 1.
Then increase z value of each new objects.

Render code should be like this.
C#
// set depth range and clear depth value.
glDepthRange(-100, 100);
glClearDepth(100);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

// Set projection.
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho(-20,20,-20,20,0, 100 );

glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LESS );

// No model view transformation.
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

// Draw object 1
glColor3f(0,0,1);
glBegin( GL_TRIANGLES );
glVertex3f( 0,0, -3 );
glVertex3f( 1,1, -3 );
glVertex3f( 0,1, -3 );
glEnd();

// Draw Object 2. Here z is -2, it will be displayed on top of object -3
glColor3f(1,0,0);
glBegin( GL_TRIANGLES );
glVertex3f( 0,1, -2 );
glVertex3f( 1,1, -2 );
glVertex3f( 1,0, -2 );
glEnd();

SwapBuffers( m_hDC );

QuestionGestures, jestures, and swipes - implementation fundamentals Pin
charlieg10-Apr-13 11:51
charlieg10-Apr-13 11:51 
AnswerRe: Gestures, jestures, and swipes - implementation fundamentals Pin
Pete O'Hanlon10-Apr-13 12:14
mvePete O'Hanlon10-Apr-13 12:14 
GeneralRe: Gestures, jestures, and swipes - implementation fundamentals Pin
charlieg10-Apr-13 23:23
charlieg10-Apr-13 23:23 
GeneralRe: Gestures, jestures, and swipes - implementation fundamentals Pin
Pete O'Hanlon10-Apr-13 23:34
mvePete O'Hanlon10-Apr-13 23:34 
GeneralRe: Gestures, jestures, and swipes - implementation fundamentals Pin
charlieg10-Apr-13 23:53
charlieg10-Apr-13 23:53 
GeneralRe: Gestures, jestures, and swipes - implementation fundamentals Pin
Pete O'Hanlon11-Apr-13 0:03
mvePete O'Hanlon11-Apr-13 0:03 
GeneralRe: Gestures, jestures, and swipes - implementation fundamentals Pin
charlieg11-Apr-13 0:16
charlieg11-Apr-13 0:16 
GeneralRe: Gestures, jestures, and swipes - implementation fundamentals Pin
Pete O'Hanlon11-Apr-13 0:19
mvePete O'Hanlon11-Apr-13 0:19 
Question3D C# windows from Pin
taufiki8-Feb-13 0:06
taufiki8-Feb-13 0:06 
AnswerCrosspost PinPopular
Eddy Vluggen8-Feb-13 0:27
professionalEddy Vluggen8-Feb-13 0:27 
AnswerRe: 3D C# windows from Pin
MaulikDusara26-Jun-13 9:04
MaulikDusara26-Jun-13 9:04 
QuestionThick Line Algorithm Pin
A_Fa5-Jan-13 20:56
A_Fa5-Jan-13 20:56 
AnswerRe: Thick Line Algorithm Pin
UweKlatt18-Jan-13 1:50
UweKlatt18-Jan-13 1:50 
GeneralRe: Thick Line Algorithm Pin
Ingo30-Jan-13 2:29
Ingo30-Jan-13 2:29 
AnswerRe: Thick Line Algorithm Pin
Ingo30-Jan-13 2:28
Ingo30-Jan-13 2:28 
AnswerRe: Thick Line Algorithm Pin
TheRealRarius21-Mar-13 0:35
TheRealRarius21-Mar-13 0:35 
AnswerRe: Thick Line Algorithm Pin
Brian J Rothwell12-Aug-14 12:24
Brian J Rothwell12-Aug-14 12:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.