コード例 #1
0
void SceneDrawer::DrawScene(UserTracker *pUserTrackerObj,int argc, char **argv,SampleManager *pSample, XnBool bShowLowConfidence)
{
    m_pUserTrackerObj=pUserTrackerObj;
    m_pSample=pSample;
    m_bShowLowConfidence=bShowLowConfidence;

#ifndef USE_GLES
    glInit(&argc, argv);
#endif

    InitTexture();
#ifndef USE_GLES
    glutMainLoop();
#else
    if (!opengles_init(GL_WIN_SIZE_X, GL_WIN_SIZE_Y, &display, &surface, &context))
    {
        printf("Error initializing opengles\n");
        ExitSample(EXIT_FAILURE);
    }

    glDisable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);
    glEnableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_COLOR_ARRAY);

    while (1)
    {
        glutDisplay();
        eglSwapBuffers(display, surface);
    }
    // we should never reach here! we have a while(1) above!
    ExitSample(EXIT_SUCCESS);

#endif
}
コード例 #2
0
ファイル: texture.cpp プロジェクト: venscn/3DGameEngine
Texture::Texture(const std::string& fileName, GLenum textureTarget, GLfloat filter)
{
 	m_fileName = fileName;

	std::map<std::string, TextureData*>::const_iterator it = s_resourceMap.find(fileName);
	if(it != s_resourceMap.end())
	{
		m_textureData = it->second;
		m_textureData->AddReference();
	}
	else
	{
		int x, y, bytesPerPixel;
		unsigned char* data = stbi_load(("./res/textures/" + fileName).c_str(), &x, &y, &bytesPerPixel, 4);

		if(data == NULL)
		{
			std::cerr << "Unable to load texture: " << fileName << std::endl;
		}

		InitTexture(x,y,data,textureTarget,filter);
		stbi_image_free(data);
		
		s_resourceMap.insert(std::pair<std::string, TextureData*>(fileName, m_textureData));
	}
}
コード例 #3
0
ファイル: PSBubbles.cpp プロジェクト: mittorn/hlwe_src
CPSBubbles::CPSBubbles(int maxParticles, const Vector &origin, const Vector &direction, const Vector &spread, float partvelocity, float size, int sprindex, int frame, float PartEmitterLife)
{
	index = 0;
	removenow = false;
	ResetParameters();
	if (!InitTexture(sprindex))
	{
		removenow = true;
		return;
	}
	m_iMaxParticles = maxParticles;
	VectorCopy(origin, m_vecOrigin);
	if (VectorCompare(origin, direction))
	{
		VectorClear(m_vecDirection);
		m_flRandomDir = true;
	}
	else
	{
		VectorCopy(direction, m_vecDirection);
		m_flRandomDir = false;
	}
	VectorCopy(spread, m_vecSpread);
	m_fParticleVelocity = partvelocity;
	m_iRenderMode = kRenderTransAdd;
	m_iFrame = frame;
	m_fScale = size;

	if (PartEmitterLife <= 0)
		m_fDieTime = -1;
	else
		m_fDieTime = gEngfuncs.GetClientTime() + PartEmitterLife;

	InitializeSystem();
}
コード例 #4
0
/**-----------------------------------------------------------------------------
 * 기하정보 초기화
 *------------------------------------------------------------------------------
 */
HRESULT InitGeometry()
{
	InitMatrix();
	InitTexture();
	InitVB();
	InitPS();
	return S_OK;
}
コード例 #5
0
ファイル: UIFrameLine.cpp プロジェクト: OLR-xray/XRay-NEW
void CUIFrameLine::Init(LPCSTR base_name, float x, float y, float size, bool horizontal, DWORD align)
{
	SetPos			(x, y);
	SetSize			(size);
	SetAlign		(align);
	SetOrientation	(horizontal);

	InitTexture(base_name);
}
コード例 #6
0
ファイル: GuiImage.cpp プロジェクト: gamebytes/pioneer
Image::Image(const char *filename, float renderWidth, float renderHeight):
	Widget(), m_color(Color::WHITE)
{
	InitTexture(filename);

	m_width = renderWidth;
	m_height = renderHeight;
	SetSize(m_width, m_height);
}
コード例 #7
0
void CameraCalibration::InitPangolin(int PanelWidth)
{

	if(stereo_mode)
	{
		const int WindowWidth = (ImageSize.width)*2+PanelWidth-1;
		const int WindowHeight = ImageSize.height;

		// Create OpenGL window in single line thanks to GLUT
		CreateGlutWindowAndBind("Main", WindowWidth, WindowHeight, GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		// Issue specific OpenGl we might need
		glEnable (GL_BLEND);
		glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		//GLenum err = glewInit();
		//if(GLEW_OK != err)
		//{
		//    cerr << "GLEW Error: " << glewGetErrorString(err) << endl;
		//    exit(0);
		//}

		panel = &CreatePanel("ui").SetBounds(1.0, 0.0, 0.0, (double)PanelWidth/DisplayBase().v.w);

		CamIntrins = new OpenGlMatrixSpec[2];

		CamIntrins[0] = ProjectionMatrixRDF_TopLeft(ImageSize.width,
													ImageSize.height,
													calib_params[0].CameraMatrix.at<double>(0, 0),
													calib_params[0].CameraMatrix.at<double>(1, 1),
													calib_params[0].CameraMatrix.at<double>(0, 2),
													calib_params[0].CameraMatrix.at<double>(1, 2),
													0.1,
													10000);

		CamIntrins[1] = ProjectionMatrixRDF_TopLeft(ImageSize.width,
													ImageSize.height,
													calib_params[1].CameraMatrix.at<double>(0, 0),
													calib_params[1].CameraMatrix.at<double>(1, 1),
													calib_params[1].CameraMatrix.at<double>(0, 2),
													calib_params[1].CameraMatrix.at<double>(1, 2),
													0.1,
													10000);

		const double panel = (double)(PanelWidth-1)/(double)(WindowWidth-1);
		const double middle_h = ((double)(WindowWidth-PanelWidth)/2.0)/(double)(WindowWidth) + (double)(PanelWidth)/(double)(WindowWidth);

		view[0] = &Display("ViewLeft").SetBounds(1.0, 0, panel, middle_h, -(double)ImageSize.width/(double)ImageSize.height);
		view[1] = &Display("ViewRight").SetBounds(1.0, 0, middle_h, 1.0, -(double)ImageSize.width/(double)ImageSize.height);
		
	}

	InitTexture();

	glutSpecialFunc(&SpecialKeyFunction);
}
コード例 #8
0
bool VolumetricFog::onAdd()
{
    if (!Parent::onAdd())
        return false;

    if (!VFRTM->IsInitialized())
    {
        Con::errorf("No VolumetricFogRTManager present!!");
        return false;
    }

    resetWorldBox();

    mShapeLoaded = LoadShape();

    setRenderTransform(mObjToWorld);

    addToScene();
    ColBox.set(getTransform(), (mObjBox.getExtents() * getScale() * COLBOX_SCALE));
    mObjSize = mWorldBox.getGreatestDiagonalLength();
    mObjScale = getScale();
    mTexTiles = mAbs(mTexTiles);
    mSpeed.set(mSpeed1.x, mSpeed1.y, mSpeed2.x, mSpeed2.y);
    mInvScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z));

    if (isClientObject())
    {
        conn = GameConnection::getConnectionToServer();
        if (!conn)
        {
            Con::errorf("VolumetricFog::onAdd - No Serverconnection");
            return false;
        }

        glowFX = static_cast<PostEffect*>(Sim::findObject("VolFogGlowPostFx"));

        mOldLightRayStrength = Con::getFloatVariable("$LightRayPostFX::brightScalar",1.0f);

        GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
        if (cv == NULL)
        {
            Con::errorf("VolumetricFog::onAdd - Canvas not found!!");
            return false;
        }
        mPlatformWindow = cv->getPlatformWindow();
        VolumetricFogRTManager::getVolumetricFogRTMResizeSignal().notify(this, &VolumetricFog::handleResize);
        GuiCanvas::getCanvasSizeChangeSignal().notify(this, &VolumetricFog::handleCanvasResize);

        InitTexture();
        return setupRenderer();
    }

    VFRTM->IncFogObjects();

    return true;
}
コード例 #9
0
ファイル: GuiImage.cpp プロジェクト: gamebytes/pioneer
Image::Image(const char *filename):
	Widget(), m_color(Color::WHITE)
{
	InitTexture(filename);

	const Graphics::TextureDescriptor &descriptor = m_quad->GetTexture()->GetDescriptor();
	m_width = descriptor.dataSize.x*descriptor.texSize.x;
	m_height = descriptor.dataSize.y*descriptor.texSize.y;
	SetSize(m_width, m_height);
}
コード例 #10
0
ファイル: Scene.cpp プロジェクト: sunzhiyuan/opencl
//--------------------------------------------------------------------------------------
// Name: Initialize()
// Desc: Initialize the scene.
//--------------------------------------------------------------------------------------
BOOL CSample::Initialize()
{
    // Create the font
    if( FALSE == m_Font.Create( "Samples/Fonts/Tuffy12.pak" ) )
        return FALSE;

    // Load the packed resources
    CFrmPackedResourceGLES resource;
    if( FALSE == resource.LoadFromFile( "Samples/Textures/MultiSample.pak" ) )
        return FALSE;

    // Create the logo texture
    m_pLogoTexture = resource.GetTexture( "Logo" );

    // Setup the user interface
    if( FALSE == m_UserInterface.Initialize( &m_Font, m_strName ) )
        return FALSE;
    m_UserInterface.AddOverlay( m_pLogoTexture->m_hTextureHandle, -5, -5,
                                m_pLogoTexture->m_nWidth, m_pLogoTexture->m_nHeight );
    m_UserInterface.AddTextString( "Press " FRM_FONT_KEY_0 " for Help", 1.0f, -1.0f );
    m_UserInterface.AddBoolVariable( &m_bRotationOn, "Rotation", "On", "Off" );
    m_UserInterface.AddHelpKey( FRM_FONT_KEY_STAR, "Toggle Orientation" );
    m_UserInterface.AddHelpKey( FRM_FONT_KEY_0, "Toggle Info Pane" );
    m_UserInterface.AddHelpKey( FRM_FONT_KEY_1, "Start Rotating" );
    m_UserInterface.AddHelpKey( FRM_FONT_KEY_2, "Stop Rotating" );

    InitProjectionMatrix();

    /* Set up line width */
    glLineWidth(1.0f);

    /* Set up a Framebuffer Object */
    glGenFramebuffers(1,&m_fboId);

    glBindFramebuffer(GL_FRAMEBUFFER, m_fboId);

    InitVertexBufferObject();

    /* Note that our FBO does not use a depth attachment. Safe to disable the depth writes */
    glDepthMask(GL_FALSE);

    InitVertexArrayObject();

    // Initialize the shaders
    if( FALSE == InitShaders() )
        return FALSE;

    InitTexture();

    /* Set up clear color */
    glClearColor(0.0f, 0.75f, 1.0f, 1.0f);

    return TRUE;
}
コード例 #11
0
		textureHandle_t CTextureLoaderTGA<Allocator>::LoadTextureFromFile(
			const string_t<Allocator>& filePath)
		{
			Utility::LoadFileTo<uchar_t, Allocator>(filePath, m_memory, false);

			GetFormat();

			LoadTextureFromMemory();

			return InitTexture();
		};
