Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Getting textures drawn faster

jounijouni Member Posts: 8
I've managed to code a programm which draws textures. It works well, but is too slow. The function which draws the triangle, is about 300 rows long. When I left light effects and depth-buffer out, the code shortened to 200 rows, and suprisingly my programm got about 30% faster, but was still too slow. I got impression that my triangle-drawing-function would get faster, if I managed to get it shorter. But my code is as optimized as I can get it!
Is there anyone here who has coded this stuff? What's the secret to get textures drawn as fast as they are in the big games?
«1

Comments

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : I've managed to code a programm which draws textures. It works well, but is too slow. The function which draws the triangle, is about 300 rows long. When I left light effects and depth-buffer out, the code shortened to 200 rows, and suprisingly my programm got about 30% faster, but was still too slow. I got impression that my triangle-drawing-function would get faster, if I managed to get it shorter. But my code is as optimized as I can get it!
    : Is there anyone here who has coded this stuff? What's the secret to get textures drawn as fast as they are in the big games?
    :
    I suggest using OpenGL. It's the fastest and most detailed API out there, but requires a 100% OpenGL compliant video card, like an nVidia. If you use an ATI or other brand, then I suggest DX, since although it is slower, it runs on any hardware you throw at it!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • jounijouni Member Posts: 8
    It has been kind of a challenge for me to make 3D graphics work on my own. I could probably avoid some troubles by giving up...
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    : It has been kind of a challenge for me to make 3D graphics work on my own. I could probably avoid some troubles by giving up...
    :
    3D stuff is just extremely complicated if you're doing it on your own. I tried a long time ago and succeeded, but it took so much math and then the results were not what I wanted. That is when I went to DX, saw how bad it sucked after a month of toying, then found OpenGL and haven't strayed since. If you have a LOT of trigenometry, geometry, and calculus knowledge, you could pull off your own 3D renderer with little trouble, but if not, that is where you should start. Without that math, nothing anybody tells you will do any good, up to a point.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • jounijouni Member Posts: 8
    Actually I'm kind of a math freak.
    But okey, here's a more accurate question: Where could I find out how much time different operations take from the processor? I mean, that multiplying and dividing variables is probably slower than adding and subtracting them. How about "for" and "while", are they equal in speed? Is there any accurate numbers about these things?

  • iDaZeiDaZe Member Posts: 464
    : Actually I'm kind of a math freak.
    : But okey, here's a more accurate question: Where could I find out how much time different operations take from the processor? I mean, that multiplying and dividing variables is probably slower than adding and subtracting them. How about "for" and "while", are they equal in speed? Is there any accurate numbers about these things?
    :
    :

    for and while should take about the same time. One way to speed things up (if you don't use it already) is to use inline assembler. I tested it a couple of years back in Pascal. I tested a while loop within a while loop within a while loop against the same type of construction in inline assembler using jmp, add, etc... statements and the assembler loop executed about 3 to 4 times as fast.
  • jounijouni Member Posts: 8
    : for and while should take about the same time. One way to speed things up (if you don't use it already) is to use inline assembler. I tested it a couple of years back in Pascal. I tested a while loop within a while loop within a while loop against the same type of construction in inline assembler using jmp, add, etc... statements and the assembler loop executed about 3 to 4 times as fast.
    :

    Now we are coming to the problem that I don't know much of programming...
    Is this inline assembler that thing when you write asm{ ...stuff... }?
    I have couple of these things copied from my friend's code, but I don't understand them myself. Could you tell how these jmp, add and other statments are used in inline assembler? (My friend has also copied them from somewhere, and doesn't understand them either.)

  • jounijouni Member Posts: 8
    : : for and while should take about the same time. One way to speed things up (if you don't use it already) is to use inline assembler. I tested it a couple of years back in Pascal. I tested a while loop within a while loop within a while loop against the same type of construction in inline assembler using jmp, add, etc... statements and the assembler loop executed about 3 to 4 times as fast.
    : :
    :
    : Now we are coming to the problem that I don't know much of programming...
    : Is this inline assembler that thing when you write asm{ ...stuff... }?
    : I have couple of these things copied from my friend's code, but I don't understand them myself. Could you tell how these jmp, add and other statments are used in inline assembler? (My friend has also copied them from somewhere, and doesn't understand them either.)
    :
    :
    Okey, I found a book on assembler programming. I faced a following problem:
    I have two short variables, tr_cy and ya. Then I try this:
    _asm{
    mov tr_cy, ya
    }
    Compiler tells me I have "invalid instruction operands". What's going on? According to my book "mov tr_cy, ya" in assembler is same as "tr_cy=ya;" in C.
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    I can't help you much with ASM. I suggest posting on our ASM board for stuff related to it. I'm not trying to run you off or anything, but I do all plain C and/or C++ (NOT VISUAL EITHER, I USE WORDPAD BABY!) and I cannot offer support on it. However, when you get your ASM routines setup and going good, I can help you with most any 3D question. Oh, and for future reference, ASM is the FASTEST language I know of, but is also probably the hardest to learn because it isn't exactly readable like C or Basic or Pascal are. However, if you learn it well enough to make stable apps, the app requirements will be MUCH lower than the same app coded in anything else.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • ZaffireZaffire Member Posts: 22
    : Okey, I found a book on assembler programming. I faced a following problem:
    : I have two short variables, tr_cy and ya. Then I try this:
    : _asm{
    : mov tr_cy, ya
    : }
    : Compiler tells me I have "invalid instruction operands". What's going on? According to my book "mov tr_cy, ya" in assembler is same as "tr_cy=ya;" in C.
    :
    In ASM, the MOV operand can't move from a memory location to another memory location. That's just the way the processor works. Try moving one of them to a register first:

    _asm
    {
    mov ax,ya
    mov tr_cy,ax
    }

    That should work better. Hope that helps!


    Zaffire

  • jounijouni Member Posts: 8
    : In ASM, the MOV operand can't move from a memory location to another memory location. That's just the way the processor works. Try moving one of them to a register first:
    :
    : _asm
    : {
    : mov ax,ya
    : mov tr_cy,ax
    : }
    :
    : That should work better. Hope that helps!
    :
    :
    : Zaffire
    :

    Actually I found out that on my own by looking some examples, but thanks anyway. Since my assembler problems are not directly related to 3D-graphics, I went to Assembler messageboard. I have one other problem there under topic of "getting started with assembler". If you Zaffire (or anyone else!) know this assembler stuff, could you check that out? It's about moving float-variables.

«1
Sign In or Register to comment.