Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make simple paint app using opengl/glut using c++ on xcode
    primarykey
    data
    text
    <p>So fare i am able to register mouse events. the only problem i am having is how to get the drawing to the screen. I have posted bellow the code that i am using currently. all it does is draw a window and some colored lines. i would idealy like a way to just draw to the screen and not have the screen completely clear every time i call the draw function.</p> <pre><code>void myInit(void) { glClearColor(1.0,1.0,1.0,0.0); // set white background color glColor3f(0.0f, 0.0f, 0.0f); // set the drawing color glPointSize(4.0); // a ‘dot’ is 4 by 4 pixels glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, 640.0, 0.0, 480.0); } void myDisplay(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the screen //First Line glLineWidth(8.0f); glBegin(GL_LINE_STRIP); glColor3ub(255, 0, 0); glVertex2i(40, 380); glColor3ub(0, 255, 0); glVertex2i(600, 380); glEnd(); //Second Line glLineWidth(8.0f); glBegin(GL_LINE_STRIP); glColor3ub(0, 0, 255); glVertex2i(40, 250); glColor3ub(0, 255, 0); glVertex2i(600, 250); glEnd(); //Third Line glLineWidth(8.0f); glBegin(GL_LINE_STRIP); glColor3ub(255, 0, 0); glVertex2i(40, 120); glColor3ub(0, 0, 255); glVertex2i(600, 120); glEnd(); glFlush(); // send all output to display } int main(int argc, char** argv) { //GLUT &amp; OpenGL glutInit(&amp;argc, argv); // initialize the toolkit glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode glutInitWindowSize(640,480); // set window size glutInitWindowPosition(100, 150); // set window position on screen glutCreateWindow("my first attempt"); // open the screen window glutDisplayFunc(myDisplay); // register redraw function myInit(); glutMainLoop(); // go into a perpetual loop } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload