Jump to content
  • Advertisement
Sign in to follow this  
3dmodelerguy

Access Problem

This topic is 4885 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 am haveing trouble with this wxWidgets problem. what I want to do is when wxWidgets in Implemented, I want to to setup the Gamewindow frame and put a GLCanvas on the gamewindow. then i will start my game loop but i can not access the GLCanvas. is there any way i can access the GLWindow like this? Mainpp.cpp:
#include "PrecompiledHeaders.h"
#include "MainApp.h"
#include "GameWindow.h"
#include "GLCanvas.h"

int Default_Window_Value = -1;
int Game_State = 1;

DWORD Default_GL_Style = wxNO_BORDER;

wxString Empty_String;

IMPLEMENT_APP( MainApp );

bool MainApp::OnInit()
{

	int Default_Window_Value = -1;
	DWORD Default_GL_Style = wxNO_BORDER;
	wxString Empty_String;
	
	MainGameWindow *GameWindow = new MainGameWindow( _T ( "Stromgage Game Engine" ), wxPoint( 100, 100 ), wxSize( 800, 600 ) );

	GLCanvas *GLWindow = new GLCanvas( GameWindow, Default_Window_Value, wxPoint( 0, 0 ), wxSize( 800, 600 ), Default_GL_Style, Empty_String );

	GameWindow -> Show( true );

	GLWindow -> SetCurrent();

//	StartGame();


	return true;
	
}

/*void MainApp::StartGame()
{

	while(GameState != 1)
	{

		glClearColor(0.0, 0.0, 0.0, 0.0);
		GLWindow -> SwapBuffer();
		
	}

}*/


mainApp.h:
#ifndef MAINAPP_H
#define MAINAPP_H

#include "PrecompiledHeaders.h"

class MainApp : public wxApp
{

	public:
		virtual bool OnInit();
		void StartGame();

	private:
		wxWindow GameWindow;

};

#endif


Share this post


Link to post
Share on other sites
Advertisement

class MainApp : public wxApp {
public:
virtual bool OnInit();
void StartGame();
~MainApp() { delete GLWindow; }
private:
wxWindow GameWindow;
GLCanvas *GLWindow;
};


Set it to the result of the 'new' in the OnInit (I assume you have a good reason for not just making this a constructor, and that it has something to do with the IMPLEMENT_APP macro and how wxWindows is set up), and (as shown) 'delete' it in the destructor. Member variables are always available to member functions.

BTW, you don't seem to be using that GameWindow member, although you have a local variable by that name in the OnInit. That looks suspicious... may be a source of bugs?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!