Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


MarkS

Member Since 09 Jan 2001
Online Last Active Today, 09:46 AM

#5229876 win32 cpu render bottleneck

Posted by MarkS on 19 May 2015 - 12:24 PM

I'm just disappointed in this thread. I have an affinity for software renderers. I started graphics development back on the Mac in the early 90's and stuck with the Mac through the original iMac. I didn't have access to hardware acceleration until I bought my iMac and that was a Rage Pro chip with hardly any acceleration at all.

No one here is going to have a problem with you writing a software renderer, but your reasons for doing so make no sense. We are just trying to understand why and you seem to be going around in circles looking for an explanation. You're asking people to dig deep into their memories for techniques that they haven't had the need to use in at least 20 years. They deserve to know why.

One of my hobbies is electronics engineering and I have an old Mac LC II motherboard lying around. I've been fighting the urge to harvest the 68030 and build a retro computer. If I do so, I'll need to write a software graphics library. I think that would qualify as reason #5.


#5228155 Basic 2D array C problem

Posted by MarkS on 09 May 2015 - 12:58 PM

I think he's exaggerating a bit. I learnt C first and I had no trouble learning C++ afterward.


I'm really not.


#5228043 Basic 2D array C problem

Posted by MarkS on 08 May 2015 - 09:27 PM

I started out with C back in the early 90's. The first compiler I had was Think C on the Mac. It was a straight C compiler with absolutely no C++ features. I learned the bulk of my programming habits and techniques back then. When I was finally exposed to C++ and OOP, C was so strongly ingrained into my way of thinking that C++ was like looking at old English. Sure, I could read it, but God help me understand it! As a result, I blew off C++ for more than a decade.

There is little reason to learn C. The programming community, by and large, has moved away from it and its principles. Learning C will bog you down in a mire that will be hard to pull yourself out of. The C concepts that are still in use in C++ will be learned when learning C++. The two stalwarts of C development today are operating system development and embedded systems development and both of those are transitioning away.

If I could do it over, I would have never learned C. I would have went directly to C++.




#5227813 Basic 2D array C problem

Posted by MarkS on 07 May 2015 - 11:55 AM

Good to know!

Arrays are used to store data. The way you wrote the first code snippet really didn't use the array. Fill the array and THEN use the stored data. Don't fill the array AND use the stored data. It's a waste of memory in that case, unless the array will be used further on.

Note that I got rid of "row" and "column". They are redundant. In a more complicated example, additional variables would help to make the code clearer. In this case, they add unnecessary verbiage. It doesn't hurt to use them, but it is just more typing for the same effect.

This would make more sense:
 
//Multiplication table using 2D array

#include<stdio.h>
#include<conio.h>

main()
{
    int mul[5][5];
    int i,j;

    clrscr();
    printf("Here is the multiplication table \n ");

    // Fill the multiplication table array.
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            mul[i][j]= (i + 1) * (j + 1);
        }
    }

    // Here you might do operations on the array data....

    // Print the array.
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            printf("%5d",mul[i][j]);
        }
        printf("\n");
    }
    getch();
    return 0;
}
You can also unroll the loops:
 
//Multiplication table using 2D array

#include<stdio.h>
#include<conio.h>

main()
{
    int mul[5][5];
    int i;

    clrscr();
    printf("Here is the multiplication table \n ");

    // Fill the multiplication table array. Unroll and eliminate the 'j' loop.
    for(i=0;i<5;i++)
    {
        mul[i][0]= (i + 1);
        mul[i][1]= (i + 1) * 2;
        mul[i][2]= (i + 1) * 3;
        mul[i][3]= (i + 1) * 4;
        mul[i][4]= (i + 1) * 5;
    }

    // Here you might do operations on the array data....

    // Print the array.
    for(i=0;i<5;i++)
    {
        printf("%5d%5d%5d%5d%5d\n",mul[i][0],mul[i][1],mul[i][2],mul[i][3],mul[i][4]);
    }
    getch();
    return 0;
}
Or you can use a one dimensional array as a two dimensional array:
 
//Multiplication table using 2D array

#include<stdio.h>
#include<conio.h>

main()
{
    int mul[25];
    int i,j;

    clrscr();
    printf("Here is the multiplication table \n ");

    // Fill the multiplication table array.
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            mul[(i * 5) + j]= (i + 1) * (j + 1);
        }
    }

    // Here you might do operations on the array data....

    // Print the array.
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            printf("%5d",mul[(i * 5) + j]);
        }
        printf("\n");
    }
    getch();
    return 0;
}
Or this... Now I'm just having fun! biggrin.png
 
//Multiplication table using 2D array

#include<stdio.h>
#include<conio.h>

main()
{
    int mul[5][5];
    int *table_ptr;
    int i,j;

    printf("Here is the multiplication table \n ");

    // Fill the multiplication table array.
    for(i=0;i<5;i++)
    {
	table_ptr = &mul[i][0];

        *table_ptr++ = (i + 1) * 5;
        *table_ptr++ = (i + 1) * 4;
        *table_ptr++ = (i + 1) * 3;
        *table_ptr++ = (i + 1) * 2;
        *table_ptr = (i + 1);
    }

    // Here you might do operations on the array data....

    // Print the array.
    for(i=0;i<5;i++)
    {
	table_ptr = &mul[i][0];
        printf("%5d%5d%5d%5d%5d\n",*table_ptr,*table_ptr++,*table_ptr++,*table_ptr++,*table_ptr++);
    }
    getch();
    return 0;
}



