Followers 0

# OpenGL Time to write rendering engine from scratch

## 25 posts in this topic

I have a new assignment where my boss wants me to write the complete source code for a simple rendering engine that can load and render standard file formats like OBJ (at least one format) but it needs to be written from scratch.

It's been a while since I wrote one from the ground up (15 years or so), in fact it seems hardly anything in graphics is written from scratch these days. The pay is great so I don't have a problem doing it, but am at a loss for an estimate and wanted to get a consensus from those with experience.

How long would you estimate it would take to write an OpenGL program that can load say OBJ files and render models without fancy shaders?

Also, what file format is most straightforward to load and render?

Thanks in advance. Edited by bigneil
-2

##### Share on other sites
I agree, it will take time to learn all the stuff necessary to write a serious and correct viewer that works according to the endless amount of specifications you'll need to know.
But, feel free to ask anything in here if you run into any problems..
I would start with GLFW for the openGL window, and go from there, as it is multiplatform (win, linux, mac), and handles the window, inputs and swapping (including vsync) for you.
Unless you also have to do that by hand
1

##### Share on other sites
I'd be extremely careful as the goal is not clearly defined. I use AssImp for the loading yet I'd find hard to take less than 5 working days. But perhaps my definition of "without fancy shaders" is different from yours. Edited by Krohm
1

##### Share on other sites
As L. Spiro say, it´s personal. And if you dont have any experiance in coding with either Dx or GL it will probably take a while to figure out how things work.

Use Assimp, it´s easy, it´s good, it´s fast and honestly saved me alot of work and time. it allso supports a ton of formats.
estimate to one month. thats a good start amount, you have room to develop, and to fix bugs, and to correct or rewrite stuff if you are forced to.
1

##### Share on other sites
Generally unsure of myself? 15 years rusty?

And it would take Spiro 2 days and it would take me 2 months?

Who is Spiro trying to impress? A group of anonymous computer nerds?

FYI I've programmed OpenGL every day for the past 15 years, and patented my own rendering system in the process. My own product already served as a rapid prototyping tool and I solved their actual problem in my first few hours.

It just happens they want the source code (a license of which I sell for $250K). I'm just pointing out that people don't usually write rendering engines from scratch anymore (the one I wrote in 1997 is still working fine thank you), and if someone tells you they can write a rendering engine from scratch in 2 days they are lying. -24 #### Share this post ##### Link to post ##### Share on other sites [quote name='bigneil' timestamp='1351866936' post='4996539'] it would take Spiro 2 days and it would take me 2 months? [/quote] I don’t know. How long [i]would[/i] it take you? That is what we are trying to determine. [quote name='bigneil' timestamp='1351866936' post='4996539'] I wwebsite as on the internet [/quote] You obviously know more about yourself than any of us, but put that aside for a moment and read your post and then my reply. If you can’t handle the answer, don’t ask the question. If you do ask the question, you should provide all of the necessary information. When estimating how long it would take you to complete a task in OpenGL, it would be a good idea to mention any experience you have in OpenGL up-front. It’s generally assumed that if you come here to ask a question, you [i]want[/i] to find people who are more experienced than yourself so you can get help from them. If this wasn’t your thinking, then what was? Did you hope to find a bunch of people saying, “It would take me 3 weeks,” so that you could say to yourself, “What a loser, I am so much better than him or her”? It sounds as though you already know the answer, so good luck with your project. L. Spiro Edited by L. Spiro 2 #### Share this post ##### Link to post ##### Share on other sites I'm not sure how "It's been a while since I wrote (a rendering engine) from the ground up" was interpreted as "it's been a while since I programmed graphics (in any capacity)", or who wouldn't take "you sound rusty and unsure of yourself" as less than insulting, but I appreciate the advice. Thanks everyone. -6 #### Share this post ##### Link to post ##### Share on other sites Because I was just tasked with writing a rendering engine from scratch I wanted to get a consensus on what people who have written rendering engines more recently thought. In the end I decided to whittle down my own code since it works perfectly (and recompiles in 6 seconds to all you A-holes who write programs that take 2 hours to compile (see Electronic Arts). But man, I forgot what a bunch of d*uche b*gs are on this site. Members here (what an appropriate term) pride themselves on their blog rating here and you'll never find a site more likely to neg you for one post that doesn't stroke their ego. Try saying you don't like Goto for example - they'll neg you all the way to negative 1000. But try asking an advanced question about parametric surfaces and you'll get crickets. Most of the people here with high ratings don't actually have computer science jobs (or formal experience) which is why they have so much time (and why they are so bitter). Worse, they provide best-case scenario estimates - an enormous disservice to themselves, coworkers and the industry. A wise man once said "The more I know the less I understand" - and members here understand everything. If you've worked in the industry you know you'll never find smarter people who are willing to do exactly what they are told (by their boss, the FDA and the TSA) - Developers in a crisis will (according to Meyer Briggs) "go with what the group does". Oh well, I'd rather be making$90 an hour programming OpenGL for my own business than to have a high db rating, but if you make less be sure to neg me.

Anytime you do something worthwhile you're going to offend someone.
-11

##### Share on other sites
Whoa whoa whoa
[quote name='L. Spiro' timestamp='1351813476' post='4996360']
[b]If[/b]...
[b]If[/b]...
[b]If[/b]...
[b]If[/b] you are generally unsure of yourself (and it [b]sounds[/b] as though you are), I would say you should give yourself no less than a month, maybe up to 2.

[b]Because of the wide range of skills and experiences, I am not sure how helpful any of our answers would be[/b].
[/quote]
1) I don't believe LS was tearing you down or diminishing your character. And I'm pretty sure the way you reacted to LS and similar answers set this thread downhill. Clarification on your part probably would have went a long way.
2) [i]Plenty[/i] of people here don't like goto (unless absolutely positively necessary, which it usually isn't).
3) I don't believe you can get a negative rating - perhaps I am wrong about that one though.

Please try to reconsider your perspective on all this - it's not what you think it is.
1

##### Share on other sites
[quote name='achild' timestamp='1352238672' post='4998210']
3) I don't believe you can get a negative rating - perhaps I am wrong about that one though.
[/quote]
No you actually can. Lowest I've seen so far is -350 or so. Not that ratings matter that much anyway. I've come to the conclusion that the thread creator is a troll, and you know what they say about trolls. Edited by Bacterius
1

##### Share on other sites
I can only second L Spiro here.

You ask a question, which it must be assumed was well-intentioned and in good faith.
You get some answers that also read as well-intentioned and in good faith.

From there it seems that you didn't like the answers you got and the resulting conflagration borders on thermonuclear war. Not good.

I'm not saying that you're obliged to like the answers, but there is such a thing as basic manners - people have freely and willingly given of their own time here.

One can only answer a question based on the information contained in that question; if the answers recieved are believed to be inadequate or otherwise lacking then there is obviously a communication deficit of some kind to be addressed. Strikes me that it would have been far more productive to address that deficit than to engage in flaming out.
2

##### Share on other sites
[img]http://public.gamedev.net//public/style_emoticons/default/huh.png[/img]
1

##### Share on other sites
[quote name='Caffeware' timestamp='1352320584' post='4998571']
[img]http://public.gamedev.net//public/style_emoticons/default/huh.png[/img]
[/quote]

Excellent Caffeware - I downloaded it and it ran instantly - this is how all software should be written!
0

##### Share on other sites
Yes! I almost achieved my negative rating!

This shows what a farce it is.

When you're a 20 year veteran of the 3D graphics industry and already worked on Madden Football, Far Cry, Doom, Descent and other games, the rating system doesn't disprove you, you disprove the rating system. Edited by bigneil
-3

##### Share on other sites
"Strikes me that it would have been far more productive to address that deficit than to engage in flaming out."

It's the forum that flames out. I was once a member for years and had a rating of 400 or so, then when I said I didn't like Goto my rating went all the way to -400 - OVER ONE THREAD. Edited by bigneil
-1

##### Share on other sites
I really do not get why you're reacting this agressively to people's reactions, there was no need for any agression, nobody tried to flame you or attack you in any way whatsoever. You got some valid answers to your question, there may have been some misunderstandings and miscommunications but there's no reason to suddenly react the way you did.
You claim to be an industry veteran of 20 years, if that's true you might want to think about acting somewhat more like an adult then in this situation instead of starting to flame and trying to profile yourself as superior to everyone else because of the projects you have done or (of all things) the compile times you get.
0

##### Share on other sites
[quote name='bigneil' timestamp='1352410597' post='4999033']
When you're a 20 year veteran of the 3D graphics industry and already worked on Madden Football, Far Cry, Doom, Descent and other games, the rating system doesn't disprove you, you disprove the rating system.
[/quote]
I am really getting tired of you and your inferiority complex. You asked a question hoping to find people with more experience than you on a given subject.
I answered because that subject is exactly down my ally. When I go to work, I make a game engine (unless I am going to my other job that is). When I get home, I make a game engine.

