Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by EngineProgrammer

  1. Hi everyone! For the last 2 years I have been learning all basics of C++ Programming. Also I've tried to start writing a game engine but that didn't really worked out very well. ( It was a terrible framework you just want to kill when you look at it ) But now, after watching allot of open source engines and after looking at engine structures I'm going to restart with creating one. But I have some questions though. 1) I want to have my final engine with DirectX implemented, is it smart to start with a full Win32 code and then later on starting to implement Dx? 2) How long ( make a guess ) will it take to write a little engine ( incl. Basic: graphics, sounds, network, shaders, 3D models, 3D animation ) for an un-experienced Programmer? I'm guessing around 4-5 months but I think I'll be the only one who thinks it is that easy? I already know the hardest thing won't be writing the code itself, but finding the best structure/framework. The structure of the engine I have in mind is this: WinMain func. -> Initializes Engine class + Game class Engine class -> Window class ( handles the window itself, fullscreen mode etc ) -> System class ( for input keyboard, mouse, controllers, etc ) -> Graphics class ( can load/create shaders, add effects ) -> Resources class ( to load images/sounds/videos ) -> Network class ( using RakNet ) I'm thinking to create a singleton design for each class above ( except the game class ).. Can't really think another way to make simple calls on them. I'll put some code down soon. Also, does someone have any tips for me I can use to create an efficient engine? Kind regards, Jonathan
  2. EngineProgrammer

    drawing in Win32

    Hey everyone, I'm just having some fun with reinventing many wheels. I just love to understand the low level programming! So here is what I want to do: basically I want to make my own pixel drawing system. I want to create a pixel class which stores a color. After I make an array of [640][480] which will be my "screen". When I gave all pixels a color I want to draw every pixel on the screen. How can I draw all pixels on the screen? SetPixel is a very slow method so I want to avoid that. Is it possible to directly connect my pixels to the screen pixels? How does the GDI communicate with the screen pixels? How can I communicate with the screen pixels without using the GDI or SetPixel? Is it even possible? Kind regards, Jonathan
  3. EngineProgrammer

    OpenGL 3D algorithm

    Hey everyone, has been a while I've programmed but I'm back. I know that re-writing existing code is useless. But I don't mind to re-write some code, I want to learn how it's done. I want to make a 3D polygon and draw it in C++, without using DirectX or OpenGL. I've been looking around after source codes or tutorials but haven't found a single tutorial that helps me. Very simple example of what I want to do: m_Polygon = new Polygon(vertex1, vertex2, vertex3, vertex4); // where the vertexes have a X,Y,Z m_Polygon->Draw(); So I want to draw the 3D polygon in my 2D screen. Can someone help me with this. Thank you and kind regards, Jonathan
  4. EngineProgrammer

    3D algorithm

    Thanks for the help, I've made a colorshader last year, but I didn't understood a single line of code what I was writing. Shaders are quite hard to understand for me. How does DirectX render his transformations? I just made a matrix class that can translate, scale and rotate. Tested it and it works. Don't mind how I use the methods. It's just a testing project. Matrix matTranslate, matRotate, matScale, matWorld; matTranslate.SetAsTranslate(-0.7f, -0.4f); matRotate.SetAsRotate(80.0); matScale.SetAsScale(0.5,0.5); matWorld = matRotate * matScale * matTranslate; Matrix::SetAsWorld(hDC, matWorld); Rectangle(hDC, -1, -1, 1, 1); This is what I use for my transformations: Matrix::Matrix(): eM11(0.0f), eM12(0.0f), eM13(0.0f), eM21(0.0f), eM22(0.0f), eM23(0.0f), eM31(0.0f), eM32(0.0f), eM33(0.0f) { } void Matrix::SetAsTranslate(float x, float y) { eM11 = 1.0f; eM12 = 0.0f; eM13 = 0.0f; eM21 = 0.0f; eM22 = 1.0f; eM23 = 0.0f; eM31 = x; eM32 = y; eM33 = 1.0f; } void Matrix::SetAsRotate(float radians) { eM11 = (float)cos(radians); eM12 = (float)sin(radians); eM13 = 0.0f; eM21 = (float)-sin(radians); eM22 = (float)cos(radians); eM23 = 0.0f; eM31 = 0.0f; eM32 = 0.0f; eM33 = 1.0f; } void Matrix::SetAsRotate(double degrees) { float radians = (float)(degrees/180 * M_PI); eM11 = (float)cos(radians); eM12 = (float)sin(radians); eM13 = 0.0f; eM21 = (float)-sin(radians); eM22 = (float)cos(radians); eM23 = 0.0f; eM31 = 0.0f; eM32 = 0.0f; eM33 = 1.0f; } void Matrix::SetAsScale(float x, float y) { eM11 = x; eM12 = 0.0f; eM13 = 0.0f; eM21 = 0.0f; eM22 = y; eM23 = 0.0f; eM31 = 0.0f; eM32 = 0.0f; eM33 = 1.0f; } Matrix operator*(const Matrix& ref1, const Matrix& ref2) { Matrix mat; mat.eM11 = ref1.eM11 * ref2.eM11 + ref1.eM12 * ref2.eM21 + ref1.eM13 * ref2.eM31; mat.eM12 = ref1.eM11 * ref2.eM12 + ref1.eM12 * ref2.eM22 + ref1.eM13 * ref2.eM32; mat.eM13 = ref1.eM11 * ref2.eM13 + ref1.eM12 * ref2.eM23 + ref1.eM13 * ref2.eM33; mat.eM21 = ref1.eM21 * ref2.eM11 + ref1.eM22 * ref2.eM21 + ref1.eM23 * ref2.eM31; mat.eM22 = ref1.eM21 * ref2.eM12 + ref1.eM22 * ref2.eM22 + ref1.eM23 * ref2.eM32; mat.eM23 = ref1.eM21 * ref2.eM13 + ref1.eM22 * ref2.eM23 + ref1.eM23 * ref2.eM33; mat.eM31 = ref1.eM31 * ref2.eM11 + ref1.eM32 * ref2.eM21 + ref1.eM33 * ref2.eM31; mat.eM32 = ref1.eM31 * ref2.eM12 + ref1.eM32 * ref2.eM22 + ref1.eM33 * ref2.eM32; mat.eM33 = ref1.eM31 * ref2.eM13 + ref1.eM32 * ref2.eM23 + ref1.eM33 * ref2.eM33; return mat; } void Matrix::SetAsWorld(HDC hDC, const Matrix& mat) { XFORM form; form.eM11 = mat.eM11; form.eM12 = mat.eM12; form.eM21 = mat.eM21; form.eM22 = mat.eM22; form.eDx = mat.eM31; form.eDy = mat.eM32; SetWorldTransform(hDC, &form); } The calculations I've written on paper first with help from a book. So I didn't copied anything from the internet. I'm getting the hang of matrices very fast with this book, next chapter is linear transformations! But indeed, I'm using GDI and it's getting pretty classic. But I really don't want to use a single external library. Because it's too "easy" then.. I'm not trying to be stubborn. Any suggestions how I avoid the classic functions? DirectX also must use a classic way or are they working very low level and code all their rendering themselves?
  5. EngineProgrammer

    3D algorithm

    I will gladly post my progress but it will take a while, today I realized I better learn matrices through 2D and when I understand everything I'll change to 3D. I'm making my own matrix class which will be supported with the function SetWorldTransform. This function works with XFORM but I'm not using this one. It's better to write my own calculations self so I can learn from it. When I got it all calculated I just put everything into an XFORM and transform the world. So when I understand the matrix and transform concept I go to 3D. Or is there a better way to transform my object(rectangle, bitmap, etc)? I know matrices needs to be used to transform such an object, but I mean, is there something else to transform my world with?
  6. EngineProgrammer


    When looking at 3D projections and transformations I was thinking on 3Dsmax, which has multiple viewports. So I've tried to get my own viewport with logical units -1 to 1. Now I wonder if I'm using a modern way of setting up a viewport. I have found these functions on msdn but I have no idea if these are still used nowadays. hDC = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &client); SetMapMode(hDC, MM_ANISOTROPIC); SetViewportOrgEx(hDC, client.right/2, client.bottom/2, 0); SetViewportExtEx(hDC, client.right, client.bottom, 0); SetWindowOrgEx(hDC, 0, 0 ,0); SetWindowExtEx(hDC, 2, 2, 0); Rectangle(hDC, 0, 0, 1, 1); EndPaint(hWnd, &ps); This code sets up my window to 2 logical units, from -1 to 1. So like DirectX uses his viewport. And I've changed the viewport extends so when I scale the window, the objects in the window are scaled also.
  7. EngineProgrammer

    4D Arrays?

    4D "can" be visualized in 3D: The fourth dimension can called whatever you like, some people say it's time, some people say it's space and some say it's an object in itself. Here is a nice link about how you project the 4D in 3D: http://steve.hollasc...s/chapter4.html Four-dimensional geometry: http://steve.hollasc...s/chapter2.html
  8. EngineProgrammer

    3D algorithm

    If you're not sure, you're definitely using a CPU You only "use" the GPU (at least the current generation) by programming little programs called shaders (in HLSL, or GLSL) which perform very specific tasks (e.g. transform vertices, or shade pixels). All the rest is done by the driver automatically. You don't actually write complete software on it. Everything that you code in C++ or C# or Java or whatever language, really, is done on your CPU. [/quote] Damn, I messed up my mind then. Thank you for clearing this out!
  9. EngineProgrammer

    3D algorithm

    Thanks everyone! Radikalizm, I'm not trying to make a commercial software renderer DirectX and OpenGL can't be beaten so I won't try to. It's all learning purpose. You say that I first need to work with the CPU, how do I do that? How can I choose which one I can use to get my project running? I know the difference between both tho, cpu only does 1 thing at the time while a gpu does multiple things at the same time. But no idea when I'm using a cpu or a gpu. DracoLacertae, thanks for the examples! So drawing lines isn't that hard to get in 3D Before I get on to it, I bought a math book which covers every mathematics what game programming concerns. So I hope to get a line or a 3D polygon on my screen today! uglybdavis, nicely done!
  10. EngineProgrammer

    3D algorithm

    I would like to write a small copy of DirectX. How do they handle the vertices and rendering of 3D models? How should it be handled for an optimal framework/engine? If my GPU can handle all the math, how can I render my 3D model with it? I still need to use some math from your first post or don't I? I'm looking up coordinate transformations and it's quite fun. And how about particles? Like when I have 1 million particles. How should I best handle them? Do I need to do all calculations and rendering on the GPU? Or are there better/faster ways? You are helping me already but I'm still a bit confused about how it all works with the gpu / cpu thing. I want to get an optimal render system for low poly models with materials, shaders, lightning, bouncings, etc. I know the pipeline for the graphics rendering but I can't go any further than the first step at the moment. For example I want to be able to load a whole environment like COD with all players, bullets, effects in it. Kind regards, Jonathan
  11. Your intensity of the bounced lights is on 100%? Way too much even for metal. Try to make it changeable. Have watched some video's and I must say, really good work! Keep it up!
  12. EngineProgrammer

    3D algorithm

    I'm looking up some information what GDI exactly is and this is a quote from wikipedia. Simple games that do not require fast graphics rendering use GDI. However, GDI is relatively hard to use for advanced animation, and lacks a notion for synchronizing with individual video frames in the video card, lacks hardware rasterization for 3D, etc. Modern games usually use DirectX or OpenGL instead, which let programmers exploit the features of modern hardware.[/quote] What makes DirectX a fast graphics renderer? How you decide the speed of rendering? I just want to get low-level what programming concerns. I really want to get the knowledge into my head how it's done. GDI only limited to 2D, how do I get the 3D in my program then? I'm assuming I need to calculate every pixel and draw them manually, please correct me if I'm wrong. I want to achieve real-time rendering. Dragging a 3D model into your window and be able to translate, scale and rotate in your project. But that is not for now, first the baby steps. But I can't do this alone sadly enough. Need some help from people who have experience in this because I can't find almost anything that helps me. maybe I'm not looking in the right place. Kind regards, Jonathan
  13. EngineProgrammer

    3D algorithm

    A billion percent thank you! In Win32 there are some standard functions for example: SetWorldTransform, SetGrapicsMode, etc. and structs like XFORM. Should I make any use of those functions and structs or should I rather make my own ones? Kind regards, Jonathan
  14. EngineProgrammer

    Humans Must Answer (2D space shooter)

    Wooooaaaah that looks awesome!!
  15. EngineProgrammer

    Allocation of memory

    Hi everyone! I'm digging into open source engines to understand their memory management but the more I look in it, the more confused I get. For example Unigine ( it's a nice engine ) uses different headers for all kind of allocations. struct FixedChunk; struct FixedAllocator; struct HeapChunk; struct HeapPool; struct HeapAllocator; struct SystemAllocator; struct Allocator; struct Memory; Why are they using so many structs(all in different headers)? An allocator is an allocator so why don't they just write 1 struct: Allocator. and use it for everything. I don't get it why they uses so many structs. So if someone could explain this for me, thank you! ~EngineProgrammer
  16. EngineProgrammer

    starting game engine

    Why do you drag Win32 into a discussion of graphics APIs? Win32 is not the C++ standard library for windows, Win32 is the basic Windows API which exposes Windows core functionality to developers. The latest OpenGL release also made it basically on par with DirectX again, so there's no issue there. I also wouldn't expect DirectX to ever go cross-platform (at least not in a way condoned by microsoft), but that doesn't mean an engine shouldn't support DirectX even if that engine will be cross-platform. There's no such thing as bug-free or error-free software [/quote] Sorry for my misunderstanding about Win32. I meant the header file <windows.h> with Win32. And that can also be used to write a game engine with, so I dragged it into this discussion. About OpenGL, my programming lecturer said 3 weeks ago that OpenGL is running behind DirectX and he is looking updates about programming stuff every day so I assume he is right. Though I should have checked first on their sites before posting it here. My apologize. But still, I've programmed with OpenGL last year for a month, I think it was child coding to be honest. But in a year allot can happen of course. There is no such thing as a bug-free and error-free game engine? Yes there is... With enough checking code, and a good team of programmers. But yes, it all depends on the client who uses your engine. If he can't work with it properly failing stuff will happen indeed. But that's not the fault of the engine but of the client. Still, a good engine would be prepared for moments like that and be sure to have enough error checking. But my experience in programming isn't that much, I just try to help others with the knowledge I have at the moment. If you can give me an example of an unfix-able piece that you can't keep error-free, please tell because I want to know. ~EngineProgrammer
  17. EngineProgrammer

    starting game engine

    Write games, not engines: http://scientificnin...mes-not-engines If you, after reading the article, still want to write a game engine. Continue reading. What can the game engine you have in mind do? Is it capable of cross-platforming(Windows,Mac,Xbox,Ps3,etc)? Do you want to work with Win32, DirectX, OpenGL, etc? Is it a 2D or a 3D engine? Will it be commercial, open source, private? cross-platforming: To get the cross platforming done you need to check how a window is created on all consoles, how the type id's are called, etc. Here are some defines that will help you: #ifdef _WIN32 || _WIN64 #elif __APPLE__ #if TARGET_OS_IPHONE #elif TARGET_OS_MAC #endif #elif __linux #elif __unix #elif __posix #else // unknown platform #endif Win32, DIrectX, OpenGL: Win32 is the standard library of C++. It's only supporting windows. DirectX is the best choice, even it's not supporting cross-platforming yet. With the possibilities of this library you can create any application you have in mind! OpenGL and DirectX were racing neck on neck a few years ago but they update of DirectX made OpenGL run behind. But it's an easy language to use. Commercial, open source, private: If you want to make a commercial engine like CryEngine, Unity... No chance on your own so forget this. If you want to make it open source, be sure to really have everything bug-free, error-free. You don't want the clients to complain about your engine, even it's open source. If you want to make it private, I think you are better of with a simple framework instead of an engine. ~EngineProgrammer EDIT: I'm regretting this post immediately.
  18. EngineProgrammer

    ElapsedTime Movement?

    Working with time instead of frames will give you a more synchronized game. it's also a must when you plan to go online. Why? Assume you have 50 processes running on your computer and your enemy has 25. Your enemies game-cycle will be called twice as fast. So he will have the advantage. You add the time to any calculation for movement, shooting, camera, etc. m_Velocity = m_Velocity * deltaTime; m_Position = m_Velocity; // you don't need to put a delta time here because it's using the velocity who has a delta time calculated in it. // This is the camera you want to move: m_Camera.moveLeft( int delta ); // Inside the method of the camera: m_CameraPosition.x = m_CameraPosition * deltaTime; // This means you need a method for the camera: void Tick( int deltaTime ) and store the deltaTime !! Edit: If you are not sure to put a delta time with a line of code you need to think on an online game. Will the code without deltaTime have a possibility to lose synchronization? If yes, add the deltaTime. I hope this was helpful. ~EngineProgrammer
  19. EngineProgrammer

    Episode 1 of Game Programming, a Video Series

    I've never programmed in java but I don't think that will be the point with my opinion. It's not smart to pick a 'random' resolution. In C++ the function 'ChangeDisplayMode" returns false at random resolutions that doesn't exist. When the gamer goes to options he might want to change the resolution. So give him known ones(640*480, 1024*768, 1280*720, etc) link: http://en.wikipedia....play_resolution (scroll down a bit) I mostly use 640*480 to start my projects with. When I create a game I'm trying to get around 1360*768. And then adjust my resolution to a "fullscreen" window for the gamer. And 3-5 minutes each video? You have written 5 lines of code now so maybe go a little bit faster, or make the video much longer? ~EngineProgrammer
  20. Ah this is a good place where I can ask a question about android as well. (this question continuous on the OP's question) Android games give you profits. But how much? I can't find everywhere how much % you get from each buyer. Assume, I've written an android game that costs 1€ on the android store. My game is decent so I have 10 000 people buying my game. How much profits will I have? Would be nice if someone could answer on this. ~EngineProgrammer
  21. EngineProgrammer

    How Do You Plan?

    Thank you for the fast response Alvaro. You are programming for 30 years now, that's nice! I have 2 years of experience now hehe. It would be awesome if you could help me out. You have more experience and you could help me allot now. I know I'm not the OP but, I want to rewrite this game for another school project: How would you handle it? Please play the first level and explore how you would create a game like that. I owe you one. ( moderators this is not offtopic. I'm asking a plan to Alvaro. ) ~EngineProgrammer
  22. EngineProgrammer

    How Do You Plan?

    Superman3275, you can see 3 different ways now to get started. This means everyone has his special way of programming, and you need to find your way. Seek out what's the best for you. Downloading open source games / engines, exploring them has been a great help for me. So I suggest you to do the same. Look how other people have done it. How they structure their classes, how they have written their lines of code, etc. It's very hard to tell you a structure / design. You need to explore / see it for your own. Telastyn, I also try to work everything out in my head. But when a week has passed it's hard to remember where I was. That's why I'm writing/drawing it all. So if I look at my paper a year later I can still remember what I've done. Alvaro, I used to work the same way as yours. But I disappreciate it.. Coding immediately caused me allot of messy code, which made me create new projects over and over again. And after that I got 10 files with sort of the same code and I need to look in all of them first to know what I was doing. My first year of programming I made Dragonball Z: supersonic warriors. I've count the number of versions I have: 17. With only 1 working completely. But the examination went pretty good with that file . After the examination in school I asked the lecturer how he started when he had a game in mind. He said: "I can't tell you that. Every programmer has his own way of thinking so I cannot tell you how to program like me. But I can give you a hint: Storage your information so you can return at it any time.". And so I came with a piece of paper and a pencil. ~EngineProgrammer
  23. EngineProgrammer

    How Do You Plan?

    Assume I want to create a game for example 'MotherLoad': http://www.miniclip..../motherload/en/ I write down everything I need. In this case: - Tileable sprites for the dirt, copper, tin, etc - sprite of a vehicle - Bitmaps for buildings - Bitmaps for menu's when your vehicle comes closes to a building - Sounds - Day/Night -> Bitmap of a sun that moves in a circle. Ok I got kinda the basics. After this I draw on a piece of paper what classes I'll need and link them. class main; // entry point of the application class Window; class System; class Graphics; // will be created in the main.cpp class Bitmap; class Sound; class Text; // stores handles to the images, fonts, etc class Vehicle; // this will store an object of Bitmap for your vehicle. class GameState; // will keep a state ( static int m_GameState = STATE_IN_GAME; // or STATE_MENU_MODE; such things. class Game; // this will create all game objects, sounds, etc. Also checks collisions. class Level; // contains information how the level looks like class LevelProp; // props like dirt, copper, etc. Can be a virtual class and support sub-classes. Linking I do with drawing arrows from class to class. Still don't have any code. Now I think "What possible methods can the classes contain?" I give 1 example: class Bitmap { public: Bitmap(string path); // Loads an image from a file ~Bitmap(); Bitmap* GetBitmap(); void SetAnimationRect(RECT bounds); RECT GetAnimationRect(); void StartAnimation(int from = 0); void StopAnimation(); void PauseAnimation(); void SetAnimationSpeed(int speed); void IncreaseAnimationSpeed(int speedDelta); void DecreaseAnimationSpeed(int speedDelta); void Render(int posX, int posY); // The position can also be stored and called with a method: SetPosition(int posX, posY); private: HBITMAP m_hBitmap; RECT m_Bounds; int m_AnimationCounter, m_AnimationSpeed; }; Of course this class sucks. It was just an example so don't copy that one. And in case you are wondering, why not painting(Photoshop) and typing instead of drawing(on paper) and writing? Answer: You only need to have a basic idea for your whole game. So don't waste time with with PS or Notebook.. Drawing & Writing goes allot faster. ~EngineProgrammer
  24. EngineProgrammer

    Advice for Graduation Project game

    A genre that has 2 teams, small environment and no levels looks like an RTS for me. - Creates barracks that automatic spawn creatures to the other base ( the stronger the creature, the more time it takes to spawn ). - The creatures follow the shortest path. - Put some environment in your map so you, as player, need to build your barracks on a good spot so your creatures will reach the other side faster. - Get some economics in it so you need to balance out your base with barracks <-> income. Smart building means more chance to win! The fact you are asking what language best fits means you know basics of different languages or just don't know a single programming language. What language you should take depends on yourself. I like programming in C++ because it has no limits. Java is written in C++, don't uses a stack, so only heap for every object. I don't know anything about other languages. ~EngineProgrammer
  25. EngineProgrammer

    [SFML] Breakout Help :(

    Do you know why this happens? Because you are thinking I'm going to handle over all the code.. Block* pBlocks, you can clearly see a ' * ' in my code. This is a dereference. Or in other words, this is a pointer. It stores an address of an object it's location. http://www.cplusplus...orial/pointers/ I found 2 errors, I can't find any error at the moment. Try using break points. Put some breakpoints in your main functions and go over the methods one by one. When you get the break error after jumping over a method, it means you are doing some strange stuff inside that method. ~EngineProgrammer
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!