Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075919 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:15:52 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Blank Screen
Pages: [1]
Print
Author Topic: Blank Screen  (Read 523 times)
gupta_shvm
Level 0
**


View Profile Email
« on: August 16, 2012, 08:00:06 AM »

I use C++ and am a beginner to OpenGL and have created a TexturedQuad class.  For some reason though, when my main loop class tries to dynamically create a TexturedQuad, or tries to create a static TexturedQuad within the loop it does not show up. It shows up perfectly when statically created in the main loop header file. Any ideas as to why this might be the case?
I've tried a lot of things but nothing has worked. Thanks in advance.
« Last Edit: August 16, 2012, 08:05:09 AM by gupta_shvm » Logged
randomnine
Level 1
*


View Profile WWW
« Reply #1 on: August 16, 2012, 08:37:25 AM »

Show us the code then. Smiley

Pop it on pastebin.com or something.
Logged

gupta_shvm
Level 0
**


View Profile Email
« Reply #2 on: August 16, 2012, 08:47:10 AM »

http://pastebin.com/YwJTCKPb

couldn't figure out how to embed
both sheet_ and player_(which at the moment just calls the TexturedQuad Render function and moves) don't render.
Logged
randomnine
Level 1
*


View Profile WWW
« Reply #3 on: August 16, 2012, 09:47:04 AM »

Working when statically initialised and not when dynamically initialised or initialised on the stack suggests that some variables are not being initialised correctly when the object is created, thus the way the memory has been initialised before construction is affecting the object's behaviour.

Are position_, angle_ and scalar_ initialised in the Quad constructor? Is the Quad constructor being called? (If it takes any arguments, it won't be.)

If that's not the issue, I'd suggest stepping through Render() and possibly LoadImage() in the debugger in both situations (once with the TexturedQuad statically created so it works, and once with it dynamically created so it doesn't) and checking to see which values are different. Go through, take notes and compare. Something will probably jump out as obviously weird, and then you can trace things back to figure out how it got that way.
Logged

gupta_shvm
Level 0
**


View Profile Email
« Reply #4 on: August 16, 2012, 11:07:44 AM »

i tried it and all the values are the same.. Sad
as for the quad constructor, it takes no arguments and initializes everything to 0
i made sure that the TexturedQuad goes through it too
like i said though the problem occurs even when i declare it statically outside of game.h
so like if i go
void Game::Rendering()
{
glClear(GL_COLOR_BUFFER_BIT);
TexturedQuad quad;
quad.LoadImage("images/grass.png");
quad.Render();
SDL_GL_SwapBuffers();
}
it doesn't show
obviously this isn't good programming but it should work theoretically... i have a feeling it has something to do with how i set up my context but i really can't figure it out. Here is my window class if anyone can help me:

http://pastebin.com/C94VQ0d9
Logged
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« Reply #5 on: August 16, 2012, 12:43:07 PM »

I wonder, does the background color change as you clear it with GL_COLOR_BUFFER_BIT? (In your case it should be gray I suppose)

Also, this (line 240, this: http://pastebin.com/YwJTCKPb):

Code:
glScalef(scalar_, scalar_, 0);

Should rather be this:

Code:
glScalef(scalar_, scalar_, 1);

But I'm not sure on this one. Scaling anything to 0 is generally bad.
Logged

Nothing to do here
Raptor85
Level 2
**

126746725
View Profile WWW Email
« Reply #6 on: August 16, 2012, 02:23:19 PM »

your opengl context probably isn't getting created before or is being destroyed before when creating the object dynamicly and isn't active at the time you load the texture, i would step through and make sure it does go through the window constructor nad does return a valid surface from setting the video mode, and make sure it does NOT destruct the window before loading the texture. Some seriously bizarre things can happen without throwing errors if that occurs, as essentially testing for opengl errors returns nothing if there's no active context.  Your code is a little hard to follow and you don't have the main loop listed (would be able to help more if you listed the rest of the code), but it's possible.  Another possibility is your blend mode settings are expecting a color input and you arent provoding one, and something in your main loop is impropery changing them making it "work" before fully initialized but not work after. again i can't see all of your code so I can't say for sure, no way to tell with partial source what order your functions would really get called in... but you could try passing a color array to see if the rectangle isn't actually being drawn just invisible due to your settings.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic