Archived

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

kaiel090x

OpenGL OpenGL with Bitmaps

Recommended Posts

I want to make a 2d game using bitmaps in OpenGL. I dont need to know how to do it, I just want to know if its possible.You can email me at kaiel090x@hotmail.com. I would be thankful for a response any time soon. ~ from the depths of the ocean

Share this post


Link to post
Share on other sites
I know I could make a 2d game with opengl. Bitmaps included. I don''t know about you though. You could always give it the old college try.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Thanks? Im guessing that means it possible to use bitmaps is OpenGL, and your arrogant and believe your the only one who can do it? Your response confused me, correct me if I''m wrong about you. Thank you for telling me its possible.

Share this post


Link to post
Share on other sites
Thanks. i was just wondering because I just learned C++, and I baught the book Game Programming in OpenGL. But I didnt know if after I learned openGL I''d be able to make the current 2d(bitmap)game Im trying to make. What about like charecter movement, there are two steps per direction the charecter walks, left foot and right foot, could I use a gif or two bitmaps?

quote:
Original post by Null and Void
Yes, 2D in OpenGL is pretty easy. Treat the bitmaps just like textures, use an orthographic project matrix, and texture some quads .

[Resist Windows XP''s Invasive Production Activation Technology!]


Share this post


Link to post
Share on other sites
As far as I know all images (.jpg, .gif, .tif, ...) are stored internally (i.e. in ram) as (uncompressed) bitmaps. You might take an animated .gif for your sprite but you will have to decompress it to be able to load it as a texture for your quads.
Opengl can''t handle .gifs itself so the benefit of an animated .gif is only to store disk space (not in ram). And You have the "problem" that you have to find and learn a library to be able to load and decompress gifs. And .gifs are even copyrighted (in the worst case compu$erve might even sue you if you go commercial).
My suggestion is to store all your sprites animations in one big bitmap and upload that bitmap to texture memory. This is faster than having many small textures for each animation and you don''t have to mess with a new api.
If you really want to store your sprites in a compressed format you may use the .png format which has a better compression than gif (even for true color images), no loss of quality (as with .jpgs) and is absoluteley free of charges.
Hope that helped ;-)

baumep

Share this post


Link to post
Share on other sites
I think I understand. So I should have one bitmap with every single ''image'' in it. And load it as a texture. What do you mean I would have to learn a new library though?

Share this post


Link to post
Share on other sites
He''s saying that to load GIF''s you''d have to go off on a tangent and learn how to decompress them (using LZO the compression algorithm), which would take much longer to learn than using texture coordinates to reference different parts of the same images as frames.

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
Thank you very much, everyone who has responded to me. Thank you Null and Viod. You sound like you know what your doing so I will take your advice.

quote:
Original post by Null and Void
He''s saying that to load GIF''s you''d have to go off on a tangent and learn how to decompress them (using LZO the compression algorithm), which would take much longer to learn than using texture coordinates to reference different parts of the same images as frames.

[Resist Windows XP''s Invasive Production Activation Technology!]




~ from the depths of the ocean

Share this post


Link to post
Share on other sites
Just to go off on a tangent here...

I understand that to do 2d easily you culd just texture some quads in an orthographic projection, but if all images are just 2d and always facing the same direction, it seems like a waste of CPU to make it do all the 3d calculations for an image that really doesnt need to be transformed in 3d at all.

Does anyone know if there is some way to bypass the 3d part, and just put your own pixels directly into the screen? Maybe somehow to lock the memory that OpenGL is drawing to and use it yourself?

As an example, something like a menu in a game, or like a 2-d cockpit. Just where the 3d stuff is drawn, and you want to overwrite some of it with your own pixels.

Any ideas?

~Dom

Share this post


Link to post
Share on other sites
There will never be access to the frame buffer in OpenGL, not in the way you want anyway. This has been discussed at length by nvidia engineers at the opengl.org forums. Ortho mode works quite well anyway.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites

  • Partner Spotlight

  • Forum Statistics

    • Total Topics
      627636
    • Total Posts
      2978331
  • Similar Content

    • By xhcao
      Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness. 
    • By cebugdev
      hi guys, 
      are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
      Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic 
      let me know if you guys have recommendations.
      Thank you in advance!
    • By dud3
      How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below? 
      Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
      Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.
       
      References:
      Code: https://pastebin.com/Hcshj3FQ
      The video shows the difference between blender and my rotation:
       
    • By Defend
      I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
      My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
      * make lots of VAO/VBO pairs and flip through them to render different objects, or
      * make one big VBO and jump around its memory to render different objects. 
      I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
      If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?
       
    • By test opty
      Hello all,
       
      On my Windows 7 x64 machine I wrote the code below on VS 2017 and ran it.
      #include <glad/glad.h>  #include <GLFW/glfw3.h> #include <std_lib_facilities_4.h> using namespace std; void framebuffer_size_callback(GLFWwindow* window , int width, int height) {     glViewport(0, 0, width, height); } //****************************** void processInput(GLFWwindow* window) {     if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)         glfwSetWindowShouldClose(window, true); } //********************************* int main() {     glfwInit();     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);     //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);     GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", nullptr, nullptr);     if (window == nullptr)     {         cout << "Failed to create GLFW window" << endl;         glfwTerminate();         return -1;     }     glfwMakeContextCurrent(window);     if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))     {         cout << "Failed to initialize GLAD" << endl;         return -1;     }     glViewport(0, 0, 600, 480);     glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);     glClearColor(0.2f, 0.3f, 0.3f, 1.0f);     glClear(GL_COLOR_BUFFER_BIT);     while (!glfwWindowShouldClose(window))     {         processInput(window);         glfwSwapBuffers(window);         glfwPollEvents();     }     glfwTerminate();     return 0; }  
      The result should be a fixed dark green-blueish color as the end of here. But the color of my window turns from black to green-blueish repeatedly in high speed! I thought it might be a problem with my Graphics card driver but I've updated it and it's: NVIDIA GeForce GTX 750 Ti.
      What is the problem and how to solve it please?
  • Popular Now