[i]Game[/i] engines aren’t [i]rendering[/i] engines, but it just so happens that my current task at work is the rendering part, and on my own engine I am currently working on the rendering part.
[quote name='bigneil' timestamp='1352410597' post='4999033']
Because I was just tasked with writing a rendering engine from scratch I wanted to get a consensus on what people who have written rendering engines more recently thought.
[/quote]
And I am exactly the person you wanted to answer this question. [i]I am writing a damned book about rendering/loading graphics files/etc. as we speak.[/i]

Suddenly you are offended that someone is better than you at this task, yet why wouldn’t I be? It’s what I do all day every day—whatever you do all day every day probably makes you better at that than I am.
So your inferiority complex kicks in and you have to make up for it in other ways—salary, past projects, status, etc.
I have been extremely kind up to this point, having passed up numerous chances to put you in your place, but here is the deal: [i]You don’t impress me.[/i]
There are people here who do, but you will never be one of them. They impress due to their skills and professionalism. Your salary, past projects, and status as a business owner are [b]not[/b] impressive. Once again I am leaving it at that instead of taking you down a few notches, although you do deserve to be put in your place. I can at least say that based on your salary, past projects, and status as a business owner, you have no place to brag, so listing these things as an attempt to make up for your shortcomings in skill only make you out as someone that much more desperate to have lived a better life. Just stop trying to make yourself more than you are, because I can promise you that no respectable person I have ever met has made the kinds of posts you have made, trying to prove themselves to some other random person online. Each time you do so just makes you much less of an impressive person and much more like the kind of person who wishes he or she was more than he or she actually is.

[i]You[/i] are what’s bringing this site’s quality down.
You only come here to flame and brag about yourself, and this topic serves absolutely no purpose to anyone who stumbles upon it in the future. It starts with a very vague question and quickly becomes a 1-man flame-war. Then you make it clear that your goal is only to get a negative reputation (I still haven’t touched your reputation, by the way).
I am not a moderator here, but it is [i]obvious[/i] that if you don’t take a contributory tone starting from your very next post, [i]you will be banned[/i].

L. Spiro Edited by L. Spiro
2

##### Share on other sites
At this point I need to chime in about reputation.

Reputation is NOT there to stroke anyone's ego. Any member of this site with sufficiently high reputation is most definitely NOT getting an internet hard-on (pardon the choice of phrase, couldn't think of a better way of putting it) from it, because they understand the purpose of the system.

The reason for reputation is to act as a service to the community. People can identify the good answers to questions, the ones that are most likely to be the right answer or to at least shove them in the right direction.

A good, fully functioning member will [i]welcome[/i] negative reputation as much as they welcome positive reputation, because they will see negative reputation as something that puts their own previously held assumptions to the test. Because they understand that no matter how much one is experienced, no matter how much one knows, learning is a continuous process.
1

##### Share on other sites
As a slight topic digression, what is the state / benefits to your engine Spiro? I'm always interested in hearing what goes on
As a member who frequents another forum devoted to a specific software, I hope I can provide something in the nature of an opinion.
I myself do not work in rendering engines. I have little experience, yet enough to understand that it can become a quickly all-encompassing task.
The issue here is that you failed to address a generic opening. This is the cause of the troubles. If you have a genuine question, ask it again, and perhaps apologise if you feel that you have overreacted. If you feel that this is unfair, then lest this topic be useful to others it should be left. Best of luck to all.
0

## Create an account

Register a new account

Followers 0

• ### Similar Content

• So it's been a while since I took a break from my whole creating a planet in DX11. Last time around I got stuck on fixing a nice LOD.
A week back or so I got help to find this:
https://github.com/sp4cerat/Planet-LOD
In general this is what I'm trying to recreate in DX11, he that made that planet LOD uses OpenGL but that is a minor issue and something I can solve. But I have a question regarding the code
He gets the position using this row
vec4d pos = b.var.vec4d["position"]; Which is then used further down when he sends the variable "center" into the drawing function:
if (pos.len() < 1) pos.norm(); world::draw(vec3d(pos.x, pos.y, pos.z));
Inside the draw function this happens:
draw_recursive(p3[0], p3[1], p3[2], center); Basically the 3 vertices of the triangle and the center of details that he sent as a parameter earlier: vec3d(pos.x, pos.y, pos.z)
Now onto my real question, he does vec3d edge_center[3] = { (p1 + p2) / 2, (p2 + p3) / 2, (p3 + p1) / 2 }; to get the edge center of each edge, nothing weird there.
But this is used later on with:
vec3d d = center + edge_center[i]; edge_test[i] = d.len() > ratio_size; edge_test is then used to evaluate if there should be a triangle drawn or if it should be split up into 3 new triangles instead. Why is it working for him? shouldn't it be like center - edge_center or something like that? Why adding them togheter? I asume here that the center is the center of details for the LOD. the position of the camera if stood on the ground of the planet and not up int he air like it is now.

