|
Post by Darkjester on Jun 4, 2009 9:04:24 GMT -5
Im trying to load a .raw file in basic4gl, i wrote this but it doesnt work
dim list = glgenlists(1)
glenable(gl_texture_2d) glNewlist (list, GL_COMPILE) glBegin (GL_TRIANGLE_STRIP) glTexCoord2f (0,0) : glVertex2f (-1,-1) glTexCoord2f (1,0) : glVertex2f (1, -1) glTexCoord2f (0,1) : glVertex2f (-1, 1) glTexCoord2f (1,1) : glVertex2f (1, 1) glEnd () glEndList ()
dim texture(0) as integer Dim FILE sub loadtextur(filename as string, x, y) FILE = openfileread(filename) if fileerror() <> "" then print FileError() closefile(file) endif dim &dat()() as string
readtext(file, true) closefile(file) glgentextures(1, texture) glbindtexture(gl_texture_2d, texture(0)) gltexenvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) gltexparameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) gltexparameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) glteximage2d(GL_TEXTURE_2D,0,GL_RGB,X,Y,0,GL_RGB,GL_UNSIGNED_BYTE, file) endsub
loadtextur("test.raw",32,32)
while true glclear(gl_color_buffer_bit) glloadidentity()
gltranslatef(0,0,-6) glbindtexture(gl_texture_2d,texture(0)) glcalllist(list)
swapbuffers() wend
|
|
|
Post by matthew on Jun 4, 2009 21:45:28 GMT -5
I'm sure there was an example of loading a .raw file somewhere on the forum. I've tried looking for it but I couldn't find it, so I did a Google search & found this page. Maybe it'll be of some use to you.
|
|
cameron
Posts
A new take on the old ASCII smiley face, because thats how you feel after 16 hours of coding.
Posts: 70
|
Post by cameron on Jul 14, 2009 5:17:16 GMT -5
Right, I don't know how Tom implemented file handles in B4GL, but I know from experience in trying to pass VB file handles to C dlls which used Low Level I/O, that wouldn't work because VB enumerated file handlers for each application not for the whole O/S like the Low Level I/O does.
The reason ur code and that code in that link might not work is because the glteximage2d file handle/stream pointer parameter might:
1) Expect an file stream pointer, and you could be passing it an B4GL file handle.
2) Expect an Low Level I/O file handle, and you could be passing it an stream pointer.
3) Expect an Low Level I/O file handle, and you could be passing an B4GL-specific file handle.
But from my days of 3D programming with OpenGL, if your giving it what it wants for the file parameter, from my scratchy memory IT SHOULD BE WORKING. But if it was me, I wouldn't be asking this here, I would be consulting the OpenGL Red Book and B4GL's documentation.
|
|