コード例 #12
0
	Painting::Painting(ID3D11Device* device, ID3D11DeviceContext* context)
		: MeshInstance(device), texture(0), width(5.0), height(5.0)
	{
		InitTexture(context);
		TestMaterial* canvasMaterial = new TestMaterial(device);
		SetMesh(new PlaneMesh(device, width, height));
		SetMaterial(canvasMaterial);
		canvasMaterial->Init();
		SetActiveTechniqueByName("TextureTech");		
		canvasMaterial->SetTexture(texture);
	}
コード例 #13
0
void CDisk_ConcentricRings::Init()

{
	// Generate the verticies and elements
	vector<vec3> vbo_data;
	vector<unsigned int> elements;
	unsigned int z_divisions = 20;
	unsigned int phi_divisions = 50;
	unsigned int r_divisions = 20;

	mRimStart = 0;
	CCylinder::GenerateRim(vbo_data, elements, z_divisions, phi_divisions);
	mRimSize = elements.size();
	// Calculate the offset in vertex indexes for the GenerateMidplane function
	// to generate correct element indices.
	unsigned int vertex_offset = vbo_data.size();
	mMidplaneStart = mRimSize;
	CCylinder::GenerateMidplane(vbo_data, elements, vertex_offset, r_divisions, phi_divisions);
	mMidplaneSize = elements.size() - mRimSize;

	// Create a new Vertex Array Object, Vertex Buffer Object, and Element Buffer
	// object to store the model's information.
	//
	// First generate the VAO, this stores all buffer information related to this object
	glGenVertexArrays(1, &mVAO);
	glBindVertexArray(mVAO);
	// Generate and bind to the VBO. Upload the verticies.
	glGenBuffers(1, &mVBO); // Generate 1 buffer
	glBindBuffer(GL_ARRAY_BUFFER, mVBO);
	glBufferData(GL_ARRAY_BUFFER, vbo_data.size() * sizeof(vec3), &vbo_data[0], GL_STATIC_DRAW);
	// Generate and bind to the EBO. Upload the elements.
	glGenBuffers(1, &mEBO);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mEBO);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements.size() * sizeof(unsigned int), &elements[0], GL_STATIC_DRAW);

	CHECK_OPENGL_STATUS_ERROR(glGetError(), "Could not create buffers");

	// Initialize the shader variables and texture following the default packing
	// scheme.
	InitShaderVariables();
	InitTexture();

	// All done. Un-bind from the VAO, VBO, and EBO to prevent it from being
	// modified by subsequent calls.
	glBindVertexArray(0);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

	CHECK_OPENGL_STATUS_ERROR(glGetError(), "Failed to bind back default buffers");

	// Indicate the model is ready to use.
	mModelReady = true;
}
コード例 #14
0
ファイル: PSDrips.cpp プロジェクト: mittorn/hlwe_src
// TODO: fix particle rotation!!
CPSDrips::CPSDrips(int maxParticles, const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &dir, int sprindex, int sprindex_splash, int r_mode, float sizex, float sizey, float scaledelta, float timetolive)
{
	index = 0;// the only good place for this
	removenow = false;
	ResetParameters();
//	m_pTexture = NULL;
	if (!InitTexture(sprindex))
	{
		removenow = true;
		return;
	}
//	m_iSplashTexture = sprindex_splash;
	if (sprindex_splash > 0)
	{
		m_pTexture2 = IEngineStudio.GetModelByIndex(sprindex_splash);
		if (!m_pTexture2 || m_pTexture2->type != mod_sprite)
			m_pTexture2 = NULL;
	}
	else
		m_pTexture2 = NULL;

	m_iMaxParticles = maxParticles;
	VectorCopy(mins, m_vecMinS);
	VectorCopy(maxs, m_vecMaxS);
	m_vecMinS[2] += 1.0f;

//	m_vecDirection = dir.Normalize();
//	m_fSpeed = dir.Length();
	VectorCopy(origin, m_vecOrigin);
	VectorCopy(dir, m_vecDirection);
	m_fSpeed = VectorNormalize(m_vecDirection);

	m_fScale = -0.1f;// XDM3035: this prevents CRenderSystem::InitializeSystem() from modifying sizes
	m_fScaleDelta = scaledelta;
	m_fSizeX = m_pTexture->maxs[1] - m_pTexture->mins[1];
	m_fSizeY = m_pTexture->maxs[2] - m_pTexture->mins[2];
	if (sizex > 0.0f)
		m_fSizeX *= sizex;
	if (sizey > 0.0f)
		m_fSizeY *= sizey;

//	m_pParticleList = NULL;
//	m_iFollowEntity = -1;
	m_iRenderMode = r_mode;

	if (timetolive <= 0.0f)
		m_fDieTime = -1;
	else
		m_fDieTime = gEngfuncs.GetClientTime() + timetolive;

//	CON_PRINTF("CPSDrips: size: %f %f\n", m_fSizeX, m_fSizeY);
	InitializeSystem();
}
コード例 #15
0
void CGLImpl::ReleaseTextures (void)
{
	glXeSurface_t *tex;
	int i;

	// explicitly NULL all textures and force texparams to dirty
	for (i = 0; i< XE_MAX_TEXTURE; i++)
	{
		tex = &glXeSurfaces[i];
		InitTexture(tex);
	}
} 
コード例 #16
0
void SceneDrawer::DrawScene(UserTracker *pUserTrackerObj,int argc, char **argv,SampleManager *pSample, XnBool bShowLowConfidence)
{
	m_pUserTrackerObj=pUserTrackerObj;
	m_pSample=pSample;
	m_bShowLowConfidence=bShowLowConfidence;

#ifndef USE_GLES
	glInitWithShaders( argc, argv );								// TOGGLE ON FOR SHADERS, OFF FOR FIXED FUNCTION

#endif
	InitTexture();
#ifndef USE_GLES

	const GLubyte *renderer = glGetString( GL_RENDERER );
	const GLubyte *vendor = glGetString( GL_VENDOR );
	const GLubyte *version = glGetString( GL_VERSION );
	const GLubyte *glslVersion =
							 glGetString( GL_SHADING_LANGUAGE_VERSION );

	GLint major, minor;
	glGetIntegerv(GL_MAJOR_VERSION, &major);
	glGetIntegerv(GL_MINOR_VERSION, &minor);

	printf("GL Vendor : %s\n", vendor);
	printf("GL Renderer : %s\n", renderer);
	printf("GL Version (string) : %s\n", version);
	printf("GL Version (integer) : %d.%d\n", major, minor);
	printf("GLSL Version : %s\n", glslVersion);

	glutMainLoop();
#else
	if (!opengles_init(GL_WIN_SIZE_X, GL_WIN_SIZE_Y, &display, &surface, &context))
	{
		printf("Error initializing opengles\n");
		ExitSample(EXIT_FAILURE);
	}

	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);
	glEnableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);

	while (1)
	{
		glutDisplay();
		eglSwapBuffers(display, surface);
	}
	// we should never reach here! we have a while(1) above!
	ExitSample(EXIT_SUCCESS); 

#endif
}
コード例 #17
0
ファイル: Scene.cpp プロジェクト: sunzhiyuan/opencl
//--------------------------------------------------------------------------------------
// Name: Resize()
// Desc: Invoked when window is resized
//--------------------------------------------------------------------------------------
BOOL CSample::Resize()
{
    InitProjectionMatrix();
    InitTexture();
    InitOffScreenFramebuffer(m_currentTextureIndex);

    glViewport(0,          /* x */
               0,          /* y */
               m_nWidth,   /* width */
               m_nHeight); /* height */

    return TRUE;
}
コード例 #18
0
ファイル: PSSparks.cpp プロジェクト: mittorn/hlwe_src
//-----------------------------------------------------------------------------
// Purpose: Draw system to screen. May get called in various situations, so
// DON'T change any RS variables here (do it in Update() instead).
//-----------------------------------------------------------------------------
void CPSSparks::Render(void)
{
	if (!InitTexture(texindex))
		return;

	if (!gEngfuncs.pTriAPI->SpriteTexture(m_pTexture, (int)m_fFrame))
		return;

	if (gHUD.m_iPaused <= 0)
	{
		gEngfuncs.GetViewAngles(m_vecAngles);
		VectorAdd(m_vecAngles, ev_punchangle, m_vecAngles);
	}

	Vector v_fwd;
	AngleVectors(m_vecAngles, v_fwd, NULL, NULL);

	gEngfuncs.pTriAPI->RenderMode(m_iRenderMode);
	gEngfuncs.pTriAPI->CullFace(TRI_NONE);
	gEngfuncs.pTriAPI->Begin(TRI_QUADS);

	CParticle *curPart = NULL;
	Vector velocity, crossvel, backpoint;
	for (int i = 0; i < m_iNumParticles; ++i)
	{
		curPart = &m_pParticleList[i];

		if (curPart->m_fEnergy <= 0.0f)
			continue;

		if (!PointIsVisible(curPart->m_vPos))// faster?
			continue;

		VectorCopy(curPart->m_vVel, velocity);
		CrossProduct(velocity, v_fwd, crossvel);

		Vector vx = velocity*curPart->m_fSizeX;
		Vector cy = crossvel*curPart->m_fSizeY;
		gEngfuncs.pTriAPI->Color4f(curPart->m_fColor[0], curPart->m_fColor[1], curPart->m_fColor[2], curPart->m_fColor[3] * curPart->m_fEnergy);
		gEngfuncs.pTriAPI->Brightness(curPart->m_fEnergy);
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f);
		gEngfuncs.pTriAPI->Vertex3fv(curPart->m_vPos - vx + cy);
		gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f);
		gEngfuncs.pTriAPI->Vertex3fv(curPart->m_vPos + cy);
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);
		gEngfuncs.pTriAPI->Vertex3fv(curPart->m_vPos - cy);
		gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);
		gEngfuncs.pTriAPI->Vertex3fv(curPart->m_vPos - vx - cy);
	}
	gEngfuncs.pTriAPI->End();
}
コード例 #19
0
ファイル: main.cpp プロジェクト: agnus-fem/VisDaVol
/* A general OpenGL initialization function.  Sets all of the initial parameters. */
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
	glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
	glDepthFunc(GL_GREATER); // The Type Of Depth Test To Do
	glEnable(GL_DEPTH_TEST); // Enables Depth Testing
	glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity(); // Reset The Projection Matrix

	gluPerspective(30.0f, (GLfloat) Width / (GLfloat) Height, 0.1f, 100.0f); // Calculate The Aspect Ratio Of The Window

	glMatrixMode(GL_MODELVIEW);

	//http://cirl.missouri.edu/gpu/glsl_lessons/glsl_geometry_shader/index.html

	setShaders(&ProgramObject);

	//http://www.opengl.org/wiki/Texture_Sampling
	//Setting shader's uniform variables
	GLint volume_location = glGetUniformLocation(ProgramObject,
			"volume_texture");
	GLint tf_location =
			glGetUniformLocation(ProgramObject, "transfer_function");

	//Checking if the state of the shader is also consider invalid.
	int isValid;
	glValidateProgram(ProgramObject);
	glGetProgramiv(ProgramObject, GL_VALIDATE_STATUS, &isValid);
	if (isValid)
		printf("Shader is valid!\n");
	else {
		printf("Shader isn't Valid!");
		exit(1);
	}

	// So, to set up those uniforms, bind the shader and call glUniform1i since they are considered as integers
	glUseProgram(ProgramObject);
	//Bind to tex unit 0
	glUniform1i(volume_location, 0);
	//Bind to tex unit 1
	glUniform1i(tf_location, 1);

	InitTexture();

	InitDraw();

}
コード例 #20
0
ファイル: Smoke.cpp プロジェクト: kelkka/projekt3d2
Smoke::Smoke(ID3D11Device* device,D3DXVECTOR3 pos,ID3D11DeviceContext* deviceContext):
ParticleSystem(device,deviceContext)
{
	mPosition = pos;

	srand(time(0));

	SystemProperties();

	InitParticles();

	InitBuffers(device);

	InitTexture(device);
}
コード例 #21
0
ファイル: scene.cpp プロジェクト: gMemiy/QtOpengl
void Scene::initializeGL()
{

    _hor = glm::vec2(-50, 50);
    _vert = glm::vec2(-50, 50);
    _depth = glm::vec2(2, -2);

    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glEnable(GL_BLEND);

    // грузим текстуры
    QString path("images/");
    _spot = InitTexture(path + "spot.png");
    _backGround = InitTexture(path + "background.jpg");
    _foreGround = InitTexture(path + "forest.png");
    _cloudTextures[0] = InitTexture(path + "cloud.png");
    _cloudTextures[1] = InitTexture(path + "cloud1.png");

    // настраиваем фейерверк и облака
    InitFireWork();

}
コード例 #22
0
ファイル: RSCylinder.cpp プロジェクト: mittorn/hlwe_src
void CRSCylinder::Render(void)
{
	if (!InitTexture(texindex))
		return;

	if (!gEngfuncs.pTriAPI->SpriteTexture(m_pTexture, (int)m_fFrame))
		return;

	gEngfuncs.pTriAPI->SpriteTexture(m_pTexture, m_iFrame);
	gEngfuncs.pTriAPI->RenderMode(m_iRenderMode);
	gEngfuncs.pTriAPI->Color4ub(m_color.r, m_color.g, m_color.b, (unsigned char)(m_fBrightness*255.0f));
	gEngfuncs.pTriAPI->Brightness(m_fBrightness);
	gEngfuncs.pTriAPI->CullFace(TRI_NONE);
	gEngfuncs.pTriAPI->Begin(TRI_QUADS);

	float h = m_fWidth/2.0f;
	float step = ((float)M_PI*2.0f)/m_usSegments;
	float x1 = 0.0f, y1 = 0.0f, x2 = 0.0f, y2 = 0.0f;
	float v = 0.0f;
	float vs = 0.25f;

	// UNDONE: ^
	for (float a = 0.0f; a < M_PI*2.0f; a += step)
	{
		SinCos(a, &x1, &y1);
		x1 = x1*m_fScale + m_vecOrigin[0];
		y1 = y1*m_fScale + m_vecOrigin[1];

		SinCos(a + step, &x2, &y2);
		x2 = x2*m_fScale + m_vecOrigin[0];
		y2 = y2*m_fScale + m_vecOrigin[1];

		gEngfuncs.pTriAPI->TexCoord2f(0.0f, v);
		gEngfuncs.pTriAPI->Vertex3f(x1, y1, m_vecOrigin[2]+h);

		gEngfuncs.pTriAPI->TexCoord2f(1.0f, v);// exchange these to rotate by 90
		gEngfuncs.pTriAPI->Vertex3f(x1, y1, m_vecOrigin[2]-h);

		gEngfuncs.pTriAPI->TexCoord2f(1.0f, v+vs);
		gEngfuncs.pTriAPI->Vertex3f(x2, y2, m_vecOrigin[2]-h);

		gEngfuncs.pTriAPI->TexCoord2f(0.0f, v+vs);// exchange these to rotate by 90
		gEngfuncs.pTriAPI->Vertex3f(x2, y2, m_vecOrigin[2]+h);

		v += vs;
	}
	gEngfuncs.pTriAPI->End();
}
コード例 #23
0
ファイル: main.cpp プロジェクト: bhattaca/shaders
int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
	glutInitWindowSize(RENDER_WIDTH,RENDER_HEIGHT);

	glutCreateWindow("shader cube");
	glutDisplayFunc(display_everything); // shadow
	//glutDisplayFunc(display);
	//glutDisplayFunc(displayBumpMapping );
	glutMouseFunc(mymouse);
	glutMotionFunc(mymotion);
	glutKeyboardFunc(mykey);

	// initialize GLEW

	GLenum err = glewInit();

	if ( err != GLEW_OK)
		printf(" Error initializing GLEW! \n");
	else
		printf("Initializing GLEW succeeded!\n");

	string fileLoc = "/home/arindam/Course/lab5/src/cubeXform";
	//programObject = SetupGLSL("/home/arindam/Course/lab3/cse5542Lab3/cubeXform");  //create shaders - assume the shaders are cubeXform.vert and cubeXform.frag
	programObject = SetupGLSL("/home/arindam/workspace/cse5542lab5/cubeXform");
	InitGeometry();

	InitTexture();

	generateShadowFBO();
	glEnable(GL_DEPTH_TEST);
	glClearColor(0,0,0,1.0f);

	glEnable(GL_CULL_FACE);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);



	cout <<"init geometry done "<<endl;
	InitVBO();
	cout <<" init vbo "<<endl;
	cout <<" init texture "<<endl;
	glutMainLoop();
}
コード例 #24
0
ファイル: game.cpp プロジェクト: Okara/Minecraft
C_Game::C_Game(sf::RenderWindow* sc)
    : C_Mod(sc)
{
    sf::Clock loadTimer;

    glewInit();

    InitFog();
    InitTexture();

    _cam->setPosition(Vector3D(CHUNK_SIZE/2, CHUNK_SIZE/2, CHUNK_ZVALUE/2 +1.6f));
    _cam->setSpeed(0.0006);
    _screen->ShowMouseCursor(false);

    glEnable(GL_TEXTURE_2D);
    InitCubes();

    _boolJumping = false;
    _frameJumping = 0;

    InitGUI();
    SetItemInHotkeys(CUBE_DIRT, 0);
    SetItemInHotkeys(CUBE_SAND, 1);
    SetItemInHotkeys(CUBE_SAND+1, 2);
    SetItemInHotkeys(CUBE_SAND+2, 3);
    SetItemInHotkeys(CUBE_SAND+3, 4);
    SetItemInHotkeys(CUBE_SAND+4, 5);
    SetItemInHotkeys(CUBE_SAND+5, 6);
    SetItemInHotkeys(CUBE_SAND+6, 7);
    SetItemInHotkeys(CUBE_SAND+7, 8);

    _actuelCubeInHand = _itemInHotkeys[0];

    C_Log::GetSingleton()->AddMessage( std::string("Scene loaded in " + FloatToString(loadTimer.GetElapsedTime()) + "sec.") );

    /*C_LineEdit *widg = new C_LineEdit();
    widg->move(10, sc->GetHeight()-40);
    widg->resize(350, 30);
    AddWidget(widg);*/

    Launch();
}
コード例 #25
0
ファイル: d3d11-texture2d.cpp プロジェクト: Arkkis/obs-studio
gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
		gs_color_format colorFormat, uint32_t levels, const void **data,
		uint32_t flags, gs_texture_type type, bool gdiCompatible,
		bool shared)
	: gs_texture      (device, type, levels, colorFormat),
	  width           (width),
	  height          (height),
	  dxgiFormat      (ConvertGSTextureFormat(format)),
	  isGDICompatible (gdiCompatible),
	  isShared        (shared),
	  isDynamic       ((flags & GS_DYNAMIC) != 0),
	  isRenderTarget  ((flags & GS_RENDERTARGET) != 0),
	  genMipmaps      ((flags & GS_BUILDMIPMAPS) != 0)
{
	InitTexture(data);
	InitResourceView();

	if (isRenderTarget)
		InitRenderTargets();
}
コード例 #26
0
ファイル: main.c プロジェクト: JianchengZh/kasicass
void InitGL(void)
{
	// set camera
	glViewport(0, 0, (GLsizei) SCREEN_WIDTH, (GLsizei) SCREEN_HEIGHT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, (GLfloat) SCREEN_WIDTH / (GLfloat) SCREEN_HEIGHT, 1.0, 30.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(0.0, 0.0, -4);

	glClearColor(0.5, 0.5, 0.5, 0.0);
	glShadeModel(GL_FLAT);
	glEnable(GL_DEPTH_TEST);

	InitTexture();
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	glGenTextures(1, &texName);
	glBindTexture(GL_TEXTURE_CUBE_MAP, texName);

	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, mytex1);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, mytex2);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, mytex3);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, mytex4);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, mytex5);
	glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, TEX_WIDTH, TEX_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, mytex6);

	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
	glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP);
	glEnable(GL_TEXTURE_GEN_S);
	glEnable(GL_TEXTURE_GEN_T);
	glEnable(GL_TEXTURE_GEN_R);
}
コード例 #27
0
ファイル: wave.c プロジェクト: Distrotech/mesa-demos
static void Init(void)
{

    glClearColor(0.0, 0.0, 0.0, 0.0);

    glShadeModel(GL_FLAT);

    glFrontFace(GL_CW);

    glEnable(GL_DEPTH_TEST);

    InitMaterials();
    InitTexture();
    InitMesh();

    glMatrixMode(GL_MODELVIEW);
    glTranslatef(0.0, 0.4, -1.8);
    glScalef(2.0, 2.0, 2.0);
    glRotatef(-35.0, 1.0, 0.0, 0.0);
    glRotatef(35.0, 0.0, 0.0, 1.0);
}
コード例 #28
0
ファイル: RSCylinder.cpp プロジェクト: mittorn/hlwe_src
//-----------------------------------------------------------------------------
// Purpose: Constructor.
// UNDONE: don't build mesh every render pass, precalculate its vertexes coords (into array) and then just scale them!
// Input  : origin - 
//			radius - 
//			radiusdelta - 
//			width - 
//			segments - 
//			sprindex - 
//			r_mode - 
//			r - 
//			g - 
//			b - 
//			a - 
//			adelta - 
//			timetolive - 
//-----------------------------------------------------------------------------
CRSCylinder::CRSCylinder(const Vector &origin, float radius, float radiusdelta, float width, unsigned short segments, int sprindex, int skin, int r_mode, unsigned char r, unsigned char g, unsigned char b, float a, float adelta, float timetolive)
{
	index = 0;// the only good place for this
	removenow = false;
	ResetParameters();
	m_pTexture = NULL;// MUST be before InitTexture()
	if (!InitTexture(sprindex))
	{
		removenow = true;
		return;
	}
	VectorCopy(origin, m_vecOrigin);
	m_fScale = radius;
	m_fScaleDelta = radiusdelta;
	m_fWidth = width;
	m_usSegments = segments;
	m_color.r = r;
	m_color.g = g;
	m_color.b = b;
	m_fBrightness = a;
	m_fBrightnessDelta = adelta;
	m_iFrame = skin;

	if (m_fScale < 2.0f)
		m_fScale = 2.0f;

	if (m_usSegments < 6)
		m_usSegments = 6;

	m_iFollowEntity = -1;
	m_iRenderMode = r_mode;

	if (timetolive < 0)
		m_fDieTime = -1;
	else
		m_fDieTime = gEngfuncs.GetClientTime() + timetolive;

	InitializeSystem();
}
コード例 #29
0
/**-----------------------------------------------------------------------------
 * 기하정보 초기화
 *------------------------------------------------------------------------------
 */
HRESULT InitGeometry()
{
    if ( FAILED( InitTexture() ) )
    {
        return E_FAIL;
    }
    if ( FAILED( InitVB() ) )
    {
        return E_FAIL;
    }
    if ( FAILED( InitIB() ) )
    {
        return E_FAIL;
    }
    SetupCamera();

    // 최초의 마우스 위치 보관
    POINT	pt;
    GetCursorPos( &pt );
    g_dwMouseX = pt.x;
    g_dwMouseY = pt.y;
    return S_OK;
}
コード例 #30
0
int TextureFont::LoadFont(char *fontlocation,int pointsize)
{
	if(!Face.LoadFace(fontlocation,pointsize)){return FALSE;}  //Load Face from fontfile with reqd pointsize	
	pt=pointsize; TexWidth= pt*24; TexHeight= pt*24;
	int penX=0,penY=pt*2;
	InitTexture();						//Initialize Texture Memory and Texture Parameters
 

	for(int i=32;i<127;i++)               //Run through all valid characters
	{ 	
		FT_Bitmap bitmap = Face.LoadGlyphBitmap(i);    //Load Bitmap of Character with charcode 'i'

		int width = bitmap.width;width = nextPowerOf2(width);  //Get Width of bitmap glyph
		int height = bitmap.rows;height = nextPowerOf2(height); //Get Height of bitmap glyph
	
		if(penX+Face.getAdvance() >=(TexWidth-1))  //Check boundary conditions
		{penY=penY+Face.getAscent()+10;penX=0;}		//Go to next line
										
		if(penY+height>=TexHeight-1)	//Check boundary conditions
		return TRUE;					//Max no of characters filled so end

		GLubyte *glyphdata = PrepareGlyph(bitmap,width,height);
		glTexSubImage2D(GL_TEXTURE_2D,0,penX  ,penY - Face.getHoriBearing(),width,height,GL_LUMINANCE_ALPHA,GL_UNSIGNED_BYTE,glyphdata);
		delete[] glyphdata;
			
		TexGlyphs[i] = new Glyph(penX ,penY - Face.getHoriBearing(),bitmap.width,bitmap.rows,Face.getHoriBearing(),Face.getAdvance());
  					
		penX=penX+Face.getAdvance()+4;
	             }

	//InitVBOExtensions();
	//for(int i=32;i<127;i++)
	//CreateVBO(i);
	

	return TRUE;
}