Full code can be seen here:
https://github.com/sp4cerat/Planet-LOD/blob/master/src.simple/Main.cpp
If anyone would like to take a look and try to help me understand this code I would love this person. I'm running out of ideas on how to solve this in my own head, most likely twisted it one time to many up in my head
Toastmastern

• I googled around but are unable to find source code or details of implementation.
What keywords should I search for this topic?
Things I would like to know:
A. How to ensure that partially covered pixels are rasterized?
Apparently by expanding each triangle by 1 pixel or so, rasterization problem is almost solved.
But it will result in an unindexable triangle list without tons of overlaps. Will it incur a large performance penalty?
How to ensure proper synchronizations in GLSL?
GLSL seems to only allow int32 atomics on image.
C. Is there some simple ways to estimate coverage on-the-fly?
In case I am to draw 2D shapes onto an exisitng target:
1. A multi-pass whatever-buffer seems overkill.
2. Multisampling could cost a lot memory though all I need is better coverage.
Besides, I have to blit twice, if draw target is not multisampled.

• By mapra99
Hello

I am working on a recent project and I have been learning how to code in C# using OpenGL libraries for some graphics. I have achieved some quite interesting things using TAO Framework writing in Console Applications, creating a GLUT Window. But my problem now is that I need to incorporate the Graphics in a Windows Form so I can relate the objects that I render with some .NET Controls.

To deal with this problem, I have seen in some forums that it's better to use OpenTK instead of TAO Framework, so I can use the glControl that OpenTK libraries offer. However, I haven't found complete articles, tutorials or source codes that help using the glControl or that may insert me into de OpenTK functions. Would somebody please share in this forum some links or files where I can find good documentation about this topic? Or may I use another library different of OpenTK?

Thanks!

• Hello, I have been working on SH Irradiance map rendering, and I have been using a GLSL pixel shader to render SH irradiance to 2D irradiance maps for my static objects. I already have it working with 9 3D textures so far for the first 9 SH functions.
In my GLSL shader, I have to send in 9 SH Coefficient 3D Texures that use RGBA8 as a pixel format. RGB being used for the coefficients for red, green, and blue, and the A for checking if the voxel is in use (for the 3D texture solidification shader to prevent bleeding).
My problem is, I want to knock this number of textures down to something like 4 or 5. Getting even lower would be a godsend. This is because I eventually plan on adding more SH Coefficient 3D Textures for other parts of the game map (such as inside rooms, as opposed to the outside), to circumvent irradiance probe bleeding between rooms separated by walls. I don't want to reach the 32 texture limit too soon. Also, I figure that it would be a LOT faster.
Is there a way I could, say, store 2 sets of SH Coefficients for 2 SH functions inside a texture with RGBA16 pixels? If so, how would I extract them from inside GLSL? Let me know if you have any suggestions ^^.
• By KarimIO
EDIT: I thought this was restricted to Attribute-Created GL contexts, but it isn't, so I rewrote the post.
Hey guys, whenever I call SwapBuffers(hDC), I get a crash, and I get a "Too many posts were made to a semaphore." from Windows as I call SwapBuffers. What could be the cause of this?
Update: No crash occurs if I don't draw, just clear and swap.
static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 24, // 24Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC = GetDC(windowHandle))) return false; unsigned int PixelFormat; if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) return false; if (!SetPixelFormat(hDC, PixelFormat, &pfd)) return false; hRC = wglCreateContext(hDC); if (!hRC) { std::cout << "wglCreateContext Failed!\n"; return false; } if (wglMakeCurrent(hDC, hRC) == NULL) { std::cout << "Make Context Current Second Failed!\n"; return false; } ... // OGL Buffer Initialization glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glUseProgram(myprogram); glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void *)indexStart); SwapBuffers(GetDC(window_handle));

• 19
• 12
• 23
• 11
• 28