Archived

This topic is now archived and is closed to further replies.

Fredric

OpenGL Can you mix OpenGL with Direct X?

Recommended Posts

I was wondering if you could write pieces of a game in OpenGL, and others in Direct X. I''m involved in a project with another programmer- who is learning Direct X while I''m learning OpenGL... is this a problem? Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes and no. As long as you don''t try to mix oGL with Direct3D or DirectDraw it will work fine.

Share this post


Link to post
Share on other sites
Nope. It''s one or the other. When you''re dealing with matters of graphics, you can only really have one API working at a time. If its claimed by OpenGL, there is no room for graphical DirectX, and vice versa. The way they work is VERY different, and they do not mesh well - at all.

However, not all is lost; all non-graphical aspects of DirectX, such as DirectInput and DirectSound and DirectPlay and so on will work fine with OpenGL.

You''re just going to have to make a decision about what your goals are, what you will be able to do with what you know, as well as your desired platform. If its 2D only, I advice DirectDraw; if its 3D, I advise OpenGL. Either way, good luck, and pursue it to no limit. Naturally, it''s best to know both graphical DX AND OpenGL.

- Hai, watashi no chichi no kuruma ga oishii deshita!
...or, in other words, "Yes, my dad's car was deliscious!"

Share this post


Link to post
Share on other sites
Thank you for your advice... I''m not sure whether to learn DX or OpenGL, but could someone explain to me why OpenGL is not as good at 2d as DDraw? I heard that you need to learn VC++ for Direct X... that''s mainly why I chose OpenGL in the first place, because I hate VC++! So confusing with all those handles and stuff! Anyhow, can someone help me out?

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
maybe you could make 2 versions of what you''re working on. one for OGL and one for DX. it may be extra work, but hey, why not?

Share this post


Link to post
Share on other sites
One of the reasons OpenGL isn''t as effective for 2D as DirectDraw is that OpenGL, regardless of what you''re doing, is always running 3D (when you want 2D, you just specify an orthographic projection, but OpenGL still behaves as though you''re specifying things in 3 dimensions). I suppose OpenGL does have various commands for pushing raw pixel data to the framebuffer, but I''m a little uncertain as to just how accelerated that is compared to blitting in DirectDraw. OpenGL was designed more for rendering primitives and the like, while DirectDraw was specifically designed for slapping bitmaps around in video memory.

Share this post


Link to post
Share on other sites
direct x 2d graphics look way better than open gl 2d graphics. i''ve been working on both, got 2d working in both of them, and the ogl version of my graphic is dithered, somewhat. however, i''m deciding on using opengl because the codes much easier, and my game is mainly in 3d, so the player won''t have time to pay too much attn to dithered 2d. i''ve been trying to integrate 3d models with 2d graphics (i.e. cockpit in sim) for a while, and i finally got it goin in open gl. direct x, i can just not get direct 3d up and running (via loading x files). bottom line: opengl 3d is as good as ddraw, opengl 2d sucks crap like d3d, but at least i can get it up and running.

a2k

Share this post


Link to post
Share on other sites
Direct x is mainly for VC++. However in version 7 there is some stuff for visual basic as well, although, i believe they are little bit slower. If you are new the graphics programming / geometry environment, i woudl definately recommend starting with OPENGL. Direct X is difficult because of the cryptic way it works for beginners, or novices. Opengl hides alot of the hardcore stuff , but does allow one to access that if needed> and makes it a lot easier. John McCormack, Creator of Quake, went from direct x to OpenGl becuase of its ease of use. in the memo he wrote, he stated :" Remember if you are use an API to write a game you will be working with it alot. Therefore make sure its something you''re comfortble with" .

OpenGL is able to do things in a few lines of code that takes DX quite a bit more code to do. There is no speed difference between them that i have noticed. However, remember OpenGL is not the world''s most compatible API. It was designed on a SGI machine, and ported to use 3d Accelerated cards. For the few people who dont have 3d Accelerated cards in their machines, it may run very very slow. and different cards have different effects on OpenGL. Fir instance the older voodoo cards have to be run in 16 bit color mode, or its dog slow. i am not sure about the new ones.

Keep these things in mind when deciding. I had to make the same decision, and ultimately went with OpenGL.

CXI

The Code is a Living breathing entity, and will move in accordance with you, therefore, be one with the Tao of the Code..

Share this post


Link to post
Share on other sites
Basically, as long as you don''t mix the rendering aspects everything is OK.

i.e. You can use OpenGL with all DirectX components apart from DDraw & D3D.

On the other question, I am learning OpenGL, I don''t want to start an API war, but I do like it, and so far have found it quite easy to pick up. Although if you don''t like VC++, it might not be a good option.


