Jump to content
  • Advertisement
Sign in to follow this  
ViX44

OpenGL Transition from DX to SDL/OGL

This topic is 4858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently decided to scrap my almost-complete-but-not-quite VB6/DirectX7 project and start anew in C++. Things are moving along smoothly for the most part, but I'm having issues coaxing OpenGL to behave the way I want/expect. I have been attempting to replicate the simple semitransparency effect I achieved with DirectX by setting vertex lighting to (1,1,1,alpha). My attempts to do so in OpenGL are not succeeding. With glBlend enabled, the alpha works over black, but if drawn over an existing image, it generates a rather ugly additive effect. (This occurs even if alpha is set to full, when I would expect/desire a normal obscuring result, as though alpha was not a consideration.) Disabling glBlend remedies the additive overly effect, but seems to disable the alpha fading I desire. Any assistance is appreciated, in this regard, as well as for any tips that may ease my transition. I am working in a Orthagonal environment, accessing OpenGL via SDL, and using SDL_Image to load the textures I'm applying, which are sourced from PNG files.

Share this post


Link to post
Share on other sites
Advertisement
Thank you for your swift responce, the issue appears to be resolved.

An additional issue I've noticed: Since SDL doesn't provide scaling, I'm considering creating my game's screen background as an array of texture-sized fragments. However, while scaling them down seems to work well, scaling them up with GL_LINEAR causes problems. If I let the texture Repeat, the filtering samples pixels from the other side, making the edge display inappropriately. If Clamped, it seems to sample Blank pixels, producing a notable seam between the sections.

Is there a way to get Linear filtering, preferably with clamped texture, that will not blend the edges with black/blank pixels when scaling upward, or is that just the nature of the beast and something I must work around/cheat at?

Share this post


Link to post
Share on other sites
You needs to use either "GL_CLAMP_TO_EDGE", or create your texture with a "border" pixel around it (and fill it). The former is just another mode like "GL_REPEAT" (although I *think* it technically requires an extension), while the latter is fairly well documented in the glTexture2D, etc. man pages.

Share this post


Link to post
Share on other sites
ClampToEdge did not compile, but Google reported it was equivalent to 0x812F, and passing that value produced an imperfect, but far superior result. (I.E., at large scaling, >150%, the seams look like a minor texture misalignment, rather than a thick dark crosshair)

Thank you both for your assistance in these matters.

Share this post


Link to post
Share on other sites
Quote:
Original post by ViX44
ClampToEdge did not compile, but Google reported it was equivalent to 0x812F, and passing that value produced an imperfect, but far superior result. (I.E., at large scaling, >150%, the seams look like a minor texture misalignment, rather than a thick dark crosshair)

Get the latest "glext.h" file from SGI: http://oss.sgi.com/projects/ogl-sample/sdk.html

Yeah the sampling will technically be incorrect since with "clamp to edge" you're effectively just duplicating a pixel at the border. The "correct" way to do this is use the OpenGL bording stuff that I mentioned.

Share this post


Link to post
Share on other sites
Is there a moderately convenient way to change the OGL render target from the window/screen to a texture temporarily? I need to render text and while a bitmap system should be adequate, I'd rather not need draw every character individually every frame if I could render once to a texture and use it until the text changes.

Share this post


Link to post
Share on other sites
Quote:
Original post by mike25025
Take a look at glCopyTexImage2D. Its the only way I can think of.


You could use that but this is easier, and potentialy much more efficient:

This class RenderTexture, takes care of everything for you automatically:
1. it uses these windows-specific (WGL_render_texture or something) extension if available which lets you render directly to a texture with a very easy to use interface.
2. if that extension isn't available(if you're on linux) it handles using glCopyTexSubImage for you with the same interface as if you had that WGL extension



Rendertexture

Enjoy!

If you need any help with it ask me, or check out gpgpu.org

Share this post


Link to post
Share on other sites
Mike: Pulling from the screen, sounds like the system HL2 uses for generating cubemaps. Could be doable, but since my menu controls may frequently not be binary sized, pulling a surface off the screen may not be feasible.

...however, this does sound like one way a screenshot system could be worked out...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!