#5227447 Basic 2D array C problem

Posted by MarkS on 06 May 2015 - 12:07 AM

I'm curious why you are using an array at all. This is much cleaner:

#include<stdio.h>
#include<conio.h>
main()
{
    int i,j;  
    clrscr();
    printf("Here is the multiplication table \n ");
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            int product = (i + 1) * (j + 1);
            printf("%5d",product);
        }
        printf("\n");
    }
    getch();
    return 0;
}



#5227446 Basic 2D array C problem

Posted by MarkS on 06 May 2015 - 12:03 AM

It's these little mistakes that get you. I couldn't even see it at first.


#5227444 Basic 2D array C problem

Posted by MarkS on 05 May 2015 - 11:59 PM

This line right here is a problem:
 

for(i=0;i<5;i++);


Remove the semicolon at the end of the for statement. This is a do nothing loop. It increments 'i' to 4 and continues.


#5227442 Basic 2D array C problem

Posted by MarkS on 05 May 2015 - 11:49 PM

Not with the code you posted, it isn't...

 

Just out of curiosity, this wouldn't happen to be a homework problem, would it?




#5227440 Basic 2D array C problem

Posted by MarkS on 05 May 2015 - 11:43 PM

Well.... I don't know. What is it doing? What were you expecting it to do? It looks OK, but I'm not going to compile your code to figure out the issue.




#5227400 Question about reputation system

Posted by MarkS on 05 May 2015 - 04:57 PM

You were down voted by "DoctorGlow", who from what I can tell, only down votes members.

 

That being said, you down voted the member who asked a very legitimate question. If you are going to down vote everyone that asks why you are doing something, you are going to be down voting a lot of people!




#5227051 Font Rendering without bitmap textures for localization

Posted by MarkS on 03 May 2015 - 06:36 PM

If they are rendered directly into bitmaps, then how does translation work for this then? Does each language need their own texture and associated glyph information?


Yes, and this is also complex. Take Arabic, for example. It is written from right to left. Not only that, but the correct glyph to be rendered depends on its position in the word!

Watch this. He is describing some of what Twitter must do to support localization. It gets really interesting at 0:39, again, using Arabic as a particularly brutal example.



To that end, it should be mentioned that localization is not the same as font rendering. Localization means taking the particulars of a language into account when rendering the characters to screen. This requires knowledge of the language. Being able to render a Chinese glyph is meaningless if you don't know that the sentences are written vertically.


#5227047 Font Rendering without bitmap textures for localization

Posted by MarkS on 03 May 2015 - 06:15 PM

FreeType takes a supplied font and renders the character you specify into a bitmap that can then be rendered as a texture. I know you want to render straight vector graphics, but the complexity required would bring any game you are making to a crawl. Windows doesn't even draw vector fonts directly. It renders them into bitmaps behind the scenes and blits the bitmaps.

 

I'm sorry, but what you are wanting to do just isn't practical, at least not in a game. Take the advice you're being given and use a library to do this for you. Vector fonts are not designed, typically, as a list of polygons that can be extracted and rendered. They are defined by points making up empty Bezier paths that must be filled using highly complex rules. This is a non-simple problem.

 

[edit] "isn't possible" isn't correct. It *is* possible, Cairo and Inkscape do it, but impractical.




#5227041 Font Rendering without bitmap textures for localization

Posted by MarkS on 03 May 2015 - 06:05 PM

You really should look at the code. No, you cannot just render a font with DirectX or OpenGL. [edit] You can, but it is very difficult! You really do not have a grasp on the complexity of what you are asking! I'm not trying to be discouraging, just realistic. To do this correctly, especially for non-English fonts, is a MASSIVE undertaking requiring intimate knowledge of font design that you don't have.

Again, take a look at the FreeType code. ALL of it is just to render a SINGLE glyph out of a font. The code base is huge and wildly complex.




#5227038 Font Rendering without bitmap textures for localization

Posted by MarkS on 03 May 2015 - 05:55 PM

Before you down vote someone, do some reading on the library they give you. dry.png  FreeType is a library that renders vector fonts. I've used it in the past. It will render any font you can throw at it, vector or bitmap. It would also help for you to look at the code. It's a nightmare! You DO NOT want to do this yourself!




#5226458 Spot the bug quiz.

Posted by MarkS on 30 April 2015 - 03:01 AM

Interesting quiz, but it's too picky about what you're supposed to click on. In some cases, I wanted to select the entire code snippet.

Yeah I gave up on the memcmp(a,b,c  == 0) question (which should be memcmp(a,b,c)==0)
 
My answer was "The ==0 is in the wrong place, it needs to be after the close-parenthesis", so I clicked on the ==.
But then the quiz said "Nope! The close-parenthesis is in the wrong place, it needs to be before the ==".
angry.png


But the "==" is exactly where it should be! The ")" is out of place! tongue.png




PARTNERS