<commit_before>/*
 *  DAGON
 *  Copyright (c) 2011 Senscape s.r.l.
 *	All rights reserved.
 *
 *  NOTICE: Senscape permits you to use, modify, and distribute this
 *  file in accordance with the terms of the license agreement accompanying it.
 *
 */

#include "DGCamera.h"
#include "DGCommonGL.h"
#include "DGConfig.h"
#include "DGEffects.h"
#include "DGLog.h"
#include "DGMemory.h"
#include "DGRender.h"
#include "DGTexture.h"
#include "DGVideo.h"

#define N_DUST 1000
#define DUST_FACTOR 32767.0f

DGObject* dustTexture;

static struct particle {
	GLfloat x,y,z;
	GLfloat r,g,b;
	GLfloat xd,yd,zd;
	GLfloat cs;
} p[N_DUST];

int randomize(DGBool full) {
    int n = 32768;
    if (full)
        while (n > 32767)
            n = rand() / 32767;
    else
        while (n < 0 || n > 32767)
            n = rand() / 32767;
    return n;
}

void DGRenderDrawDust() {
    int i;
    float s = 0.0015f;
    
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    DGTextureBind(dustTexture);
    for (i = 0; i < N_DUST; i++)
    {
        p[i].x+=p[i].xd/100.0f;
        p[i].y+=p[i].yd/100.0f;
        p[i].z+=p[i].zd/100.0f;
        if (p[i].y<=-0.5f)
        {   // This should be defined according to the size of the cube
            p[i].xd=-(randomize(DG_YES)/DUST_FACTOR-0.5f)/200.0f;
            p[i].zd=-(randomize(DG_YES)/DUST_FACTOR-0.5f)/200.0f;
            p[i].yd=-randomize(DG_YES)/DUST_FACTOR/100.0f;
            p[i].x=(randomize(DG_YES)/DUST_FACTOR-0.5f);
            p[i].y=randomize(DG_NO)/DUST_FACTOR;
            p[i].z=(randomize(DG_YES)/DUST_FACTOR-0.5f);
        }

        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f);
        glVertex3f(p[i].x,p[i].y,p[i].z+s);
        glTexCoord2f(0.0f, 1.0f);
        glVertex3f(p[i].x,p[i].y+s,p[i].z+s);
        glTexCoord2f(1.0f, 1.0f);
        glVertex3f(p[i].x+s,p[i].y+s,p[i].z+s);
        glTexCoord2f(1.0f, 0.0f);
        glVertex3f(p[i].x+s,p[i].y,p[i].z+s);
        glEnd();
    }
}

// TODO: This should obviously go in the Texture manager
DGObject* blendTexture;

static DGBool blendNextUpdate;
static int cubeTextureSize;
static DGBool texturesEnabled;

#define NUM_VERTS 40
GLfloat circle[(NUM_VERTS * 2) + 2];

DGBool _isExtensionSupported(const char *extension);
static DGBool supports_shaders = DG_NO;

