| | |
OpenGL - displaying issue (reshape func)
Thread Solved |
Hello,
my problem is of that kind beginners use to have. After following some glut tutorials I've decided it's time to do something small generally on my own. An obstacle appeared at the very beginning.
At the moment I got stuck, all my code was supposed to do was drawing a primitive using an ortagonal transformation to display it. Apperently, I failed at coding the latter.
and the drawing func("bobby's" variables x and y are holding float values, tried with various bare numbers too):
Guess I could solve this with a little help of an example code, but I'd like to understand what I'm doing. Thanks.
my problem is of that kind beginners use to have. After following some glut tutorials I've decided it's time to do something small generally on my own. An obstacle appeared at the very beginning.
At the moment I got stuck, all my code was supposed to do was drawing a primitive using an ortagonal transformation to display it. Apperently, I failed at coding the latter.
c++ Syntax (Toggle Plain Text)
void reshape (int w, int h) { if (h==0) { h=1; } glViewport(0,0,w,h); glMatrixMode (GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f,w,h,0.0f,-1.0f,1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
and the drawing func("bobby's" variables x and y are holding float values, tried with various bare numbers too):
c++ Syntax (Toggle Plain Text)
void DrawScene(void) { glPushMatrix(); glTranslatef(bobby.x, bobby.y, 0.0f); glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_TRIANGLES); glVertex2d(-0.2, -0.2); glVertex2d(0.2, 0.2); glVertex2d(0.2, -0.2); glEnd(); glPopMatrix(); glutSwapBuffers(); }
Guess I could solve this with a little help of an example code, but I'd like to understand what I'm doing. Thanks.
•
•
Join Date: Aug 2009
Posts: 27
Reputation:
Solved Threads: 2
I don't know what other calls you have there...
but first make sure everything is off:
Then...
Also it looks from there that Ortho Call is too vast scaled. Ortho sets a cordinte system. Your cordinate system goes from 0 to w (or h), thus scale is 1024 on both sides. If you draw then a Triangle with 0.2, guess where it is? Probably in the vast space of the opengl universe...
Either change glOrtho
double itsUnit=1.0f;
double itsRatio=1024.0f/768.0f;
glOrtho(0.0, itsUnit*itsRatio, 0.0, itsUnit, 0, 10);
or Change the size of your trinagle..
glVertex2d(-400, -400);
Could be other things as well, but for that I would need to see the whole code.
&Cheers,
poliet
but first make sure everything is off:
C++ Syntax (Toggle Plain Text)
glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glDisable(GL_ALPHA);
Then...
Also it looks from there that Ortho Call is too vast scaled. Ortho sets a cordinte system. Your cordinate system goes from 0 to w (or h), thus scale is 1024 on both sides. If you draw then a Triangle with 0.2, guess where it is? Probably in the vast space of the opengl universe...
Either change glOrtho
double itsUnit=1.0f;
double itsRatio=1024.0f/768.0f;
glOrtho(0.0, itsUnit*itsRatio, 0.0, itsUnit, 0, 10);
or Change the size of your trinagle..
glVertex2d(-400, -400);
Could be other things as well, but for that I would need to see the whole code.
&Cheers,
poliet
Last edited by poliet; Aug 22nd, 2009 at 9:33 pm.
![]() |
Similar Threads
- problem with upload script (PHP)
- Java problems - not displaying in IE6 (Web Browsers)
- Drawing Text in OpenGL (C++)
- OpenGL in C (errors) (C)
- STP to Opengl (Computer Science)
- FlexGrid issue and error "Invalid Row value".... (Visual Basic 4 / 5 / 6)
- Boot up issue with xp (Windows NT / 2000 / XP)
- error C2664: cannot convert parameter 1 from 'float (void)' to 'float' (Game Development)
- need help with a php issue (PHP)
- setting width and fill character...(a compiler issue?) (C++)
Other Threads in the Game Development Forum
- Previous Thread: Direct3D9 Sprite issues with rotation.
- Next Thread: falling of a bmp under gravity - glut
| Thread Tools | Search this Thread |
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamer games gaming gauntanamo government idaho in-gameadvertisement intellectualproperty l-systems laracroft lindenmayer live manhunt math mathematics matrix mercenaries microsoft mmorpg modded msn naked news nintendo obama opengl palin physics pirate playstation politics projection ps3 rpg search selection software sony stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox-live xbox360





