Question

OpenGL 2D i asked this question: Line graph using lines and point and i get this...

OpenGL 2D

i asked this question: Line graph using lines and point and i get this answer but when try to run i get error :

[Error] 'drawLine' was not declared in this scope.

[Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings] .

#include<math.h>
#include"graphics.h

const int width=800,height=600;
int drawline(int movetoX, int movetoY, int drawX, int drawY, int textX, int textY, int colour, char *name)
{
   moveto(movetoX,movetoY);
   setcolour(colour);
   lineto(drawX,drawY);
   outtextxy(textX,textY,name);
}

int main(){
   double x,y;
   initwindow(width,height);
   moveto(height/2,width/2); //move cursor to centre
  
   // let us draw first function
   for(x=0;x<width;x+=0.01)
   {
       y=pow(x,4);
       setcolour(14);
       lineto(width/2+(x*100),height/2-(y*100));
   }
  
   // let us draw first function
   for(x=0;x<width;x+=0.01)
   {
       y=pow(x,1./3.);
       lineto(width/2+(x*100),height/2-(y*100));
   }
  
   //and our x and y lines are:
   drawLine(0,height/2,width,height/2,WHITE,width-20,height/2+10,"x");
   drawLine(width/2,0,width/2,height,WHITE,width/2+10,0,"y");
  
  
   getch();
   closegraph();
   system("PAUSE");
   return 0;
  
}

//Use this code in Dev-c++ (4.9.9.2)

#include<math.h>
#include"graphics.h

const int width=800,height=600;
int drawline(int movetoX, int movetoY, int drawX, int drawY, int textX, int textY, int colour, char *name)
{
   moveto(movetoX,movetoY);
   setcolour(colour);
   lineto(drawX,drawY);
   outtextxy(textX,textY,name);
}

int main(){
   double x,y;
   initwindow(width,height);
   moveto(height/2,width/2); //move cursor to centre
  
   // let us draw first function
   for(x=0;x<width;x+=0.01)
   {
       y=pow(x,4);
       setcolour(14);
       lineto(width/2+(x*100),height/2-(y*100));
   }
  
   // let us draw first function
   for(x=0;x<width;x+=0.01)
   {
       y=pow(x,1./3.);
       lineto(width/2+(x*100),height/2-(y*100));
   }
  
   //and our x and y lines are:
   drawLine(0,height/2,width,height/2,WHITE,width-20,height/2+10,"x");
   drawLine(width/2,0,width/2,height,WHITE,width/2+10,0,"y");
  
  
   getch();
   closegraph();
   system("PAUSE");
   return 0;
  
}

//Use this code in Dev-c++ (4.9.9.2)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Change the below lines in main()
   drawLine(0,height/2,width,height/2,WHITE,width-20,height/2+10,"x");
   drawLine(width/2,0,width/2,height,WHITE,width/2+10,0,"y");

to

drawline(0,height/2,width,height/2,WHITE,width-20,height/2+10,"x");
drawline(width/2,0,width/2,height,WHITE,width/2+10,0,"y");

the function is drawline() -> small l in line but you are calling drawLine() -> capital L , remember C/C++ is a type sensitive language and so you must take care of small and capital letters as they are treated differently.

So drawline() and drawLine() are two different functions of which only drawline() is defined in your program not drawLine() , so you are getting the error 'drawLine' was not declared in this scope.

Add a comment
Know the answer?
Add Answer to:
OpenGL 2D i asked this question: Line graph using lines and point and i get this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I NEED HELP IN MAZE PROBLEM. Re-write the following program using classes. The design is up...

    I NEED HELP IN MAZE PROBLEM. Re-write the following program using classes. The design is up to you, but at a minimum, you should have a Maze class with appropriate constructors and methods. You can add additional classes you may deem necessary. // This program fills in a maze with random positions and then runs the solver to solve it. // The moves are saved in two arrays, which store the X/Y coordinates we are moving to. // They are...

  • Have been working on this code for awhile and cant get it to work with Glut....

    Have been working on this code for awhile and cant get it to work with Glut. Wondering if there is anything I can fix #include <iostream> #include "graph1.h" using namespace std; //Add Function Prototypes Here int getNoPoints(); void getPoints(int x[], int y[], int no_points); void drawPolyLine(int x[], int y[], int no_points); int main() {    //Variable Declaration/Initialization    int no_points = 0;    const int MAX_POINTS = 10;    int x[MAX_POINTS];    int y[MAX_POINTS];    //Display Graphics Window    displayGraphics();...

  • On the Turtle class I need to make a method so turtle 0 and turtle 2...

    On the Turtle class I need to make a method so turtle 0 and turtle 2 to "kiss" or touch their heads. Everything that can be use is in the SimpleTurtle link. https://www2.cs.uic.edu/~i101/doc/SimpleTurtle.html public void turtleTricks() { int worldWidth = 800; int worldHeight = 600; Random random = new Random(); World earth = new World(worldWidth, worldHeight );//Make a big world for turtles.    Turtle[] turtles = new Turtle[5]; int xLocation, yLocation, angle; for ( int i = 0; i <...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • I am trying to create a menu after inputting text from where the cursor is located...

    I am trying to create a menu after inputting text from where the cursor is located in openGL window in C++. The menu needs to be able to change color and font of text and also have an option to quit the program. For some reason my program is not working. First the words won’t display when I start typing. Then when I click on a color it quits the program. How do I fix this? My code is below:...

  • Modify the NervousShapes program so that it displays equilateral triangles as well as circles and rectangles....

    Modify the NervousShapes program so that it displays equilateral triangles as well as circles and rectangles. You will need to define a Triangle class containing a single instance variable, representing the length of one of the triangle’s sides. Have the program create circles, rectangles, and triangles with equal probability. Circle and Rectangle is done, please comment on your methods so i can understand */ package NervousShapes; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import javax.swing.*; import javax.swing.event.*; public class...

  • Game Description: Most of you have played a very interesting game “Snake” on your old Nokia...

    Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...

  • JAVA problem: Upgrade and extend the previous programs Draw.java and DrawCanvas.java used in the class to...

    JAVA problem: Upgrade and extend the previous programs Draw.java and DrawCanvas.java used in the class to maintain a list of shapes drawn as follows: Replace and upgrade all the AWT components used in the programs to the corresponding Swing components, including Frame, Button, Label, Choice, and Panel. Add a JList to the left of the canvas to record and display the list of shapes that have been drawn on the canvas. Each entry in the list should contain the name...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT