colinisinhere

Members
  • Content count

    372
  • Joined

  • Last visited

Community Reputation

100 Neutral

About colinisinhere

  • Rank
    Member
  1. Timing in linux

    Actually, I checked back, compiled in release mode, and close a couple of x apps, and it was much better. But it still isn't as good as I want/need it to be. Does anyone have a snippet of how Quake 3 does it? Since now it is GPL. I'd rather not look it up myself if someone has it handy, but I will if I have to.
  2. Timing in linux

    This timer does the same thing, inaccurate, and spuratic. Any ideas?
  3. Timing in linux

    Here is the meat of my timer class: #include "../core/Timer.h" Timer::Timer() { m_fStartTime = getMilliSeconds(); } Timer::~Timer() { } void Timer::start() { m_fStartTime = getMilliSeconds(); } f64 Timer::getInterval() { return (getMilliSeconds()-m_fStartTime); } f64 getMilliSeconds() { #ifdef LINUX_X86 struct timeval tm; struct timezone tz; gettimeofday(&tm, &tz); return (((double)(tm.tv_sec) + (double)(tm.tv_usec) * 0.000001))*1000; #endif } I used this time to rotate a cube, to test how accurate the timing is. But it is not accurate at all. It is very inconsistant, and jerky. Really nast on the eyes. Any ideas why it is like this? (BTW, f64 is double)
  4. Forcing certain sized ints and floats

    Do you mean, just in future versions? But right now they are standard?
  5. Forcing certain sized ints and floats

    so, for sure, gcc uses 16 bits shorts, 32 bit ints? No matter what?
  6. Forcing certain sized ints and floats

    yeah, I definatly want my code portable. It seems as though this must be able to be done somehow...
  7. Forcing certain sized ints and floats

    I'm working on Linux, using Eclipse as my IDE.
  8. I would like to make types with a certain size. For example: int16, int32, int64, float32, float64... etc I cant just do it like: typedef int16 short; Because I heard that for ints, it is dependent on the compiler/compiler. That the sizes can differ. I'm pretty sure that floats are always 32 and doubles are always 64. But how can I force a type to be a certain bit int? (Sorry, I had a hard time explaining what I want to do) (in C++)
  9. SDL_WarpMouse() = really slow?

    Zenthos: I changed some stuff... Everything is in the one function. And I completely removed the mouse event in Device::run() void Camera::setViewByMouse(dimension2d<unsigned short> screenSize) { int middleX = screenSize.width >> 1; int middleY = screenSize.height >> 1; float angleY = 0.0f; float angleZ = 0.0f; static float currentRotX = 0.0f; int x, y; SDL_GetRelativeMouseState(&x, &y); if((x == middleX) && (y == middleY)) return; angleY = (float)((middleX - x))/1000.0f; angleZ = (float)((middleY - y))/1000.0f; currentRotX -= angleZ; if(currentRotX > 1.45f) { currentRotX = 1.45f; } else if(currentRotX < -1.45f) { currentRotX = -1.45f; } else { vector3df vAxis = (m_vTarget - m_vPos).crossProduct(m_vUp); vAxis.normalize(); rotateView(angleZ, vAxis.x, vAxis.y, vAxis.z); rotateView(angleY, 0, 1, 0); } SDL_WarpMouse(middleX, middleY); } But now it doesn't work at all. The mouse returns at 0,0 on "SDL_GetRelativeMouseState(&x, &y);" ...
  10. SDL_WarpMouse() = really slow?

    There is no framerate drop, the framerate is extremly high. It is just that the movement of the mouse is laggy. What you said makes sense. I call SD_WarpMouse() every frame, and I also check for mouse events every frame. But I check for events first. Here is a simplified version of my code: // Device.cpp // bool Device::run() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_MOUSEMOTION: m_vMousePos.x = event.motion.x; m_vMousePos.y = event.motion.y; break; default: break; } } return active; } // Camera.pp // void Camera::setViewByMouse(dimension2d<unsigned short> screenSize, vector2di vMousePos) { int middleX = screenSize.width >> 1; int middleY = screenSize.height >> 1; float angleY = 0.0f; float angleZ = 0.0f; static float currentRotX = 0.0f; if((vMousePos.x == middleX) && (vMousePos.y == middleY)) return; angleY = (float)((middleX - vMousePos.x))/1000.0f; angleZ = (float)((middleY - vMousePos.y))/1000.0f; currentRotX -= angleZ; if(currentRotX > 1.45f) { currentRotX = 1.45f; } else if(currentRotX < -1.45f) { currentRotX = -1.45f; } else { vector3df vAxis = (m_vTarget - m_vPos).crossProduct(m_vUp); vAxis.normalize(); rotateView(angleZ, vAxis.x, vAxis.y, vAxis.z); rotateView(angleY, 0, 1, 0); } SDL_WarpMouse(middleX, middleY); } // Main.cpp // // MAIN LOOP // while(device->run()) { camera->setViewByMouse(renderer->getScreenSize(), device->getMousePos()); renderer->beginScene(); camera->render(renderer); ((OpenGLRenderer*)renderer)->renderTestCube(test.id); renderer->endScene(); } It might be hard to understand what is going on with just that small snippet.. But you will see that Device.run() runs every frame, and so does setViewByMouse(). Any ideas on how to make this faster?
  11. I'm using SDL_WarpMouse() to reset my mouse for my rotateByMouse() function in my 3d camera class. It works right, it is just extremly laggy. Has anyone else used this function for a 3d camera? Does it work for you? Any input? BTW I'm on Linux Thanks
  12. Is Quake 3's source ugly?

    I recently downloaded the Quake 3 source just for a peak. I looked at it and found it kinda ugly, poorly organized. Is this just me? Is it C in general that is ugly? Reading C++ source to a game is a lot easier, it feels more organized. Just wondering what your guy's input is. :P
  13. What language should i choose?

    Since basic C/C++ syntax is the same, it is a lot easier to deal with C as first, for basic games (like 3d pong and stuff). But personaly, I think all games should be programmed in C++. So much cleaner.
  14. Choppy SDL mouse input

    Here is my camera rotate-by-mouse function: void Camera::setViewByMouse(dimension2d<unsigned int> screenSize, vector2di vMousePos) { int middleX = screenSize.width >> 1; int middleY = screenSize.height >> 1; float angleY = 0.0f; float angleZ = 0.0f; static float currentRotX = 0.0f; if((vMousePos.x == middleX) && (vMousePos.y == middleY)) return; angleY = (float)((middleX - vMousePos.x))/1000.0f; angleZ = (float)((middleY - vMousePos.y))/1000.0f; currentRotX -= angleZ; if(currentRotX > 1.45f) { currentRotX = 1.45f; } else if(currentRotX < -1.45f) { currentRotX = -1.45f; } else { vector3df vAxis = (m_vTarget - m_vPos).crossProduct(m_vUp); vAxis.normalize(); rotateView(angleZ, vAxis.x, vAxis.y, vAxis.z); rotateView(angleY, 0, 1, 0); } SDL_WarpMouse(middleX, middleY); } I get the cursor location with (in a seperate class): case SDL_MOUSEMOTION: m_vMousePos.x = event.motion.x; m_vMousePos.y = event.motion.y; But the results are very choppy. The framerate is over 100 the whole time, so it has nothing to do with the framerate. Any ideas?
  15. SDL set mouse position?

    Is there a SDL function that can set the cursor position? Thanks