texturing a quad
BlitzMax Forums/OpenGL Module/texturing a quad
| ||
I'm playing with opengl and trying to texture a quad although the texture does not appear. Any ideas? Also, is there a method for converting 2d vertex coordinates to 2d screen pixel coordinates? |
| ||
only works in full screen 'cause of an 'undocumented feature' >;p Global tex bglCreateContext (800, 600, 32, 0, bgl_fullscreen|BGL_BACKBUFFER | BGL_DEPTHBUFFER) 'bglSetSwapInterval(1) InitGl() While Not KeyHit(KEY_ESCAPE) mx=MouseX()-64 ; my=600-MouseY()-64 glClear GL_COLOR_BUFFER_BIT '| GL_DEPTH_BUFFER_BIT glLoadIdentity glColor3f 1.0,0.5,1.0 glEnable GL_TEXTURE_2D glBindTexture GL_TEXTURE_2D,tex ' quad glBegin GL_QUADS glTexCoord2f 0.0, 0.0 glVertex2f mx , my glTexCoord2f 1.0, 0.0 glVertex2f mx+120 , my glTexCoord2f 1.0, 1.0 glVertex2f mx+120 , my+120 glTexCoord2f 0.0, 1.0 glVertex2f mx , my+120 glEnd FlushMem bglSwapBuffers Wend End Function InitGl() glShadeModel(GL_SMOOTH) glClearColor(0.4, 0.6, 0.7, 0.5) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) glViewport(0,0,800,600) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluortho2d(0.0, 800, 0.0, 600) glMatrixMode(GL_MODELVIEW) glLoadIdentity() tex=bglTexFromPixmap(LoadPixmap("metal.bmp")) glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST End Function |
| ||
Hi Chris, I got it working in windowed and fullscreen modes (Win32Beta) but the image looks terrible. Any ideas on how to display pixel-perfect quads? |
| ||
re quads see above... pixel perfect and coloured, if you look at the code, there are errors in your attempt [edit] oh so thats wht u meant by pixel perfect! least you got an answer... Theres a bug in max at the mo re: mouse pointers and windowed mode... |