starting place
BlitzMax Forums/OpenGL Module/starting place
| ||
ok, after leaving ogl alone for a while i decided to return to it, i've gone back over the basics, just creating a quad. now i'm guessing i've done something wrong as to get a square with 4 equal sides i though i was just need to use 1.0 for n value i changed in glvertex3f() but i'm finding i have to change some values to 0.5 to get n e thing that looks even. here is some code and maybe someone can point out what i've done wrong.SetGraphicsDriver GLGraphicsDriver() GLGraphics 640,480 glViewport(0,0,640,480); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0,640/480,0.1,100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Repeat glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() glTranslatef(0,0.0,-6.0); glBegin(GL_QUADS); glColor3f(0.0,0.0,1.0); glVertex3f( 0.0, 0.5, 0.0); glColor3f(0.0,1.0,0.0); glVertex3f(0.0,-1.0, 0.0); glColor3f(1.0,0.0,0.0); glVertex3f( 1.0,-1.0, 0.0); glColor3f(0.0,1.0,1.0); glVertex3f( 1.0,0.5, 0.0); glEnd(); Flip() Until KeyDown(key_escape) |
| ||
you shouldn't have to do anything more than flip a few signs for a square. glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); I don't have access to bmax right at the moment but I'll check it out tonight if no one else comes up with a solution. |
| ||
maybe its to do with my perspective then as it warps as it turns if or as i move camera changing gluPerspective(45.0,640/480,0.1,100.0); to gluPerspective(45.0,1.333,0.1,100.0); seems to work, but i thought that'd be the same thing |
| ||
640/480 is an integer division. If you want to have float result, use at least one float (640.0/480 or 640/480.0) |
| ||
ah , excellent, thx alot m8 |
| ||
ok, all initial issues sorted, now creating cubes etc which are textured using a 512 x 512 jpg image, it looks fine when the image is facing direct to user, however as the cube rotates the image loses alot of quality and goes very blocky. quiet strange, n e know if there is n e thing i need to enable to stop it? |
| ||
perhaps glShadeModel(GL_SMOOTH)? |
| ||
hmmm...may well be, will try when i get home, although may have tried it, if not i'll just post sample project |
| ||
use mip mapping try this after you load the texture. glBindTexture(GL_TEXTURE_2D, texturenumber) glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR) glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR) glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT) glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT) |
| ||
@DJ Scantron Works like a dream, now looks so much smoother. thanks |
| ||
hey all, I'm doing rotation of a quad with code glrotatef(sr,0.0,0.0,1); glBegin(GL_QUADS); glColor3f(0.0,0.0,1.0);glVertex3f(0.0, 0.0, 0.0); glColor3f(0.0,1.0,0.0);glVertex3f(0.0, 32.0, 0.0); glColor3f(1.0,0.0,0.0);glVertex3f(32.0,32.0, 0.0); glColor3f(1.0,0.0,1.0);glVertex3f(32.0,0.0, 0.0); glEnd(); If KeyDown(KEY_P) Then sr=sr+2; this rotates the quad around the top left point, how can i shift the rotation to the center of the quad? *EDIT - sorted it, just offset the translate and the quad coords like so: 1 glTranslatef(sx+16,sy+16,0); glrotatef(sr,0.0,0.0,1); glBegin(GL_QUADS); glColor3f(0.0,0.0,1.0);glVertex3f(-16.0, -16.0, 0.0); glColor3f(0.0,1.0,0.0);glVertex3f(-16.0, 16.0, 0.0); glColor3f(1.0,0.0,0.0);glVertex3f(16.0,16.0, 0.0); glColor3f(0.6,0.6,0.6);glVertex3f(16.0,-16.0, 0.0); glEnd(); |
| ||
If you're learning OpenGL I strongly recommend you get yourself a copy of the official programming guide (red book): http://www.opengl.org/documentation/red_book/ I wouldn't have been able to write MiniB3D without it, it will tell you everything you need to know from the basics to the fancy stuff. |
| ||
thx Simonh, will get a copy and learn, learn tilli cry |