NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <iostream>
#include <GL/glut.h>
#include <string.h>
#define WIDTH 700
#define HEIGHT 600

using namespace std;
float pos = 250;
bool dir = true;
double arr[5000][4];
double x1 = 360, x2 = 380, x3 = 400;
int z = 0;
int i, a = 0;
int flag = 0;
float radius = 0.03;
int ptr = 0;
int faltu_bit = 1;
float color[3][3] = { { 1.0, 1.0, 1.0 }, { 1.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 } };

void drawText(char *str, float x, float y, int id)
{
int i;
int len = strlen(str);
//glLoadIdentity();
glColor3f(color[id][0], color[id][1], color[id][2]);
glRasterPos2f(x, y);
for (i = 0; i<len; i++)

glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, str[i]);

}


void init()
{
glClearColor(0.0, 0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT);
memset(arr, 0, 5000);

glPointSize(20);

}

void resetAll()
{
memset(arr, 0, 5000);
z = 0;
}

///OPENGL MAPPING///
float getOpenGLX(int x)
{
double ox = x / (double)WIDTH*(WIDTH);
return ox;
}

float getOpenGLY(int y)
{
double oy = (1 - y / (double)HEIGHT)*HEIGHT;
return oy;
}



void drawBall(float x, float y)
{
glBegin(GL_POINTS);
glColor3f(1.0, 1.0, 0.0);
glVertex2f(x, y);

glEnd();
}

void draw()

{

int yon = 1;


if (arr[ptr + 1][0] - arr[ptr][0] > 0 && arr[ptr + 1][1] - arr[ptr][1] < 0){

x1 += 0.1;
x2 +=0.1;
x3 += 0.1;
pos -= 0.1;


}
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glVertex2f(x1, pos);
glColor3f(1, 0, 0);
glVertex2f(x1, pos + 10);
glColor3f(1, 0, 0);
glVertex2f(x1 + 10, pos + 10);
glColor3f(1, 0, 0);
glVertex2f(x1 + 10, pos);
glEnd();
//2.koyun
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glVertex2f(x2, pos);
glColor3f(1, 0, 0);
glVertex2f(x2, pos + 10);
glColor3f(1, 0, 0);
glVertex2f(x2 + 10, pos + 10);
glColor3f(1, 0, 0);
glVertex2f(x2 + 10, pos);
glEnd();
//3.koyun
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glVertex2f(x3, pos);
glColor3f(1, 0, 0);
glVertex2f(x3, pos + 10);
glColor3f(1, 0, 0);
glVertex2f(x3 + 10, pos + 10);
glColor3f(1, 0, 0);
glVertex2f(x3 + 10, pos);
glEnd();






//1.koyun


}

void drawLines()
{

glBegin(GL_LINE_STRIP);
glColor3f(1.0, 0.0, 0.0);

for (i = 0; i < z; i++)
{


glVertex2f(arr[i][0], arr[i][1]);

}


glEnd();

}




void addValue(int x, int y)
{



arr[z][0] = getOpenGLX(x);
arr[z++][1] = getOpenGLY(y);





}





void myDisplay()
{
glClear(GL_COLOR_BUFFER_BIT);

drawLines();


drawBall(arr[ptr][0], arr[ptr][1]);
draw();



glutSwapBuffers();
glutPostRedisplay();


glFlush();
}


void myMouseStat(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
if (!flag)
{

flag = 1;
}
}
else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP)
{
if (flag)
{

flag = 0;
}
}

}


void myPressedMove(int x, int y)
{
if (flag)
{
addValue(x, y);
}
}


void myTimer(int t)
{

if (ptr != z - 1)
{



ptr++;



}




glutTimerFunc(115, myTimer, 0);

}

int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100, 100);
glutInitWindowSize(WIDTH, HEIGHT);
glutCreateWindow("KoyunKurtarma");
init();

glutDisplayFunc(myDisplay);

glutMouseFunc(myMouseStat);
glutMotionFunc(myPressedMove);
glutTimerFunc(115, myTimer, 0);

glutMainLoop();
return 0;
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.