Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

295 Neutral

About EngineProgrammer

  • Rank
  1. 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
  2. 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?
  3. 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?
  4. 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.
  5. 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
  6. 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!
  7. 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!
  8. 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
  9. 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!
  10. 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
  11. 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
  12. 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
  13. EngineProgrammer

    Humans Must Answer (2D space shooter)

    Wooooaaaah that looks awesome!!
  14. 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
  15. 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
  • 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!