1
\$\begingroup\$

I am fairly new to OpenGL. I have a 2D game in SDL2 that uses currently works by creating a SDL_Surface from the pixel data, copying it into a SDL_Texture, and rendering it to the screen with SDL_Renderer. But rather than using SDL to render the pixels, I'd like to switch to OpenGL. The reason I'd like to switch is because I need to render some lines on top of the pixel data and SDL_RenderDrawLine() just doesn't have all the features I need (like line thickness or glScissor). At first, I attempted to switch to OpenGL by using glDrawPixels() and I was happy with the results. However, I found out that glDrawPixels() does not seem to be available in OpenGL-ES (mobile devices). I have looked through some tutorials, but they all use shaders and other fancy stuff that I don't think I really need. Is there a simple way (like glDrawPixels()) to just draw pixel data to the screen for a 2D game? The pixel data is in the format GL_UNSIGNED_BYTE and it contains everything that I want to draw on the screen (except for several 2D line segments that I plan on using GL to render on top).

\$\endgroup\$
  • \$\begingroup\$ OpenGL for mobiles require Shaders for almost everything... Personally I'm not really sure of another way to do work there. \$\endgroup\$ – rlam12 May 10 '16 at 23:50
  • \$\begingroup\$ Why not use models and textures? \$\endgroup\$ – Bálint May 11 '16 at 6:38
  • \$\begingroup\$ As a side comment OpenGL ES does not neccesarily support lines wider than one pixel. It is left in the API mainly for debugging. Go for triangles instead if possible. \$\endgroup\$ – Andreas May 11 '16 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.