Jump to content

Graphics() fct replacement


Recommended Posts

Hi guys!


Any idea how to replace the lw's Graphics() fct? I can't make it work without it since I don't know how to set it up properly without it (bacbuffer, etc). If I remove the line, I can create meshes but nothing that relates to textures. If I do call LoadTexture for instance, I get a msgbox "OpenGL Error - GL_INVALID_VALUE". Also, the backbuffer's height and width are 0.


I'm using tao and vs2008 and a SimpleOpenglcontrol in my form.


This is my c# code:


m_iWidth = mgr.GetDataInt("OpengGLWindowWidth", DEFAULT_OGL_WIDTH);
m_iHeight = mgr.GetDataInt("OpengGLWindowHeight", DEFAULT_OGL_HEIGHT);
string strFakeAppTitle = mgr.GetDataString("FakeAppTitle", DEFAULT_FAKE_APP_TITLE);


// We're initializing the window just because I can't seem to init all needed stuff in 
// lw to make the textures and meshes work.
Leadwerks.Engine.Leadwerks.Graphics(m_iWidth, m_iHeight, 0, 0, Leadwerks.Engine.Leadwerks.GRAPHICS_BACKBUFFER|Leadwerks.Engine.Leadwerks.GRAPHICS_DEPTHBUFFER);

// hide the window right away -- HACK!!!
int hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
 if (pr.MainWindowTitle == strFakeAppTitle)
   hWnd = pr.MainWindowHandle.ToInt32();
   ShowWindow(hWnd, 0);

// setup leadwerks path
string strAbstractPath = mgr.GetDataString("AbstractPath", Application.StartupPath);

// Create our custom buffer
OpenGLControl.MakeCurrent(); // this has to be done before calling leadwerks stuff..            
m_World_fake = Leadwerks.Engine.Leadwerks.CreateWorld();  // Create world
m_buffer = Leadwerks.Engine.Leadwerks.CreateCustomBuffer(DGetSize, DMakeCurrent);

Link to comment
Share on other sites

Download the BMX demo and take a look at the source code to their OpenGL Module, it shows you the meat of the Graphics call, which has its root in C/C++ calls on the Windows API to create a window, setup a context, etc.


It basically does what any tutorial on OpenGL basics shows you how to do with regards to a window and context.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)


IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15


csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...