Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() function which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() function which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() function which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

added 9 characters in body
Source Link
Ethan Bierlein
  • 15.9k
  • 4
  • 60
  • 146
  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() function which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() function which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

added 859 characters in body
Source Link
Ethan Bierlein
  • 15.9k
  • 4
  • 60
  • 146

In C++ (and even later versions of C), it's always better to use const (or constexpr in some special cases) for defining constant values rather than a macro. This means that theUsing macros can often lead to obscure and confusing issues popping up, especially if you're overzealous in your use of them. The macros in your code (excluding GLEW_STATIC) should be declared as:

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

In C++ (and even later versions of C), it's always better to use const (or constexpr in some special cases) for defining constant values rather than a macro. This means that the macros in your code (excluding GLEW_STATIC) should be declared as:

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

In C++ (and even later versions of C), it's always better to use const (or constexpr in some special cases) for defining constant values rather than a macro. Using macros can often lead to obscure and confusing issues popping up, especially if you're overzealous in your use of them. The macros in your code (excluding GLEW_STATIC) should be declared as:

  • You have a small bug in your code where you #define GLEW_STATIC. In order to use GLEW properly as a static library, GLEW_STATIC must be declared before you include glew.h. You'll also likely have to change "glew32.lib" to "glew32s.lib". Example:

     #pragma comment(lib, "glew32s.lib")
     ...
     #define GLEW_STATIC
     #include "glew.h"
    
  • Please don't ever use using namespace std; in your C++ code. It's a very bad idea. See this Stack Overflow post for the reason why.

  • The variable bodyIndex is poorly named and unnecessary. std::vector<T> already has a size() which returns the number of elements in the vector.

  • While you mentioned that you know you used the fixed function pipeline, I'm going to recommend against it anyways. It's deprecated in a lot of graphics hardware and sometimes requires some special workarounds to get working. It's also much less flexible than the programmable function pipeline.

  • The various #includes and #defines at the beginning of your code are are grouped together in one big cluster, which isn't very visually appealing. I'd highly recommend separating them into distinct groups, like so:

     #pragma comment(lib, "glew32.lib")
     ...
     #include <stdlib.h>
     #include <string>
     #include <vector>
     #include <iostream>
     #include <fstream>
     ...
     #define GLEW_STATIC
     #include "GL/glew.h"
     #include <glut.h>
     ...
     #define WIDTH 800
     #define HEIGHT 640
     #define AU (149.6e6 * 1000)
     #define SCALE (250 / AU)
     #define G 6.67428e-11
     ...
    

    As you can see, there are four distinct groups here, #pragmas, standard #includes, 3rd-party #includes and #defines.

Source Link
Ethan Bierlein
  • 15.9k
  • 4
  • 60
  • 146
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /