• Content count

  • Joined

  • Last visited

Community Reputation

1825 Excellent

About bradbobak

  • Rank

Personal Information

  • Interests
  1.  Maybe stat is failing? (You may need to append the filename to the directory to pass to stat).
  2. Do you comment Above or Below your code?

     I generally put small comments next to the code, and bigger ones above it.  I've voted for below as well (but not sure if it would be interpreted as such) for a case such as     char buf[500];  // read a header  read(stream, buf, 500);    // some arbritary code  x = buf[3];   // file is now parsed.
  3. Safe endian macro

    This is what I use. You might be able to extract extra checks from this. Note the disclaimer.  
  4. Weird if() behavior

      fyi, i think this is wrong.. everything will be set to backlog[0]. I think you need to do the loop in reverse.
  5. afaik, PM_NOREMOVE causes the PeekMessage() to leave the message on the queue. GetMessage() then removes the message from the queue.   edit: although this example would probably be fine with just the PeekMessage() without the PM_NOREMOVE.
  6.  As far as i know, a text file is treated similar to binary file except that some os's do some linefeed, carriage return translations. Text files are sometimes parsed by reading line-by-line, which, in c++, is straightforward to do (std::getline()). You have the filesize, you know when you've reached the end of file, and you can read line-by-line if you want. Thinking from a text file point of view, i don't even think '\0' is valid in it (does getline() stop at the '\0'). I guess what i'm trying to say, a text file is basically a binary file except it generally contains printable text rather than some sort of binary data and a '\0' would be considered binary data.    (did i get that right, lol)    EDIT: ninja'd
  7.  You need to add a '\0' c-string terminator. make the char buffer 1 bigger, then when you read it, assign the last char in the array a value of 0.    int filesize = whatever; char *buf = new char[filesize + 1]; read_the_data(); buf[filesize] = 0;    This is needed as a c-string holds a null terminator to signify the end of the string.
  8. It may just be me, but that looks like a buffer overflow.   Don't think so. read reads bytes and the array size is specified correctly.
  9.  read, write, and close are posix functions. 'man 2 read' in unix should bring up the man pages.    From your compiler output it seems like the header files are not being included. Try including <unistd.h>, that may fix your problem.
  10.  I read somewhere that the 8 core fx series has 4 'modules' each with 2 integer cores and a shared floating point core per module. so, maybe that has something to do with this.
  11.  Can I guarantee that once inserted, the value part will not be copied? // i.e. can i do this:   std::map< int, int > my_map;   int *int_ptr = &my_map::find(5)->second; // assuming 5 exists.   // will int_ptr always be at the same place if I add / remove map entries (not including the int_ptr entry).    And if this is true, is it valid to say an unordered_map will do this as well?  
  12. I thought the quads were 20 pixels, 0..19 is 20 units no?
  13.  Hi, when I render quads to my ortho view (set up as (0, window_x_size), (0, window_y_size), (-1, 1)) opengl leaves a blank line between neighbouring quads.   heres my ortho matrix setup: matrix4x4 &matrix4x4::make_ortho(float left_, float right_,  float top_, float bottom_, float near_, float far_) {   zero();     mat[0] = 2.0f / (right_ - left_);   mat[5] = 2.0f / (top_ - bottom_);   mat[10] = -2.0f / (far_ - near_);   mat[12] = -((right_ + left_) / (right_ - left_));   mat[13] = -((top_ + bottom_) / (top_ - bottom_));   mat[14] = -((far_ + near_) / (far_ - near_));   mat[15] = 1.0f;     return *this; } I call the above with make_ortho(0, 600, 0, 400, -1, 1) where the window size is 600 x 400.   This is the contents of my vertex array right before I enable the vertex attrib array and glVertexAttribPointer it.   (2 quads, one under the other)   verts : (0, 300, 0) verts : (19, 300, 0) verts : (19, 319, 0) verts : (0, 319, 0) verts : (0, 320, 0) verts : (19, 320, 0) verts : (19, 339, 0) verts : (0, 339, 0)   Unfortunately, this is leaving a blank line between the top quad and the bottom one and I can't see why.   My vertex shader: (trans is set to my ortho matrix) #version 330   uniform mat4 trans;   in vec3 pos; in vec3 color;   out vec3 frag_color;   void main() {   gl_Position = trans * vec4(pos, 1.0);     frag_color = color; }     Fragment shader: #version 330   in vec3 frag_color;   out vec4 out_color;   void main() {   out_color = vec4(frag_color, 1.0); }      Everything works fine (quad placement is correct, color is correct), except there is a blank (black) horizontal line between the 2 quads.    Any help would be appreciated.    
  14.  I just started this shader stuff, but I think your vertex shader needs to output a color to the fragment shader.