Can any1 convert this shit from Masm to Fasm (this is procedure for adding texture to OpenGl
format iz TGA ) :
LoadTexture PROC lpTxtFname:LPVOID
LOCAL fileHandle:HANDLE
LOCAL fileSize:DWORD
LOCAL lpTmpMem:LPVOID
invoke CreateFile,lpTxtFname,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,NULL
mov fileHandle,eax
push eax
mov eax,esp
invoke GetFileSize,fileHandle,eax
mov fileSize,eax
pop eax
invoke LocalAlloc,LPTR,fileSize
mov lpTmpMem,eax
push eax
mov eax,esp
invoke ReadFile,fileHandle,lpTmpMem,fileSize,eax,NULL
pop eax
invoke CloseHandle,fileHandle
invoke LocalAlloc,LPTR,128*128*3
mov lpTxtImg,eax
push edi
push esi
mov edi,lpTxtImg
mov esi,lpTmpMem
add esi,18
mov ecx,128*128
@BGR2RGB:
mov al,
mov ah,
mov dl,
mov ,al
mov ,ah
mov ,dl
add esi,3
add edi,3
dec ecx
jnz @BGR2RGB
pop esi
pop edi
invoke LocalFree,lpTmpMem
_glBindTexture GL_TEXTURE_2D,1
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
_glTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_BLEND
invoke glTexImage2D,GL_TEXTURE_2D,0,3,txtW,txtH,0,GL_RGB,GL_UNSIGNED_BYTE,lpTxtImg
ret
LoadTexture ENDP
I dont have clue how to do that !
HELP !
Thnx in advance !
format iz TGA ) :
LoadTexture PROC lpTxtFname:LPVOID
LOCAL fileHandle:HANDLE
LOCAL fileSize:DWORD
LOCAL lpTmpMem:LPVOID
invoke CreateFile,lpTxtFname,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,NULL
mov fileHandle,eax
push eax
mov eax,esp
invoke GetFileSize,fileHandle,eax
mov fileSize,eax
pop eax
invoke LocalAlloc,LPTR,fileSize
mov lpTmpMem,eax
push eax
mov eax,esp
invoke ReadFile,fileHandle,lpTmpMem,fileSize,eax,NULL
pop eax
invoke CloseHandle,fileHandle
invoke LocalAlloc,LPTR,128*128*3
mov lpTxtImg,eax
push edi
push esi
mov edi,lpTxtImg
mov esi,lpTmpMem
add esi,18
mov ecx,128*128
@BGR2RGB:
mov al,
mov ah,
mov dl,
mov ,al
mov ,ah
mov ,dl
add esi,3
add edi,3
dec ecx
jnz @BGR2RGB
pop esi
pop edi
invoke LocalFree,lpTmpMem
_glBindTexture GL_TEXTURE_2D,1
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
_glTexParameteri GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
_glTexEnvi GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_BLEND
invoke glTexImage2D,GL_TEXTURE_2D,0,3,txtW,txtH,0,GL_RGB,GL_UNSIGNED_BYTE,lpTxtImg
ret
LoadTexture ENDP
I dont have clue how to do that !
HELP !
Thnx in advance !
Hmm, there are some question-marks here, at the line with the comment "<-- ??? ...", and on the line before return there are some unkown variables. I'll take closer look at the code below and see if I can make some thing out of it the translation might not work due to these questions.
I have attached an translation (well I made some changes, like using double precision floats instead of single) of lesson number 6 of the NeHe OGL tut (http://nehe.gamedev.net/), you will have to change the paths of the includes inorder to be able to compile it (compiled exe included), and I haven't made any thing to improve readabillty of the code, so reading might be hard and understanding the macros (glCall#, glPush#) can be easier if you read this thread http://www.asmcommunity.net/board/index.php?topic=11545.
I haven't made any real proc for reading bitmaps, so I'll probably do something with this, I you don't mind. For now I use bitmap resources, not the best solution but I got it to work ;)
proc LoadTexture, lpTxtFname
.fileHandle dd ?
.fileSize dd ?
.lpTmpMem dd ?
enter
invoke CreateFile, , GENERIC_READ, FILE_SHARE_READ, 0,\
OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, 0
mov [.fileHandle],eax
push eax
mov eax,esp
invoke GetFileSize,[.fileHandle],eax
mov [.fileSize],eax
pop eax
invoke LocalAlloc, LPTR,[.fileSize]
mov [.lpTmpMem],eax
push eax
mov eax,esp
invoke ReadFile, [.fileHandle], [.lpTmpMem], [.fileSize],eax,0
pop eax
invoke CloseHandle,[.fileHandle]
invoke LocalAlloc,LPTR,128*128*3
mov [.lpTxtImg],eax
push edi
push esi
mov edi,[.lpTxtImg]
mov esi,[.lpTmpMem]
add esi,18
mov ecx,128*128
@BGR2RGB:
mov al,
mov ah,
mov dl,
mov ,al
mov ,ah
mov ,dl
add esi,3
add edi,3
dec ecx
jnz @BGR2RGB
pop esi
pop edi
invoke LocalFree,[.lpTmpMem]
invoke glBindTexture, Gl_TEXTURE_2D, 1 ; <-- ??? 1 should be an pointer
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
invoke glTexEnvi, GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_BLEND
invoke glTexImage2D, GL_TEXTURE_2D,0,3,[.txtW],[.txtH],0,GL_RGB,GL_UNSIGNED_BYTE,[.lpTxtImg]
return
P.S. I think you don't have to swap the RGB bits, just change GL_RGB to GL_BGR, take a look in the opengl.hlp.
I have attached an translation (well I made some changes, like using double precision floats instead of single) of lesson number 6 of the NeHe OGL tut (http://nehe.gamedev.net/), you will have to change the paths of the includes inorder to be able to compile it (compiled exe included), and I haven't made any thing to improve readabillty of the code, so reading might be hard and understanding the macros (glCall#, glPush#) can be easier if you read this thread http://www.asmcommunity.net/board/index.php?topic=11545.
I haven't made any real proc for reading bitmaps, so I'll probably do something with this, I you don't mind. For now I use bitmap resources, not the best solution but I got it to work ;)
proc LoadTexture, lpTxtFname
.fileHandle dd ?
.fileSize dd ?
.lpTmpMem dd ?
enter
invoke CreateFile, , GENERIC_READ, FILE_SHARE_READ, 0,\
OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, 0
mov [.fileHandle],eax
push eax
mov eax,esp
invoke GetFileSize,[.fileHandle],eax
mov [.fileSize],eax
pop eax
invoke LocalAlloc, LPTR,[.fileSize]
mov [.lpTmpMem],eax
push eax
mov eax,esp
invoke ReadFile, [.fileHandle], [.lpTmpMem], [.fileSize],eax,0
pop eax
invoke CloseHandle,[.fileHandle]
invoke LocalAlloc,LPTR,128*128*3
mov [.lpTxtImg],eax
push edi
push esi
mov edi,[.lpTxtImg]
mov esi,[.lpTmpMem]
add esi,18
mov ecx,128*128
@BGR2RGB:
mov al,
mov ah,
mov dl,
mov ,al
mov ,ah
mov ,dl
add esi,3
add edi,3
dec ecx
jnz @BGR2RGB
pop esi
pop edi
invoke LocalFree,[.lpTmpMem]
invoke glBindTexture, Gl_TEXTURE_2D, 1 ; <-- ??? 1 should be an pointer
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR
invoke glTexParameteri, GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR
invoke glTexEnvi, GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_BLEND
invoke glTexImage2D, GL_TEXTURE_2D,0,3,[.txtW],[.txtH],0,GL_RGB,GL_UNSIGNED_BYTE,[.lpTxtImg]
return
P.S. I think you don't have to swap the RGB bits, just change GL_RGB to GL_BGR, take a look in the opengl.hlp.
Thenk you very much for Help.
And One More Thing do work with OGL in Fasm active or its just by the way
BYe n thnx again !
And One More Thing do work with OGL in Fasm active or its just by the way
BYe n thnx again !
And One More Thing do work with OGL in Fasm active or its just by the way
I'm sorry but I'm not sure if I understand what you mean, but if you're asking me why I'm doing OGL now, then the answer is that I'm trying to learn OGL so I can make some nice games and become rich... ;)
Serioulsy, I try to learn OGL for the same reason as many other things, for the fun of learning. And the fun of sharing knowledge with others is a good side effect. (I must admit that I like helping people, espectially some people IRL (in real life), not just with computers but in other subjects such as physics... Posted on 2003-03-26 14:55:13 by scientica
could anyone help me
have this macro (import.inc)
macro library
{ forward
local _label
if ~ name#.needed
dd 0,0,0,RVA _label,RVA name
end if
common
dd 0,0,0,0,0
forward
if ~ name#.needed
_label db string,0
end if }
what .needed mean. In the .pdf file i've not find needed info.
have this macro (import.inc)
macro library
{ forward
local _label
if ~ name#.needed
dd 0,0,0,RVA _label,RVA name
end if
common
dd 0,0,0,0,0
forward
if ~ name#.needed
_label db string,0
end if }
what .needed mean. In the .pdf file i've not find needed info.
basically its saying that if it sees a reference to that Library name in your code it becomes "needed" and space is alocated in your program for this. For instance, when you import kernel32,\ etc. 'ExitProcess' . Whenever the assembler finds ExitProcess in your program, which is from kernel32, kernel32 becomes "needed" in a sense, I just woke up so im hoping this helps you:)
well,
but what happen if i write
library user,'USER32.DLL'
and omit import clause for this lybrary.
fasm raise mistake.
i don't understand why it's mistake. :rolleyes:
but what happen if i write
library user,'USER32.DLL'
and omit import clause for this lybrary.
fasm raise mistake.
i don't understand why it's mistake. :rolleyes: