Archived

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

i8degrees

OpenGL OpenGL and 2D

Recommended Posts

i8degrees    122
Is creating a 2D engine based on OpenGL a good idea? I know it can do pixels, blits, and all that. Is it safe to assume that most people will have a 3D accelerated graphics card that can run OpenGL apps reasonably well? I know a lot of older cards don''t support GL that well... it would limit a lot of older computers out of the arena, I guess it might just be a design decision to have to be made by myself. "I am governed by none other than the Laws of the Universe."

Share this post


Link to post
Share on other sites
llyod    122

It is an excellent idea. And about the other question, well -- I''m not too sure (hi bunny!) but in any case OpenGL will revert back to software mode if it''s not hardware accelerated. Definitely a good idea in any case.


2D!Now

Share this post


Link to post
Share on other sites
i8degrees    122
Heh, well software mode is EXTREMELY slow, even on my computer (Athlon 850, 384MB ram), so I definitely wouldn''t want anyone having to play my game on an unaccelerated card. The game that I tried was Nehe''s Zelda, which is very basic. It was slow as hell until I updated my drivers for my Geforce2 MX 400 for OpenGL support (on WinXP). Oh, and on a unrelated note, why is it that when OpenGL apps go fullscreen, and then turn back, it messes up the placement of my other open windows? It doesn''t do it on SDL/DirectX apps.

I think the 2D engine running on OpenGL would be a cool idea though, especially with GLUT added. I''d prefer it over SDL.

"I am governed by none other than the Laws of the Universe."

Share this post


Link to post
Share on other sites
zedzeek    528
>>Heh, well software mode is EXTREMELY slow, even on my computer (Athlon 850, 384MB ram), so I definitely wouldn''t want anyone having to play my game on an unaccelerated card. <<

true, software is horrible but remember a in the US the last 3 number one 3d games have all used only opengl, its safe to assume quite a few ppl have a 3d accelerator

>>The game that I tried was Nehe''s Zelda, which is very basic. It was slow as hell until I updated my drivers for my Geforce2 MX 400 for OpenGL support (on WinXP).<<

winXP does not support opengl out of the box, (easily fixed by downloading drivers from the manufacturer). surely such blatent abuse by ms is against the law (does it matter)

>>Oh, and on a unrelated note, why is it that when OpenGL apps go fullscreen, and then turn back, it messes up the placement of my other open windows? It doesn''t do it on SDL/DirectX apps.<<

bad window creation code, personally this is why i plan to use SDL in creating all my opengl windows (its tried + tested + bugfree)

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
i8degrees    122
Hmm, I''ve been looking at OpenGL more ... how would I be able to plot graphics primitives using the standard coordinates system that I have been use to? I notice that OpenGL uses floats, but I want to maintain the same old pixel coordinate system that has been in use... If I want a pixel at (50, 50) on a OpenGL surface, how could I do this? You aren''t dealing with resolution anymore?

"I am governed by none other than the Laws of the Universe."

Share this post


Link to post
Share on other sites
i8degrees    122
What do you mean, not in its element? Is it going to be slow doing indiviual pixels (GL_POINTS)?

[EDIT 1] Oh, thanks llyod, I'm sure that information will come in use.

[EDIT 2] If I do the 2D engine in OpenGL, it has to be efficient at not only sprite blitting, but graphics primitives as well. If going to SDL or DirectDraw means faster, I'll switch to that.

[edited by - i8degrees on May 6, 2002 10:12:12 PM]

Share this post


Link to post
Share on other sites
benjamin bunny    838
If you're talking about using GL_POINTS to fill large areas of pixels, it's a very bad idea, in fact it's a bad idea to be plotting any serious number of individual pixels in any graphics API. If you _really_ want to play with pixels, learn ASM. Plotting pixels is not something high level graphics APIs are designed for.

quote:

[EDIT 2] If I do the 2D engine in OpenGL, it has to be efficient at not only sprite blitting, but graphics primitives as well. If going to SDL or DirectDraw means faster, I'll switch to that.



OpenGL is a very capable API for 2D, but you have to use textures and quads (as someone said already). You can think of textured quads as sprites.
____________________________________________________________
www.elf-stone.com

[edited by - benjamin bunny on May 6, 2002 11:03:44 PM]

Share this post


Link to post
Share on other sites

  • Similar Content

    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
    • By C0dR
      I would like to introduce the first version of my physically based camera rendering library, written in C++, called PhysiCam.
      Physicam is an open source OpenGL C++ library, which provides physically based camera rendering and parameters. It is based on OpenGL and designed to be used as either static library or dynamic library and can be integrated in existing applications.
       
      The following features are implemented:
      Physically based sensor and focal length calculation Autoexposure Manual exposure Lense distortion Bloom (influenced by ISO, Shutter Speed, Sensor type etc.) Bokeh (influenced by Aperture, Sensor type and focal length) Tonemapping  
      You can find the repository at https://github.com/0x2A/physicam
       
      I would be happy about feedback, suggestions or contributions.

    • By altay
      Hi folks,
      Imagine we have 8 different light sources in our scene and want dynamic shadow map for each of them. The question is how do we generate shadow maps? Do we render the scene for each to get the depth data? If so, how about performance? Do we deal with the performance issues just by applying general methods (e.g. frustum culling)?
      Thanks,
       
  • Popular Now