Jump to content
  • Advertisement
Sign in to follow this  
c_young

displaying html in c++

This topic is 4091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in working on a simple web browser for a school project, i already have the networking side programed out and can retreive the html file from websites; but its only being displayed as text. what is the most official way to display the html file graphically instead of as text? ive searched google but havent been able to find anything.

Share this post


Link to post
Share on other sites
Advertisement
That's an extremely challenging task. I assume you already know graphics programming?

Also, I hope you're not planning on being able to display actual internet pages. Even a "simple" web browser would take a big team many months to accomplish: javascript, CSS, nested tables, dynamic layers, embedded plugins, etc.

Simple HTML is basically just a 2D layout. But parsing the text into that layout can be incrediably difficult. You're going to need to recurse all the table structures and build out a 2D map of where items go (taking into account the dimensions of any images in the text, etc).

I'd imagine that if you haven't done graphics programming before that this will be a nearly impossible task. Even if you do have the experience, I'd imagine that it'd take you a few weeks of full-time work to get even a simple table structure rendering.

Probably the best thing to start out with is just a simple page with text and some images (no tables, or any other complex structure). After that get a simple table rendering. Then nested tables. Forget about anything having to do with CSS or things like that.

-me

Share this post


Link to post
Share on other sites
There is only one official way:
http://www.w3.org/TR/html401/

HTML 4.01 standard (anything above that involves much more, such as CSS, making rendering considerably more complex). Although implementing it is hell, not to mention huge task.

There's also problem with standards compliance, so most applications that need to display HTML embed a browser component.

In your case that might be somewhat self-defeating, since embedded components take care of connection as well.

Share this post


Link to post
Share on other sites
I assumed you were trying to code your own renderer. That's perhaps not what you're looking for.

If not then I'm sure there is an IE or firefox renderer that you could just plugin to a windows app (but then those probably come with all the networking stuff already implemented, thus defeating the purpose of your app...). Check out msdn.microsoft.com for info on IE, and google around for firefox info.

-me

Share this post


Link to post
Share on other sites
i know some basics in graphics programming, and i wasnt planning for javascript or anything like that. like you said all i want is to be able to display some text and a couple picutres.

so what your all saying is i have to manually sort through the html page and read the code and display it myself?

Share this post


Link to post
Share on other sites
Quote:
Original post by c_young
i know some basics in graphics programming, and i wasnt planning for javascript or anything like that. like you said all i want is to be able to display some text and a couple picutres.

so what your all saying is i have to manually sort through the html page and read the code and display it myself?


The times of HTML being text and pictures are long gone.

HTML 4 standard is considered old, and that one is complex. But once you get to CSS and advanced layout with DOM, things get really bad.

Incompatibilities of today's browsers don't come from developers being incompetent - the standard is just so huge, and majority of its features rarely get used, thus leading to incomplete or ambigous implementations of the standard.

Today's web pages rely on all these features, so implementing a simple version won't be able to render even the basic ones, hence, there are only a handful of commercial/professional implementations, and none of others come even close. Add to that that any useful browser must account for incompatible and non-compliant historically defines rules, and you get a huge mess.

Rendering HTML isn't trivial. Just look at standard. Each element has many rules, many special cases, some inconsistencies, and plenty of over-engineering.

The most you could hope to do quickly is probably HTML 2 standard, which doesn't include much layout. You'll need a way to render text, and calculate the image layouts. Then, most pages rely on tables for formatting to a degree. So you can't really skip those.

But unless you provide these, and just want to render text, then you're better off forgetting the whole HTML, and think about converting it into some rich format, rendering text only without any formatting, or using an embedded browser.

Yes, it really is that complex, if you want to produce any reasonable output that applies features of HTML. Otherwise you'd be just displaying text.

Share this post


Link to post
Share on other sites
so what should i do? i dont want to half do the project ( if converting it to a rich text format is the cheap way out ), id like to make it a quality program. but if displaying html is really too complicated were can you point me to?

Share this post


Link to post
Share on other sites
i think i will end up using that, but i hate borrowing code, i like knowing i made every line and i know how it all works

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!