void DGRenderInitialize() {
	int i;
	const GLubyte* version = glGetString(GL_VERSION);
	
	DGLogTrace(DG_MOD_RENDER, "Initializing render system...");
	DGLogInfo(DG_MOD_RENDER, "OpenGL version: %s", version);
	
	/*GLint texSize;
	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
	 
	GL_MAX_TEXTURE_IMAGE_UNITS // For the cache
	*/
	
	glewInit();
	
	if (glewIsSupported("GL_VERSION_2_0")) {
		DGEffectsInit();
        DGEffectsSetGamma(2.5f);
		supports_shaders = DG_YES;
	}
	else {
		DGLogWarning(DG_MOD_RENDER, "Visual effects not supported on this system");<commit_msg>Refs ticket 44 for testing<commit_after>/*
 *  DAGON
 *  Copyright (c) 2011 Senscape s.r.l.
 *	All rights reserved.
 *
 *  NOTICE: Senscape permits you to use, modify, and distribute this
 *  file in accordance with the terms of the license agreement accompanying it.
 *
 */

#include "DGCamera.h"
#include "DGCommonGL.h"
#include "DGConfig.h"
#include "DGEffects.h"
#include "DGLog.h"
#include "DGMemory.h"
#include "DGRender.h"
#include "DGTexture.h"
#include "DGVideo.h"

#define N_DUST 1000
#define DUST_FACTOR 32767.0f

DGObject* dustTexture;

static struct particle {
	GLfloat x,y,z;
	GLfloat r,g,b;
	GLfloat xd,yd,zd;
	GLfloat cs;
} p[N_DUST];

int randomize(DGBool full) {
    int n = 32768;
    if (full)
        while (n > 32767)
            n = rand() / 32767;
    else
        while (n < 0 || n > 32767)
            n = rand() / 32767;
    return n;
}

void DGRenderDrawDust() {
    int i;
    float s = 0.0015f;
    
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    DGTextureBind(dustTexture);
    for (i = 0; i < N_DUST; i++)
    {
        p[i].x+=p[i].xd/100.0f;
        p[i].y+=p[i].yd/100.0f;
        p[i].z+=p[i].zd/100.0f;
        if (p[i].y<=-0.5f)
        {   // This should be defined according to the size of the cube
            p[i].xd=-(randomize(DG_YES)/DUST_FACTOR-0.5f)/200.0f;
            p[i].zd=-(randomize(DG_YES)/DUST_FACTOR-0.5f)/200.0f;
            p[i].yd=-randomize(DG_YES)/DUST_FACTOR/100.0f;
            p[i].x=(randomize(DG_YES)/DUST_FACTOR-0.5f);
            p[i].y=randomize(DG_NO)/DUST_FACTOR;
            p[i].z=(randomize(DG_YES)/DUST_FACTOR-0.5f);
        }

        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f);
        glVertex3f(p[i].x,p[i].y,p[i].z+s);
        glTexCoord2f(0.0f, 1.0f);
        glVertex3f(p[i].x,p[i].y+s,p[i].z+s);
        glTexCoord2f(1.0f, 1.0f);
        glVertex3f(p[i].x+s,p[i].y+s,p[i].z+s);
        glTexCoord2f(1.0f, 0.0f);
        glVertex3f(p[i].x+s,p[i].y,p[i].z+s);
        glEnd();
    }
}

// TODO: This should obviously go in the Texture manager
DGObject* blendTexture;

static DGBool blendNextUpdate;
static int cubeTextureSize;
static DGBool texturesEnabled;

#define NUM_VERTS 40
GLfloat circle[(NUM_VERTS * 2) + 2];

DGBool _isExtensionSupported(const char *extension);
static DGBool supports_shaders = DG_NO;

unsigned int frameBuffer;
unsigned int frameBufferDepth;
unsigned int frameBufferTexture;

void DGRenderInitialize() {
	int i;
	const GLubyte* version = glGetString(GL_VERSION);
	
	DGLogTrace(DG_MOD_RENDER, "Initializing render system...");
	DGLogInfo(DG_MOD_RENDER, "OpenGL version: %s", version);
	
	/*GLint texSize;
	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
	 
	GL_MAX_TEXTURE_IMAGE_UNITS // For the cache
	*/
	
	glewInit();
	
	if (glewIsSupported("GL_VERSION_2_0")) {
		DGEffectsInit();
        DGEffectsSetGamma(2.5f);
		supports_shaders = DG_YES;
	}
	else {
		DGLogWarning(DG_MOD_RENDER, "Visual effects not supported on this system");
{'fraction_non_alphanumeric': 0.1505357760110612, 'fraction_numerical': 0.03905979951607328, 'mean_word_length': 2.9937888198757765, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5726557', 'n_tokens_mistral': 2607, 'n_tokens_neox': 2396, 'n_words': 458}