-Mezz

Share this post


Link to post
Share on other sites
Alright, well it looks like I''ll be going with OpenGL purely because it''s easier. However, once I''m done with OpenGL and I have a decent grasp on 3d aspects as well as rendering and that kind of thing, I''ll move on to Direct X. Why move on and learn both? Because it''s just way better to have both.. that way I''ll be able (like a post mentioned above) to make all my games DX and OpenGL compatible. Thanks for all your help, I greatly appreciate it.

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
hmm ... why everyone thinks that opengl is better ? In my opinion, those Draw Primitive stuff in direct3d seems more organised to use than opengl. direct 3d graphics don''t really look that bad and multi-texturing is quite intuitive.

Share this post


Link to post
Share on other sites
Man cxi, Voodoo''s are dog slow in anything above 16bit color, so far(until the Voodoo4&5) every 3dfx card only runs in 16BIT COLOR!. Also, when John Carmak was writing that article, He was comparing OpenGL to DirectX5, when you had to use peice of crap Execute Buffers(or whatever,never used em, read bout em). I think that if he compared DirectX7/8 to OpenGl, it would be much closer, though his love for Linux would probaly keep him from saying that.

Share this post


Link to post
Share on other sites
I agree with esap1 i first had contact with DirectX 6, and the simplification from 6 to 7 alone was a large step (I cut away a big Part of the initialization, and all this Material and Lighting got much simpler).

Another Thing, why are you all talking about DirectX with VC++, you don''t need Visual C++, you can compile your DirectX Projects with nearly any C-Compiler. I am using Watcom and it works without Problems.

Lars

Share this post


Link to post
Share on other sites
Actually, Carmack was comparing OpenGL with DirectX3 -- not 5 (DirectX5 was the first version to introduce DrawPrimitive).

BTW, as for the quality differences between the API''s: there should be none as long as you know what your doing.

--TheGoop

Share this post


Link to post
Share on other sites
Actually, Carmack was comparing OpenGL to Direct3D of DirectX 3. Version 5 wasn''t so bad. It added drawprimitive, and thus programmers could avoid using execute buffers.

Direct3D has just gotten better and better. Everyone with common sense agrees that D3D v3 sucked..Some people just tolerated it at the time because the OpenGL driver situation on consumer cards was iffy. Luckily, id took a stand which I believe directly resulted in much better support for OpenGL from vendors and thus more support for OpenGL from other game developers.

In many ways, I think D3D 7 has some slight advantages over OpenGL when it comes to cutting edge features, but I am still using OpenGL for portability reasons. Its nice to run on platforms other than Windows....

Here''s hoping the OpenGL ARB and/or SIGs like Khronos are able to kickstart OpenGL back into the limelight with wider integration of cutting edge extentions, etc.

---

And, to repeat what others have said before me: the answer to your question is that you can mix all of DirectX (including DirectPlay, DInput, DSound, DMusic, etc) with OpenGL as long as you steer clear of D3D or DDraw. There have been rumors for quite some time that Microsoft had an OpenGL32.DLL implementation that could be mixed with DirectDraw, but they never released it because they want to push D3D over OpenGL for gaming. They may release it someday...There IS a PFD_SUPPORT_DIRECTDRAW pixel format flag defined in the newer Microsoft include files for wgl/GDI, but as far as I know it is not generally supported or documented.

Share this post


