steffenomak

Members
  • Content count

    4
  • Joined

  • Last visited

Community Reputation

100 Neutral

About steffenomak

  • Rank
    Newbie
  1. SDL - CPU usage

    Oh, this helped me, thank you , when I tried whit a normal window, the window used a 100% on one core, but when i added SDL_Delay( 0 ); it made the load go down to 0% when nothing happaned.
  2. OpenGL zoom in and out

    [quote]Original post by jyk lol, I solved it by placing object directly deeper in to the screen and out of the screen lol. So that means I cant move the camera whit glTranslatef it just moves the focus for the glVertex starting point. Funny
  3. OpenGL zoom in and out

    Quote:Original post by jyk Are you using a perspective projection, or an orthographic projection? If it's the latter, changing the camera distance won't give you the effect you're after (more info on orthographic projections here). You can however create a zoom effect by modifying the parameters of the orthographic projection matrix. In straightforward terms, moving the sides of the orthographic frame (left, right, bottom, and top) closer together will create a 'zoom in' effect, and moving them farther apart will create a 'zoom out' effect. The resize event that does some things and i thing there it sets it to projection but i dont know void GLRender::resizeGL( int w, int h ){ if( h == 0 ){ h = 1; } glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45.0f, (GLfloat)w/(GLfloat)h, 0.1f, 100.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } But could you give an super small example is you would be so nice.
  4. Hi I'm using OpengGl Qt and Box2d to make a game of sorts. The problem I'm having is that when i use glTranslate3f and at the z parameter put something there, there is no diffrense. I want to be able like zooming and stuff. I have just started learning some opengl, but then I started making box2d working in qt but whit qts paintingmethods beeing not to my liking i just made opengl render everything. The code for everything is in a mess becouse I havent starting cleaning up and making elegant solutions, i only whant something that works. The code that renders the sceene, or at least all the boxes, ill post here and if some one whant to download the source I'll put up a link void World::renderWorld(){ RenderShape painter; painter.set_render_mode( SolidRender ); GLfloat x=0.0f; GLfloat y=0.0f; GLfloat w=0.0f; GLfloat h=0.0f; GLfloat a=0.0f; GLfloat z = 0.0f; GLfloat cameraZoom = -6.0f; GLfloat cameraY = 0.0f; GLfloat cameraX = 0.0f; glLoadIdentity(); glTranslatef( 0.0f, 0.0f, cameraZoom ); QListIterator<Body *> list( bodyList ); int i=0; while( list.hasNext() ){ Body *temp = list.next(); if( temp->get_frozen() == false ){ x = temp->get_x(); y = temp->get_y(); w = temp->get_width() / 2.0f; h = temp->get_height() / 2.0f; a = temp->get_angle_deg(); glTranslatef( x, y, z ); GLfloat color1[] = { 0.0f, 0.0f, 0.0f }; GLfloat color2[] = { 0.5f, 0.5f, 0.5f }; GLfloat color3[] = { 1.0f, 1.0f, 1.0f }; if( temp->get_body_type() == square ){ temp->get_dynamic() ? painter.render_square( w, h, a, color1 ): painter.render_square( w, h, a, color2 ); } else if( temp->get_body_type() == circle ){ w *= 2.0f; temp->get_dynamic() ? painter.render_circle( w, color1 ): painter.render_circle( w, color2 ); } glLoadIdentity(); glTranslatef( 0.0f, 0.0f, -6.0f ); } else { delete temp; bodyList.removeAt( i ); } i+=1; } GLfloat c[] = { 0.0f, 0.0f, 0.0f }; painter.render_grid( -3.0f, 3.0f, 6.0f, 6.0f, 0.1f, c ); target->render( cameraX, cameraY, cameraZoom ); glLoadIdentity(); glTranslatef( cameraX, cameraY, cameraZoom ); } the source link: http://www.megaupload.com/?d=A1J5WNPY [Edited by - steffenomak on February 16, 2010 2:00:33 AM]