Jump to content
  • Advertisement

GRAPHIC GEEK

Member
  • Content Count

    8
  • Joined

  • Last visited

Everything posted by GRAPHIC GEEK

  1. GRAPHIC GEEK

    OpenGL LineStipple Problem

    haegarr, Thanks a lot for replying, so what you were saying is apart from what you write in RESIZE callback function, all the methods that are even called after RESIZE function are recalled is that it? then how can i avoid my above problem of each time when i resize the glutDisplayFunc(dashed_lines) getting called repeatedly? and I am really sorry for the inconvenience i have created for you, i see that i wont repeat it again.. please shed some light on me Thanks in advance GG
  2. Hi everyone, I am a newbie to OpenGL programming, i have written a small program of LineStipple in OpenGL, but when i get the output when i try to resize the window, it is not getting resized properly, the function which implements LineStipple gets called again and again, even though i wrote the RESIZE function seperately, unable to figure out what exactly is the problem, I am posting the code below, --------------------------- LINE STIPPLE IMPLEMENTATION ----------------------------------------- #include<GL/gl.h> #include<GL/glu.h> #include<GL/glut.h> #include<stdio.h> #include<stdlib.h> #include<math.h> #define PI 3.1415926535898 #define drawline(x1,y1,x2,y2) glBegin(GL_LINES); glVertex2f(x1,y1); glVertex2f(x2,y2); glEnd(); glFlush(); void clr_wndow() { GLfloat v1[2] = {0.25,0.25}; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.8, 0.5, 0.0); glPointSize(5.0f); //setting the size of the points //printf("The glPoint size range is:%d",glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE)); glBegin(GL_LINES); glVertex2fv(v1); glVertex2f(0.75,0.25); glVertex2f(0.85,0.50); glVertex2f(0.75,0.75); glVertex2f(0.25,0.75); glVertex2f(0.15,0.50); glEnd(); glFlush(); } void dashed_lines() { glEnable(GL_LINE_STIPPLE); glLineStipple(1,0x1); glBegin(GL_LINE_LOOP); drawline(0.25,0.25,0.75,0.25); drawline(0.85,0.50,0.75,0.75); drawline(0.25,0.75,0.15,0.50); drawline(0.15,0.50,0.25,0.25); glEnd(); glFlush(); } void draw_rect() { GLfloat cords[4]={0.25,0.25,0.75,0.75}; glVertex4fv(cords); } void draw_circle() { glColor3f(1.0,1.0,1.0); glVertex2f(0.73,0.73); } ---------------------------------------------------- MAIN FUNCTION ------------------------------------------------- #include "wndw_clr_tst.h" void display1() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex3f(0.25,0.25,0.0); glVertex3f(0.75,0.25,0.0); glVertex3f(0.75,0.75,0.0); glVertex3f(0.25,0.75,0.0); glEnd(); glFlush(); } void display2() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 0.0); glBegin(GL_LINE); glVertex3f(0.0,0.0,0.0); glVertex3f(1.0,0.0,0.0); glVertex3f(1.0,1.0,0.0); glVertex3f(0.0,1.0,0.0); glEnd(); glFlush(); } void display3() { glColor3f(0.0,1.0,1.0); glBegin(GL_TRIANGLES); glVertex2f(0.25,0.25); glVertex2f(0.75,0.25); glVertex2f(0.75,0.75); glEnd(); //glClear(GL_COLOR_BUFFER_BIT); glFlush(); } void resize(int w, int h) { printf("\nThe size of width and height is:%d,%d",w,h); glViewport(0,0,(GLsizei)w,(GLsizei)h); //the object will not be visible because viewport is not viewing over the object placement glClearColor(0.0,0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,1.0,0.0,1.0); } int main(int argc,char *argv[]) { char t[] = "true"; char f[] = "false"; glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500 , 500); glutCreateWindow("My First OpenGL program"); glutReshapeFunc(resize); //glutDisplayFunc(display1); //glutDisplayFunc(display2); //glutDisplayFunc(display3); //glutDisplayFunc(clr_wndow); glutDisplayFunc(dashed_lines); //printf("The blend is enabled?:%s",glIsEnabled(GL_BLEND) ? "true" : "false" ); glutMainLoop(); return 0; } Please help me thanks in advance GG
  3. Hi everyone, I am using GLUT in ubuntu 10.10, when i try to draw smooth points in OPENGL using below code i am not getting circular points, instead of that i am getting square points void draw_points() { GLfloat v1[2] = {0.25,0.25}; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.8, 0.5, 0.0); glPointSize(5.0f); //setting the size of the points glEnable( GL_POINT_SPRITE ); // GL_POINT_SPRITE_ARB if you're glEnable( GL_POINT_SMOOTH ); // using the functionality as an extension. glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBegin(GL_POINTS); glVertex2fv(v1); glVertex2f(0.75,0.25); glVertex2f(0.85,0.50); glVertex2f(0.75,0.75); glVertex2f(0.25,0.75); glVertex2f(0.15,0.50); glEnd(); glFlush(); } please tell me where i am going wrong thanks a lot in advance, GG
  4. I have already tried that, you can see that in my program itself, but it did not help me, if you got any other way please tell me
  5. Hi everyone, I am a newbie to OpenGL programming. I've started learning OpenGL very recently can anyone please explain me how the function GLFlush works in simple terms with an example that can help me understand it better? Thankyou
  6. GRAPHIC GEEK

    How does GLFlush() works?

    thanks a lot guys for your valuable replies. Cheers, GG
  7. GRAPHIC GEEK

    How does GLFlush() works?

    Thankyou Brother Bob for replying, how long will the commands stay in command buffer? why because even after the complete execution of program, will the commands still stay there? please tell me
  8. GRAPHIC GEEK

    How does GLFlush() works?

    Thankyou all for replying, but still i am unable to understand how GLFlush works, is it mandatory to write GLFlush after all the drawing functions between glBegin and glEnd? i've written a sample code please go through it #include<GL/gl.h> #include<GL/glu.h> #include<GL/glut.h> #include<stdio.h> #include<stdlib.h> void display1() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex3f(0.25,0.25,0.0); glVertex3f(0.75,0.25,0.0); glVertex3f(0.75,0.75,0.0); glVertex3f(0.25,0.75,0.0); glEnd(); glFlush(); } void display2() { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 0.0); glBegin(GL_LINE); glVertex3f(0.25,0.25,0.0); glVertex3f(0.75,0.25,0.0); glVertex3f(0.75,0.75,0.0); glVertex3f(0.25,0.75,0.0); glEnd(); glFlush(); } void display3() { glColor3f(0.0,1.0,1.0); glBegin(GL_TRIANGLES); glVertex3f(0.25,0.25,0.0); glVertex3f(0.75,0.25,0.0); glVertex3f(0.75,0.75,0.0); glEnd(); //glClear(GL_COLOR_BUFFER_BIT); glFlush(); } void init() { glClearColor(0.0,0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0); } int main(int argc,char *argv[]) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500 , 500); glutCreateWindow("My First OpenGL program"); init(); glutDisplayFunc(display1); glutDisplayFunc(display2); glutDisplayFunc(display3); glutMainLoop(); return 0; } In the above code in 3 functions display1,2 and 3, when i specify GLFlush then only i am able to see the object or else i am unable to see anything why is it like that? can you explain me in detail why GLFLUSH is being used here with a small lucid example? thanks in advance
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!