Find Jobs
Hire Freelancers

a 5 minute code review

$10-15 USD / hour

In Progress
Posted almost 11 years ago

$10-15 USD / hour

here the source //////////////////////////////////////////////////// #include using namespace std; #include "/usr/include/GL/vgl.h" #include #include "/usr/include/GL/glew.h" #include "/usr/include/GL/LoadShaders.h" #include "/usr/include/GL/gl.h" // I thimk LoadShaders.h is a custom header or something // the code is the first practice from opengl programming 8th edition // with a few include modification that got the libraries to work(complete paths). enum VAO_IDs { Triangles, NumVAOs }; enum Buffer_IDs { ArrayBuffer, NumBuffers }; enum Attrib_IDs { vPosition = 0 }; GLuint VAOs[NumVAOs]; GLuint Buffers[NumBuffers]; const GLuint NumVertices = 6; //----------------------------- //------init //----------------------------- void init( void){ glGenVertexArrays(NumVAOs, VAOs); glBindVertexArray(VAOs[Triangles]); GLfloat vertices[NumVertices][2] = { { -0.90f, -0.90f}, //triangle 1 { 0.85f, -0.90f }, { -0.90f, 0.85f }, { 0.90f, -0.85f }, //triangle 2 { 0.90f, 0.90f }, { -0.85f, 0.90f } }; glGenBuffers(NumBuffers, Buffers); glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); ShaderInfo shaders[] = { { GL_VERTEX_SHADER, "triangles.vert" } { GL_FRAGMENT_SHADER,"triangles.frag" } { GL_NONE, NULL } }; GLuint program = LoadShaders(Shaders); glUseProgram(Program); glVertexAttribPointer(vPosition, 2 , GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); glEnableVertexAttribArray(vPosition); } //---------------------- // display void display(void) { glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(VAOs[Triangles]); glDrawArray(GL_TRIANGLES, 0, NumVertices); glFlush(); } //-------------------------------------- //main // int main (int argc, char** argv) { glutInit(&argc, char** argv); glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(512, 512); glutInitContextVersion(4, 3); glutInitContextProfile(GLUT_CORE_PROFILE); glutCreateWindow(argv[0]); if(glewInit()) { cerr << "Unable to initialize GLEW ..... exiting" << endl; exit(EXIT_FAILURE); } init(); glutDisplayFunc(display); glutMainLoop(); } //---------------------------------------end-------------------------------------- //---------------------------the compile errors:---------------------------- //---------------------------------------------------------------------------------- I use "g++ /path/to/[login to view URL] -lm -lGL -lglut /home/ilan/Desktop/c++/opengl/[login to view URL]: In function ‘void init()’: /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected ‘}’ before ‘{’ token /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected ‘,’ or ‘;’ before ‘{’ token /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected ‘;’ before ‘}’ token /home/ilan/Desktop/c++/opengl/[login to view URL]: At global scope: /home/ilan/Desktop/c++/opengl/[login to view URL]: error: ‘Shaders’ was not declared in this scope /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected constructor, destructor, or type conversion before ‘(’ token /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected constructor, destructor, or type conversion before ‘(’ token /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected constructor, destructor, or type conversion before ‘(’ token /home/ilan/Desktop/c++/opengl/[login to view URL]: error: expected declaration before ‘}’ token I read the code a hundred times but cant find where it's broken (I'm a complete noob) I want the code to be corrected and the error explained thanx
Project ID: 4594670

About the project

2 proposals
Remote project
Active 11 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
2 freelancers are bidding on average $55 USD/hour for this job
User Avatar
Hello, expert in C++ and OpenGL here, I can help you building and running this code. Please check PM. Thanks, Paul
$100 USD in 2 days
5.0 (25 reviews)
5.8
5.8

About the client

Flag of ISRAEL
kfar yona, Israel
5.0
7
Payment method verified
Member since Jun 5, 2013

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.