Find Jobs
Hire Freelancers

a 5 minute code review

$10-15 USD / hour

W trakcie realizacji
Opublikowano prawie 11 lat temu

$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
Identyfikator projektu: 4594670

Informację o projekcie

2 ofert
Zdalny projekt
Aktywny 11 lat temu

Szukasz sposobu na zarobienie pieniędzy?

Korzyści ze składania ofert na Freelancer.com

Ustal budżet i ramy czasowe
Otrzymuj wynagrodzenie za swoją pracę
Przedstaw swoją propozycję
Rejestracja i składanie ofert jest bezpłatne
2 freelancerzy składają oferty o średniej wysokości $55 USD/godz. dla tej pracy
Awatar Użytkownika
Hello, expert in C++ and OpenGL here, I can help you building and running this code. Please check PM. Thanks, Paul
$100 USD w 2 dni
5,0 (25 opinii)
5,8
5,8

O kliencie

Flaga ISRAEL
kfar yona, Israel
5,0
7
Zweryfikowana metoda płatności
Członek od cze 5, 2013

Weryfikacja Klienta

Dziękujemy! Przesłaliśmy Ci e-mailem link do odebrania darmowego bonusu.
Coś poszło nie tak podczas wysyłania wiadomości e-mail. Proszę spróbować ponownie.
Zarejestrowani Użytkownicy Całkowita Liczba Opublikowanych Projektów
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Wczytywanie podglądu
Udzielono pozwolenia na Geolokalizację.
Twoja sesja logowania wygasła i zostałeś wylogowany. Proszę, zalogować się ponownie.