Link to post
Share on other sites

  • Announcements

  • Forum Statistics

    • Total Topics
      628400
    • Total Posts
      2982446
  • Similar Content

    • By test opty
      Hi all,
       
      I'm starting OpenGL using a tut on the Web. But at this point I would like to know the primitives needed for creating a window using OpenGL. So on Windows and using MS VS 2017, what is the simplest code required to render a window with the title of "First Rectangle", please?
       
       
    • By DejayHextrix
      Hi, New here. 
      I need some help. My fiance and I like to play this mobile game online that goes by real time. Her and I are always working but when we have free time we like to play this game. We don't always got time throughout the day to Queue Buildings, troops, Upgrades....etc.... 
      I was told to look into DLL Injection and OpenGL/DirectX Hooking. Is this true? Is this what I need to learn? 
      How do I read the Android files, or modify the files, or get the in-game tags/variables for the game I want? 
      Any assistance on this would be most appreciated. I been everywhere and seems no one knows or is to lazy to help me out. It would be nice to have assistance for once. I don't know what I need to learn. 
      So links of topics I need to learn within the comment section would be SOOOOO.....Helpful. Anything to just get me started. 
      Thanks, 
      Dejay Hextrix 
    • By mellinoe
      Hi all,
      First time poster here, although I've been reading posts here for quite a while. This place has been invaluable for learning graphics programming -- thanks for a great resource!
      Right now, I'm working on a graphics abstraction layer for .NET which supports D3D11, Vulkan, and OpenGL at the moment. I have implemented most of my planned features already, and things are working well. Some remaining features that I am planning are Compute Shaders, and some flavor of read-write shader resources. At the moment, my shaders can just get simple read-only access to a uniform (or constant) buffer, a texture, or a sampler. Unfortunately, I'm having a tough time grasping the distinctions between all of the different kinds of read-write resources that are available. In D3D alone, there seem to be 5 or 6 different kinds of resources with similar but different characteristics. On top of that, I get the impression that some of them are more or less "obsoleted" by the newer kinds, and don't have much of a place in modern code. There seem to be a few pivots:
      The data source/destination (buffer or texture) Read-write or read-only Structured or unstructured (?) Ordered vs unordered (?) These are just my observations based on a lot of MSDN and OpenGL doc reading. For my library, I'm not interested in exposing every possibility to the user -- just trying to find a good "middle-ground" that can be represented cleanly across API's which is good enough for common scenarios.
      Can anyone give a sort of "overview" of the different options, and perhaps compare/contrast the concepts between Direct3D, OpenGL, and Vulkan? I'd also be very interested in hearing how other folks have abstracted these concepts in their libraries.
    • By aejt
      I recently started getting into graphics programming (2nd try, first try was many years ago) and I'm working on a 3d rendering engine which I hope to be able to make a 3D game with sooner or later. I have plenty of C++ experience, but not a lot when it comes to graphics, and while it's definitely going much better this time, I'm having trouble figuring out how assets are usually handled by engines.
      I'm not having trouble with handling the GPU resources, but more so with how the resources should be defined and used in the system (materials, models, etc).
      This is my plan now, I've implemented most of it except for the XML parts and factories and those are the ones I'm not sure of at all:
      I have these classes:
      For GPU resources:
      Geometry: holds and manages everything needed to render a geometry: VAO, VBO, EBO. Texture: holds and manages a texture which is loaded into the GPU. Shader: holds and manages a shader which is loaded into the GPU. For assets relying on GPU resources:
      Material: holds a shader resource, multiple texture resources, as well as uniform settings. Mesh: holds a geometry and a material. Model: holds multiple meshes, possibly in a tree structure to more easily support skinning later on? For handling GPU resources:
      ResourceCache<T>: T can be any resource loaded into the GPU. It owns these resources and only hands out handles to them on request (currently string identifiers are used when requesting handles, but all resources are stored in a vector and each handle only contains resource's index in that vector) Resource<T>: The handles given out from ResourceCache. The handles are reference counted and to get the underlying resource you simply deference like with pointers (*handle).  
      And my plan is to define everything into these XML documents to abstract away files:
      Resources.xml for ref-counted GPU resources (geometry, shaders, textures) Resources are assigned names/ids and resource files, and possibly some attributes (what vertex attributes does this geometry have? what vertex attributes does this shader expect? what uniforms does this shader use? and so on) Are reference counted using ResourceCache<T> Assets.xml for assets using the GPU resources (materials, meshes, models) Assets are not reference counted, but they hold handles to ref-counted resources. References the resources defined in Resources.xml by names/ids. The XMLs are loaded into some structure in memory which is then used for loading the resources/assets using factory classes:
      Factory classes for resources:
      For example, a texture factory could contain the texture definitions from the XML containing data about textures in the game, as well as a cache containing all loaded textures. This means it has mappings from each name/id to a file and when asked to load a texture with a name/id, it can look up its path and use a "BinaryLoader" to either load the file and create the resource directly, or asynchronously load the file's data into a queue which then can be read from later to create the resources synchronously in the GL context. These factories only return handles.
      Factory classes for assets:
      Much like for resources, these classes contain the definitions for the assets they can load. For example, with the definition the MaterialFactory will know which shader, textures and possibly uniform a certain material has, and with the help of TextureFactory and ShaderFactory, it can retrieve handles to the resources it needs (Shader + Textures), setup itself from XML data (uniform values), and return a created instance of requested material. These factories return actual instances, not handles (but the instances contain handles).
       
       
      Is this a good or commonly used approach? Is this going to bite me in the ass later on? Are there other more preferable approaches? Is this outside of the scope of a 3d renderer and should be on the engine side? I'd love to receive and kind of advice or suggestions!
      Thanks!
    • By nedondev
      I 'm learning how to create game by using opengl with c/c++ coding, so here is my fist game. In video description also have game contain in Dropbox. May be I will make it better in future.
      Thanks.
  • Popular Now