2 hopefully really easy questions

hi, so i finally got started on OF. i’m liking it a lot, it’s very new for me, being in C++ and all. i have 2 questions, my first one is:

how can i make glut calls like glRotatef(45, 0, 0, 1); self complete like they do when i type ofSetColor(0,0,0);. i found out i’m going to be using glut a lot because i like to push and pop the matrices and having simple rotate and translate is good instead of creating sin and cos functions for every little point on my whatever-shape. furthermore, does someone have the GLUT library in a clean sheet of html. what is being presented to me is frustrating.
this-is-frustrating (because it only brings me to my next point)
this-is-REALLY-frustrating (where is glrotatef()?)
this-is-really-cool
this-is-cool

you get what i mean? i’m-reading-about-all-these-calls and it’s like they don’t even exist…

my second question:
why does my very simple application slow down in direct relation to the size of my window. so if i resize my window all tiny, it runs hyper fast, if i resize it all big, i get big slowdown. as if it had to compute largeeeee nummmbbereerreessss!!! or something.

Hi Ramy

I don’t know very much about opengl, so sure there is much better references, but I think the problem is you are looking for glut reference, that is in fact the windowing system, google for opengl reference instead of glut… ie:

http://www.opengl.org/sdk/docs/man/

About the problem with the window size, I have the same issue, I thought it was the regular behaivour, but I remember seeing in a recent post that it doesn’t have to be like that. Perhaps is a linux issue, also another possible reason is the graphics card, mine uses shared memory, perhaps that’s the reason that it gets slower with the size of the window?

thanks arturo

that’ interesting, i’ll send my app to different ppl and see what happens to them.

can I ask what are the speed differences you are seeing?

one difference in speed is very likely related to clearing the background - this is actually a somewhat expensive (relatively) process, and if you have screen sizes that are very different, it could mean alot in terms of speed. again, if you are drawing nothing and vertical sync is off, it could be the difference between 300 fps and 900fps, or something like that (both crazy fast), but disabling background clearing is a better judge of the two different window sizes.

hope that helps!

take care,
zach

here’s the code, see what you think. it’s 2 circle connected by a line rotating in a circular fashion inside a box that is rotating the opposite way all while following your mouse… whatever, you’ll see.

what i did was i copied and pasted the emptyExample folder and renamed it ramy_try. so like this: of_preRelease_v0.05_linux_cb_FAT/apps/examples/ramy_try . That’s where it is.

this is the code i wrote inside the testApp.cpp file
using GCC to compile.
on ubuntu gutsy
code::blocks 5074

  
  
#include "testApp.h"  
  
float circle1X, circle1Y, circle2X, circle2Y;//X and Y positions for the 2 circles  
float upPosition = PI;//up in rad is PI  
float downPosition = PI/4;//down is PI/4  
float speed = TWO_PI/(PI*1000);  
  
int diameter = 40;  
  
float boxRotation = 0;  
//--------------------------------------------------------------  
void testApp::setup(){  
ofEnableSmoothing();  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
    circle1X = sin(upPosition)*diameter;  
    circle1Y = cos(upPosition)*diameter;  
  
    circle2X = sin(downPosition)*diameter;  
    circle2Y = cos(downPosition)*diameter;  
  
    upPosition += speed;  
    downPosition += speed;  
  
    boxRotation += 0.05;  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
    ofSetRectMode(OF_RECTMODE_CORNER);  
  
    ofSetColor(0,0,255);  
    ofRect(0,0, ofGetWidth()/2, ofGetHeight());  
  
    ofSetColor(255,0,0);  
    ofRect(ofGetWidth()/2, 0, ofGetWidth(), ofGetHeight());  
  
    ofNoFill();  
    ofSetColor(255,255,255);  
  
    ofLine(circle1X+mouseX,circle1Y+mouseY,circle2X+mouseX,circle2Y+mouseY);  
    ofCircle(circle1X+mouseX,circle1Y+mouseY, 10);  
    ofCircle(circle2X+mouseX,circle2Y+mouseY, 10);  
  
    glPushMatrix();  
        glTranslatef(mouseX, mouseY, 1);  
        glRotatef(boxRotation, 0, 0, 1);  
        ofSetRectMode(OF_RECTMODE_CENTER);  
        ofRect(0,0,100,100);  
    glPopMatrix();  
  
    ofFill();  
    ofCircle(circle1X+mouseX,circle1Y+mouseY, 10);  
    ofCircle(circle2X+mouseX,circle2Y+mouseY, 10);  
  
  
}  
  
//--------------------------------------------------------------  
void testApp::keyPressed  (int key){  
  
}  
  
//--------------------------------------------------------------  
void testApp::keyReleased  (int key){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseMoved(int x, int y ){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseDragged(int x, int y, int button){  
}  
  
//--------------------------------------------------------------  
void testApp::mousePressed(int x, int y, int button){  
}  
  
//--------------------------------------------------------------  
void testApp::mouseReleased(){  
  
}  
  

maybe there is something very wrong with the way i wrote the code. i don’t know. obviously any pointers are greatly appreciated.

i sent the app to my friend and he also saw that when he resized the window, it got way faster, and when he made it bigger, it got slower as the sized increased.

this wouldn’t bother me so much if it wasn’t for the fact that now i have to take into consideration the screen resolution if i want to make a full screen app, you know?

and at the same time this doesn’t feel like a big problem because i can just change the code to make it go as fast as it would when the window is small while at the same time being full screen. so it’s not even like" the computer has reached it’s limitations!!!" it didn’t because clearly i can just crank it.

anyways, tell me what you people think - and i promise to quit bitching about this, OF is still great.
i <3 OF

if you add,

printf(“frame rate %f \n”, ofGetFrameRate());

to the update, what does the console say?

what are the frame rates full size and small?

thanks
zach

ok so, when the window is maximized at 1280x1024 framerate is at 105, give or take 5.

when the window size is small, the** framerate is easily 750+** sometimes touching 800.

any insights?

thanks zach for taking the time to peek earlier.

thanks!

yes this is the cost of background clearing… when you have a small window, opengl needs to clear alot less, it’s simply that.

you can make it consistent if you want, by setting the frameRate, ie:
ofSetFrameRate(60);

take care!
zach

excellent man

super thanks!