a 5 minute code review
$10-15 USD / hour
Publicado hace casi 11 años
$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
ID del proyecto: 4594670
Información sobre el proyecto
2 propuestas
Proyecto remoto
Activo hace 11 años
¿Buscas ganar dinero?
Beneficios de presentar ofertas en Freelancer
Fija tu plazo y presupuesto
Es gratis registrarse y presentar ofertas en los trabajos
2 freelancers están ofertando un promedio de $55 USD /hora por este trabajo
Hello,
expert in C++ and OpenGL here, I can help you building and running this code. Please check PM.
Thanks,
Paul
$100 USD en 2 días
5,0 (25 comentarios)