Jump to content
  • Advertisement
Sign in to follow this  
Mol-mol

drawing problem with openGL and Tao

This topic is 4095 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

hi there, i'm new to game dev and I'm trying to make a first start in Tao adn OpenGL. Now it seems that this is not working so well since My screen stays black. I followed some of the Nehe lessons and I'm not able to do the same in C# with tao. For example lesson two. This already is not working at all: Gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); Gl.glBegin(GL_TRIANGLES); Gl.glVertex3f( 0.0f, 1.0f, 0.0f); Gl.glVertex3f(-1.0f,-1.0f, 0.0f); Gl.glVertex3f( 1.0f,-1.0f, 0.0f); Gl.glEnd();

Share this post


Link to post
Share on other sites
Advertisement
No I haven't, why? It should work, since I got this from a code sample that actually workd. What's the deal with swapbuffers?

Thanks by the way.

Share this post


Link to post
Share on other sites
It seems that there is no such function in the Tao framework. I've checked out the API and search at many other places but there seem nothing like SwapBuffers.

Hmmm thats kind of strange, but thanks for the information. It sounds very logical to me, but somehow there is no such function.
Actually what I'm trying to do is to get lesson 19 working with the Tao framework. Now the converted version that is posted there is nice, but is based on the old framework, CsGL, while I'm trying to get this to work with the new version of the framework, Tao. It's compiles smoothly, but the screen stays black instead of a nice particle system.

I choose C# because it is easier to learn for me, instead of C++.

anyways for some reason, weather it is the SwapBuffer() or not, I can't get it to work.

http://www.gamedev.net/community/forums/images/icons/icon91.gif

Share this post


Link to post
Share on other sites
Hmm I really don't understand a thing about that SwapBuffer function.

This the code I'm trying to run with TAO:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Tao.OpenGl;
using Tao.Platform.Windows;

namespace CGtest1
{
public partial class OpenGlForm : Form
{
public OpenGlForm()
{
InitializeComponent();
simpleOpenGlControl1.InitializeContexts();
InitGl();

}

private void InitGl()
{
Gl.glShadeModel(Gl.GL_SMOOTH);
Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Gl.glClearDepth(1.0f); // Depth Buffer Setup
Gl.glEnable(Gl.GL_DEPTH_TEST);// Enables Depth Testing
Gl.glDepthFunc(Gl.GL_LEQUAL);
Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);

}


private void RenderScene()
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();

Gl.glTranslatef(-1.5f, 0.0f, -6.0f);

Gl.glBegin(Gl.GL_TRIANGLES);
Gl.glVertex3f(0.0f, 1.0f, 0.0f);
Gl.glVertex3f(-1.0f,-1.0f, 0.0f);
Gl.glVertex3f(1.0f,-1.0f, 0.0f);
Gl.glEnd();


}

private void SetView(int height, int width)
{
if (height == 0)height = 1;
Gl.glViewport(0, 0, width, height);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();

Glu.gluPerspective(45.0f, width / height, 0.1f, 100.0f);

Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
}



private void simpleOpenGlControl1_Paint(object sender, PaintEventArgs e)
{
RenderScene();
}

protected override void OnResize(EventArgs e)
{
base.OnResize(e);
SetView(this.Height, this.Width);
}



}
}

Share this post


Link to post
Share on other sites
'simpleOpenGlControl1' should contain a SwapBuffers method. Try calling that.

EDIT: Ok, a small explanation should clear things up. SimpleOpenGlControl creates what is called a 'double-buffered' context. OpenGL functions will draw to the backbuffer while your screen displays the frontbffer. When you are done rendering you'll have to issue a call that 'flips' the backbuffer and the frontbuffer to display the result of your drawing operations.

OpenGL itself can only draw to the buffers - flipping is the operating system responsibility (e.g. through wglSwapBuffers). SimpleOpenGlControl interacts with the operating system to create a window and control flipping, so you have to look at SimpleOpenGlControl's methods for this functionality.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!